Refactoring of some of the font management in WResourceManager. This change looks bigger than it actually is - most of the touched files are simply renaming of some font enums that I moved out of MTGDefinitions into the resource manager header files. The main points of this change: collapsing the font containers into a single map, eliminating duplicated functions, and migrating the font building logic into the resource manager class. GameApp doesn't need to know anything about the fonts it uses, and likewise, font users don't need to know what the name of their chosen font is, just the FONT_TYPE enum.

(I did a cursory check to make sure chinese still displays correctly - at a glance, I'm seeing what looks correct to someone who doesn't read the language :) )
This commit is contained in:
wrenczes@gmail.com
2010-10-19 07:51:32 +00:00
parent f64c2b0183
commit 5aa3dc6fd3
34 changed files with 313 additions and 354 deletions
-5
View File
@@ -171,11 +171,6 @@ class Constants
CHANCE_PURE_OVERRIDE = 50, CHANCE_PURE_OVERRIDE = 50,
CHANCE_MIXED_OVERRIDE = 25, CHANCE_MIXED_OVERRIDE = 25,
MAIN_FONT = 0,
MENU_FONT = 1,
MAGIC_FONT = 2,
OPTION_FONT = 1,
GRADE_SUPPORTED = 0, GRADE_SUPPORTED = 0,
GRADE_BORDERLINE = 1, GRADE_BORDERLINE = 1,
GRADE_UNOFFICIAL = 2, GRADE_UNOFFICIAL = 2,
+23 -3
View File
@@ -6,10 +6,27 @@
#include <JSprite.h> #include <JSprite.h>
#include "config.h" #include "config.h"
namespace Fonts
{
enum Font_Type
{
MAIN_FONT = 0,
MENU_FONT = 1,
OPTION_FONT = 1,
MAGIC_FONT = 2,
SMALLFACE_FONT = 3
};
// when using gbk languages and we need to keep around single byte font variants,
// the single byte fonts will be offset by this value
const unsigned int kSingleByteFontOffset = 100;
}
class WFont class WFont
{ {
public: public:
unsigned char id; int mFontID;
// Rendering text to screen. // Rendering text to screen.
virtual void DrawString(const char *s, float x, float y, int align=JGETEXT_LEFT, float leftOffset = 0, float width = 0) = 0; virtual void DrawString(const char *s, float x, float y, int align=JGETEXT_LEFT, float leftOffset = 0, float width = 0) = 0;
virtual void DrawString(std::string s, float x, float y, int align=JGETEXT_LEFT, float leftOffset = 0, float width = 0) = 0; virtual void DrawString(std::string s, float x, float y, int align=JGETEXT_LEFT, float leftOffset = 0, float width = 0) = 0;
@@ -29,13 +46,16 @@ public:
virtual void SetTracking(float tracking) = 0; virtual void SetTracking(float tracking) = 0;
// Set Base for the character set to use. // Set Base for the character set to use.
virtual void SetBase(int base) = 0; virtual void SetBase(int base) = 0;
WFont(int inID) : mFontID(inID) {};
virtual ~WFont() {}; virtual ~WFont() {};
}; };
class WLBFont : public WFont class WLBFont : public WFont
{ {
public: public:
WLBFont(const char *fontname, int lineheight, bool useVideoRAM=false) { WLBFont(int inFontID, const char *fontname, int lineheight, bool useVideoRAM=false)
: WFont(inFontID)
{
it = NEW JLBFont(fontname,lineheight,useVideoRAM); it = NEW JLBFont(fontname,lineheight,useVideoRAM);
}; };
~WLBFont() {SAFE_DELETE(it);}; ~WLBFont() {SAFE_DELETE(it);};
@@ -58,7 +78,7 @@ private:
class WFBFont : public WFont class WFBFont : public WFont
{ {
public: public:
WFBFont(const char *fontname, int lineheight, bool useVideoRAM=false); WFBFont(int inFontID, const char *fontname, int lineheight, bool useVideoRAM=false);
~WFBFont(); ~WFBFont();
void DrawString(const char *s, float x, float y, int align=JGETEXT_LEFT, float leftOffset = 0, float width = 0); void DrawString(const char *s, float x, float y, int align=JGETEXT_LEFT, float leftOffset = 0, float width = 0);
+10 -14
View File
@@ -178,16 +178,12 @@ public:
JTexture* GetTexture(const string &textureName); JTexture* GetTexture(const string &textureName);
JTexture* GetTexture(int id); JTexture* GetTexture(int id);
int reloadWFonts(); // Font management functions
int reloadWLBFonts(); void InitFonts(const std::string& inLang);
//Wrapped from JResourceManger. TODO: Privatize int ReloadWFonts();
WFont * LoadWLBFont(const string &fontName, int height); WFont* LoadWFont(const string& inFontname, int inFontHeight, int inFontID);
WFont * LoadWFBFont(const string &fontName, int height); WFont* GetWFont(int id);
WFont * GetWFont(const string &fontName);
WFont * GetWFont(int id);
WFont * GetWLBFont(int id);
void RemoveWFonts(); void RemoveWFonts();
void RemoveWLBFonts();
//Wrapped from JSoundSystem. TODO: Privatize. //Wrapped from JSoundSystem. TODO: Privatize.
JMusic * ssLoadMusic(const char *fileName); JMusic * ssLoadMusic(const char *fileName);
@@ -210,7 +206,7 @@ private:
WCache<WCachedSample,JSample> sampleWCache; WCache<WCachedSample,JSample> sampleWCache;
WCache<WCachedParticles,hgeParticleSystemInfo> psiWCache; WCache<WCachedParticles,hgeParticleSystemInfo> psiWCache;
typedef std::map<std::string, WManagedQuad> ManagedQuadMap; typedef std::map<std::string, WManagedQuad> ManagedQuadMap;
ManagedQuadMap mManagedQuads; ManagedQuadMap mManagedQuads;
typedef std::map<int, std::string> IDLookupMap; typedef std::map<int, std::string> IDLookupMap;
@@ -219,10 +215,10 @@ private:
//Statistics of record. //Statistics of record.
unsigned int lastTime; unsigned int lastTime;
int lastError; int lastError;
vector<WFont *> mWFontList;
map<string, int> mWFontMap; typedef std::map<int, WFont*> FontMap;
vector<WLBFont *> mWLBFontList; FontMap mWFontMap;
map<string, int> mWLBFontMap; std::string mFontFileExtension;
}; };
extern WResourceManager resources; extern WResourceManager resources;
+1 -1
View File
@@ -152,7 +152,7 @@ void AIStats::Render(){
if (player == g->players[1]) x0 = 280; if (player == g->players[1]) x0 = 280;
JRenderer::GetInstance()->FillRoundRect(x0,10,200,180,5,ARGB(50,0,0,0)); JRenderer::GetInstance()->FillRoundRect(x0,10,200,180,5,ARGB(50,0,0,0));
WFont * f = resources.GetWFont("simon"); WFont * f = resources.GetWFont(Fonts::MAIN_FONT);
int i = 0; int i = 0;
char buffer[512]; char buffer[512];
list<AIStat *>::iterator it; list<AIStat *>::iterator it;
+1 -1
View File
@@ -225,7 +225,7 @@ void ActionLayer::setMenuObject(Targetable * object, bool must){
SAFE_DELETE(abilitiesMenu); SAFE_DELETE(abilitiesMenu);
abilitiesMenu = NEW SimpleMenu(10, this, Constants::MAIN_FONT, 100, 100,object->getDisplayName().c_str()); abilitiesMenu = NEW SimpleMenu(10, this, Fonts::MAIN_FONT, 100, 100,object->getDisplayName().c_str());
for (int i=0;i<mCount;i++){ for (int i=0;i<mCount;i++){
ActionElement * currentAction = (ActionElement *)mObjects[i]; ActionElement * currentAction = (ActionElement *)mObjects[i];
+6 -6
View File
@@ -37,7 +37,7 @@ void NextGamePhase::Render(){
GameObserver * g = GameObserver::GetInstance(); GameObserver * g = GameObserver::GetInstance();
int nextPhase = (g->getCurrentGamePhase() + 1) % Constants::MTG_PHASE_CLEANUP; int nextPhase = (g->getCurrentGamePhase() + 1) % Constants::MTG_PHASE_CLEANUP;
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
mFont->SetBase(0); mFont->SetBase(0);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
char buffer[200]; char buffer[200];
@@ -66,7 +66,7 @@ const string Interruptible::getDisplayName() const
} }
void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string alt1, string alt2, string action, bool bigQuad){ void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string alt1, string alt2, string action, bool bigQuad){
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
mFont->SetColor(ARGB(255,255,255,255)); mFont->SetColor(ARGB(255,255,255,255));
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
mFont->DrawString(_(action).c_str(), x + 30 , y, JGETEXT_LEFT); mFont->DrawString(_(action).c_str(), x + 30 , y, JGETEXT_LEFT);
@@ -317,7 +317,7 @@ int PutInGraveyard::resolve(){
} }
void PutInGraveyard::Render(){ void PutInGraveyard::Render(){
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
mFont->SetBase(0); mFont->SetBase(0);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
if (!removeFromGame){ if (!removeFromGame){
@@ -354,7 +354,7 @@ int DrawAction::resolve(){
} }
void DrawAction::Render(){ void DrawAction::Render(){
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
mFont->SetBase(0); mFont->SetBase(0);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
char buffer[200]; char buffer[200];
@@ -789,7 +789,7 @@ void ActionStack::Render(){
if (current->state==NOT_RESOLVED) height += current->mHeight; if (current->state==NOT_RESOLVED) height += current->mHeight;
} }
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
mFont->SetBase(0); mFont->SetBase(0);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
mFont->SetColor(ARGB(255,255,255,255)); mFont->SetColor(ARGB(255,255,255,255));
@@ -845,7 +845,7 @@ void ActionStack::Render(){
if (current->display) height += current->mHeight; if (current->display) height += current->mHeight;
} }
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
mFont->SetColor(ARGB(255,255,255,255)); mFont->SetColor(ARGB(255,255,255,255));
+4 -4
View File
@@ -64,7 +64,7 @@ void CardGui::Update(float dt)
void CardGui::Render() void CardGui::Render()
{ {
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
GameObserver * game = GameObserver::GetInstance(); GameObserver * game = GameObserver::GetInstance();
@@ -215,7 +215,7 @@ void CardGui::alternateRender(MTGCard * card, const Pos& pos){
renderer->RenderQuad(q, x, pos.actY, pos.actT, scale, scale); renderer->RenderQuad(q, x, pos.actY, pos.actT, scale, scale);
} }
// Write the title // Write the title
WFont * font = resources.GetWFont("magic"); WFont * font = resources.GetWFont(Fonts::MAGIC_FONT);
float backup_scale = font->GetScale(); float backup_scale = font->GetScale();
font->SetColor(ARGB((int)pos.actA, 0, 0, 0)); font->SetColor(ARGB((int)pos.actA, 0, 0, 0));
font->SetScale(kWidthScaleFactor * pos.actZ); font->SetScale(kWidthScaleFactor * pos.actZ);
@@ -418,7 +418,7 @@ void CardGui::tinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad) {
renderer->RenderQuad(quad, x, imgY , pos.actT, imgScale, imgScale); renderer->RenderQuad(quad, x, imgY , pos.actT, imgScale, imgScale);
// Write the title // Write the title
WFont * font = resources.GetWFont("magic"); WFont * font = resources.GetWFont(Fonts::MAGIC_FONT);
float backup_scale = font->GetScale(); float backup_scale = font->GetScale();
font->SetColor(ARGB((int)pos.actA, 0, 0, 0)); font->SetColor(ARGB((int)pos.actA, 0, 0, 0));
font->SetScale(kWidthScaleFactor * pos.actZ); font->SetScale(kWidthScaleFactor * pos.actZ);
@@ -612,7 +612,7 @@ void CardGui::RenderBig(MTGCard* card, const Pos& pos){
void CardGui::renderCountersBig(const Pos& pos){ void CardGui::renderCountersBig(const Pos& pos){
// Write Named Counters // Write Named Counters
if (card->counters) { if (card->counters) {
WFont * font = resources.GetWFont("magic"); WFont * font = resources.GetWFont(Fonts::MAGIC_FONT);
font->SetColor(ARGB((int)pos.actA, 0, 0, 0)); font->SetColor(ARGB((int)pos.actA, 0, 0, 0));
font->SetScale(kWidthScaleFactor * pos.actZ); font->SetScale(kWidthScaleFactor * pos.actZ);
std::vector<string> txt = card->formattedText(); std::vector<string> txt = card->formattedText();
+3 -3
View File
@@ -173,9 +173,9 @@ void Credits::Render(){
if (!p1) return; if (!p1) return;
GameObserver * g = GameObserver::GetInstance(); GameObserver * g = GameObserver::GetInstance();
JRenderer * r = JRenderer::GetInstance(); JRenderer * r = JRenderer::GetInstance();
WFont * f = resources.GetWFont(Constants::MAIN_FONT); WFont * f = resources.GetWFont(Fonts::MAIN_FONT);
WFont * f2 = resources.GetWFont(Constants::MENU_FONT); WFont * f2 = resources.GetWFont(Fonts::MENU_FONT);
WFont * f3 = resources.GetWFont(Constants::MAGIC_FONT); WFont * f3 = resources.GetWFont(Fonts::MAGIC_FONT);
f->SetScale(1); f->SetScale(1);
f->SetColor(ARGB(255,255,255,255)); f->SetColor(ARGB(255,255,255,255));
f2->SetScale(1); f2->SetScale(1);
+1 -1
View File
@@ -139,7 +139,7 @@ int Damage::resolve(){
return a; return a;
} }
void Damage::Render(){ void Damage::Render(){
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
mFont->SetBase(0); mFont->SetBase(0);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
char buffer[200]; char buffer[200];
+1 -1
View File
@@ -51,7 +51,7 @@ void DamagerDamaged::clearDamage()
void DamagerDamaged::Render(CombatStep mode) void DamagerDamaged::Render(CombatStep mode)
{ {
TransientCardView::Render(); TransientCardView::Render();
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
mFont->SetBase(0); mFont->SetBase(0);
switch (mode) switch (mode)
+1 -1
View File
@@ -36,7 +36,7 @@ int ExtraCost::setSource(MTGCardInstance * _source){
void ExtraCost::Render(){ void ExtraCost::Render(){
if (!mCostRenderString.empty()) if (!mCostRenderString.empty())
{ {
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
mFont->SetColor(ARGB(255,255,255,255)); mFont->SetColor(ARGB(255,255,255,255));
mFont->DrawString(mCostRenderString, 20 ,20, JGETEXT_LEFT); mFont->DrawString(mCostRenderString, 20 ,20, JGETEXT_LEFT);
+2 -13
View File
@@ -149,18 +149,7 @@ void GameApp::Create()
LOG("--Loading fonts"); LOG("--Loading fonts");
string lang = options[Options::LANG].str; string lang = options[Options::LANG].str;
std::transform(lang.begin(), lang.end(), lang.begin(), ::tolower); std::transform(lang.begin(), lang.end(), lang.begin(), ::tolower);
if (lang.compare("cn") == 0) { resources.InitFonts(lang);
resources.LoadWFBFont("simon",12);
resources.LoadWFBFont("f3",16);
resources.LoadWFBFont("magic",16);
resources.LoadWFBFont("smallface",12);
}
resources.LoadWLBFont("simon",11);
resources.GetWFont("simon")->SetTracking(-1);
resources.LoadWLBFont("f3",16);
resources.LoadWLBFont("magic",16);
resources.LoadWLBFont("smallface", 7);
LOG("--Loading various textures"); LOG("--Loading various textures");
resources.RetrieveTexture("phasebar.png",RETRIEVE_MANAGE); resources.RetrieveTexture("phasebar.png",RETRIEVE_MANAGE);
@@ -334,7 +323,7 @@ void GameApp::Render()
{ {
if (systemError.size()){ if (systemError.size()){
fprintf(stderr, "%s", systemError.c_str()); fprintf(stderr, "%s", systemError.c_str());
WFont * mFont= resources.GetWFont("simon"); WFont * mFont= resources.GetWFont(Fonts::MAIN_FONT);
if (mFont) mFont->DrawString(systemError.c_str(),1,1); if (mFont) mFont->DrawString(systemError.c_str(),1,1);
return; return;
} }
+1 -1
View File
@@ -161,7 +161,7 @@ void GameStateAwards::Update(float dt)
case JGE_BTN_MENU: case JGE_BTN_MENU:
showMenu = true; showMenu = true;
SAFE_DELETE(menu); SAFE_DELETE(menu);
menu = NEW SimpleMenu(-102, this,Constants::MENU_FONT, 50,170); menu = NEW SimpleMenu(-102, this,Fonts::MENU_FONT, 50,170);
if(mState == STATE_DETAILS) if(mState == STATE_DETAILS)
menu->Add(2, "Back to Trophies"); menu->Add(2, "Back to Trophies");
menu->Add(1, "Back to Main Menu"); menu->Add(1, "Back to Main Menu");
+8 -8
View File
@@ -132,7 +132,7 @@ void GameStateDeckViewer::switchDisplay(){
void GameStateDeckViewer::updateDecks(){ void GameStateDeckViewer::updateDecks(){
SAFE_DELETE(welcome_menu); SAFE_DELETE(welcome_menu);
welcome_menu = NEW SimpleMenu( MENU_DECK_SELECTION, this, Constants::MENU_FONT,20,20); welcome_menu = NEW SimpleMenu( MENU_DECK_SELECTION, this, Fonts::MENU_FONT,20,20);
DeckManager * deckManager = DeckManager::GetInstance(); DeckManager * deckManager = DeckManager::GetInstance();
vector<DeckMetaData *> playerDeckList = fillDeckMenu( welcome_menu,options.profileFile()); vector<DeckMetaData *> playerDeckList = fillDeckMenu( welcome_menu,options.profileFile());
@@ -172,7 +172,7 @@ void GameStateDeckViewer::Start()
myCollection->Sort(WSrcCards::SORT_ALPHA); myCollection->Sort(WSrcCards::SORT_ALPHA);
displayed_deck = myCollection; displayed_deck = myCollection;
//Build menu. //Build menu.
menu = NEW SimpleMenu( MENU_DECK_BUILDER, this, Constants::MENU_FONT,SCREEN_WIDTH/2-150,20); menu = NEW SimpleMenu( MENU_DECK_BUILDER, this, Fonts::MENU_FONT,SCREEN_WIDTH/2-150,20);
menu->Add( MENU_ITEM_FILTER_BY, "Filter by..."); menu->Add( MENU_ITEM_FILTER_BY, "Filter by...");
menu->Add( MENU_ITEM_SWITCH_DECKS_NO_SAVE, "Switch decks without saving"); menu->Add( MENU_ITEM_SWITCH_DECKS_NO_SAVE, "Switch decks without saving");
menu->Add( MENU_ITEM_SAVE_RENAME, "Save & Rename"); menu->Add( MENU_ITEM_SAVE_RENAME, "Save & Rename");
@@ -340,7 +340,7 @@ void GameStateDeckViewer::Update(float dt)
if (card && displayed_deck->count(card)){ if (card && displayed_deck->count(card)){
price = pricelist->getSellPrice(card->getMTGId()); price = pricelist->getSellPrice(card->getMTGId());
sprintf(buffer,"%s : %i %s",_(card->data->getName()).c_str(),price,_("credits").c_str()); sprintf(buffer,"%s : %i %s",_(card->data->getName()).c_str(),price,_("credits").c_str());
subMenu = NEW SimpleMenu( MENU_CARD_PURCHASE, this, Constants::MAIN_FONT,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,buffer); subMenu = NEW SimpleMenu( MENU_CARD_PURCHASE, this, Fonts::MAIN_FONT,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,buffer);
subMenu->Add( MENU_ITEM_YES,"Yes"); subMenu->Add( MENU_ITEM_YES,"Yes");
subMenu->Add( MENU_ITEM_NO,"No","",true); subMenu->Add( MENU_ITEM_NO,"No","",true);
} }
@@ -466,7 +466,7 @@ void GameStateDeckViewer::Update(float dt)
void GameStateDeckViewer::renderOnScreenBasicInfo(){ void GameStateDeckViewer::renderOnScreenBasicInfo(){
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
char buffer[256]; char buffer[256];
int myD = (displayed_deck == myDeck); int myD = (displayed_deck == myDeck);
@@ -500,7 +500,7 @@ int GameStateDeckViewer::getCurrentPos() {
} }
void GameStateDeckViewer::renderSlideBar(){ void GameStateDeckViewer::renderSlideBar(){
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
int total = displayed_deck->Size(); int total = displayed_deck->Size();
if(total == 0) if(total == 0)
@@ -568,7 +568,7 @@ void GameStateDeckViewer::renderDeckBackground(){
void GameStateDeckViewer::renderOnScreenMenu(){ void GameStateDeckViewer::renderOnScreenMenu(){
WFont * font = resources.GetWFont(Constants::MAIN_FONT); WFont * font = resources.GetWFont(Fonts::MAIN_FONT);
font->SetColor(ARGB(255,255,255,255)); font->SetColor(ARGB(255,255,255,255));
JRenderer * r = JRenderer::GetInstance(); JRenderer * r = JRenderer::GetInstance();
float pspIconsSize = 0.5; float pspIconsSize = 0.5;
@@ -1229,7 +1229,7 @@ int GameStateDeckViewer::countCardsByType(const char * _type) {
} }
void GameStateDeckViewer::renderCard(int id, float rotation){ void GameStateDeckViewer::renderCard(int id, float rotation){
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
MTGCard * card = cardIndex[id]; MTGCard * card = cardIndex[id];
float max_scale = 0.96f; float max_scale = 0.96f;
@@ -1310,7 +1310,7 @@ void GameStateDeckViewer::renderCard (int id){
void GameStateDeckViewer::Render() { void GameStateDeckViewer::Render() {
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
JRenderer * r = JRenderer::GetInstance(); JRenderer * r = JRenderer::GetInstance();
r->ClearScreen(ARGB(0,0,0,0)); r->ClearScreen(ARGB(0,0,0,0));
+4 -4
View File
@@ -91,7 +91,7 @@ void GameStateDuel::Start()
for (int i = 0; i<2; i ++){ for (int i = 0; i<2; i ++){
if (mParent->players[i] == PLAYER_TYPE_HUMAN){ if (mParent->players[i] == PLAYER_TYPE_HUMAN){
decksneeded = 1; decksneeded = 1;
deckmenu = NEW SimpleMenu(DUEL_MENU_CHOOSE_DECK, this, Constants::MENU_FONT, 35, 25, "Choose a Deck"); deckmenu = NEW SimpleMenu(DUEL_MENU_CHOOSE_DECK, this, Fonts::MENU_FONT, 35, 25, "Choose a Deck");
DeckManager *deckManager = DeckManager::GetInstance(); DeckManager *deckManager = DeckManager::GetInstance();
vector<DeckMetaData *> playerDeckList = getValidDeckMetaData( options.profileFile() ); vector<DeckMetaData *> playerDeckList = getValidDeckMetaData( options.profileFile() );
@@ -236,7 +236,7 @@ bool GameStateDuel::MusicExist(string FileName){
void GameStateDuel::ensureOpponentMenu(){ void GameStateDuel::ensureOpponentMenu(){
if (!opponentMenu){ if (!opponentMenu){
opponentMenu = NEW SimpleMenu(DUEL_MENU_CHOOSE_OPPONENT, this, Constants::MENU_FONT, 35, 25, "Choose Opponent"); opponentMenu = NEW SimpleMenu(DUEL_MENU_CHOOSE_OPPONENT, this, Fonts::MENU_FONT, 35, 25, "Choose Opponent");
opponentMenu->Add( MENUITEM_RANDOM_AI, "Random"); opponentMenu->Add( MENUITEM_RANDOM_AI, "Random");
if (options[Options::EVILTWIN_MODE_UNLOCKED].number) if (options[Options::EVILTWIN_MODE_UNLOCKED].number)
opponentMenu->Add( MENUITEM_EVIL_TWIN, "Evil Twin", _("Can you play against yourself?").c_str()); opponentMenu->Add( MENUITEM_EVIL_TWIN, "Evil Twin", _("Can you play against yourself?").c_str());
@@ -375,7 +375,7 @@ void GameStateDuel::Update(float dt)
} }
if (mEngine->GetButtonClick(JGE_BTN_MENU)) { if (mEngine->GetButtonClick(JGE_BTN_MENU)) {
if (!menu) { if (!menu) {
menu = NEW SimpleMenu(DUEL_MENU_GAME_MENU, this, Constants::MENU_FONT, SCREEN_WIDTH/2-100, 25, game->players[1]->deckName.c_str()); menu = NEW SimpleMenu(DUEL_MENU_GAME_MENU, this, Fonts::MENU_FONT, SCREEN_WIDTH/2-100, 25, game->players[1]->deckName.c_str());
int cardsinhand = game->players[0]->game->hand->nb_cards; int cardsinhand = game->players[0]->game->hand->nb_cards;
//almosthumane - mulligan //almosthumane - mulligan
@@ -428,7 +428,7 @@ void GameStateDuel::Update(float dt)
void GameStateDuel::Render() void GameStateDuel::Render()
{ {
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
JRenderer * r = JRenderer::GetInstance(); JRenderer * r = JRenderer::GetInstance();
r->ClearScreen(ARGB(0,0,0,0)); r->ClearScreen(ARGB(0,0,0,0));
+11 -11
View File
@@ -117,7 +117,7 @@ void GameStateMenu::Create()
if (!langChosen){ if (!langChosen){
currentState = MENU_STATE_MAJOR_LANG | MENU_STATE_MINOR_NONE; currentState = MENU_STATE_MAJOR_LANG | MENU_STATE_MINOR_NONE;
} }
scroller = NEW TextScroller(Constants::MAIN_FONT, SCREEN_WIDTH/2 - 90 , SCREEN_HEIGHT-17,180); scroller = NEW TextScroller(Fonts::MAIN_FONT, SCREEN_WIDTH/2 - 90 , SCREEN_HEIGHT-17,180);
scrollerSet = 0; scrollerSet = 0;
splashTex = NULL; splashTex = NULL;
@@ -317,7 +317,7 @@ void GameStateMenu::setLang(int id){
void GameStateMenu::loadLangMenu(){ void GameStateMenu::loadLangMenu(){
LOG("GameStateMenu::loadLangMenu"); LOG("GameStateMenu::loadLangMenu");
subMenuController = NEW SimpleMenu( MENU_LANGUAGE_SELECTION, this, Constants::MENU_FONT, 150,60); subMenuController = NEW SimpleMenu( MENU_LANGUAGE_SELECTION, this, Fonts::MENU_FONT, 150,60);
if (!subMenuController) return; if (!subMenuController) return;
resetDirectory(); resetDirectory();
if (!mDip){ if (!mDip){
@@ -371,7 +371,7 @@ void GameStateMenu::ensureMGuiController(){
if (!mGuiController) { if (!mGuiController) {
mGuiController = NEW JGuiController(100, this); mGuiController = NEW JGuiController(100, this);
if (mGuiController) { if (mGuiController) {
WFont * mFont = resources.GetWFont(Constants::MENU_FONT); WFont * mFont = resources.GetWFont(Fonts::MENU_FONT);
mFont->SetColor(ARGB(255,255,255,255)); mFont->SetColor(ARGB(255,255,255,255));
mGuiController->Add(NEW MenuItem(MENUITEM_PLAY, mFont, "Play", 80, 50 + SCREEN_HEIGHT/2, mIcons[8], mIcons[9],"particle1.psi",resources.GetQuad("particles"), true)); mGuiController->Add(NEW MenuItem(MENUITEM_PLAY, mFont, "Play", 80, 50 + SCREEN_HEIGHT/2, mIcons[8], mIcons[9],"particle1.psi",resources.GetQuad("particles"), true));
mGuiController->Add(NEW MenuItem(MENUITEM_DECKEDITOR, mFont, "Deck Editor", 160, 50 + SCREEN_HEIGHT/2, mIcons[2], mIcons[3],"particle2.psi",resources.GetQuad("particles"))); mGuiController->Add(NEW MenuItem(MENUITEM_DECKEDITOR, mFont, "Deck Editor", 160, 50 + SCREEN_HEIGHT/2, mIcons[2], mIcons[3],"particle2.psi",resources.GetQuad("particles")));
@@ -469,7 +469,7 @@ void GameStateMenu::Update(float dt)
if (MENU_STATE_MINOR_NONE == (currentState & MENU_STATE_MINOR)) { if (MENU_STATE_MINOR_NONE == (currentState & MENU_STATE_MINOR)) {
if (!hasChosenGameType){ if (!hasChosenGameType){
currentState = MENU_STATE_MAJOR_SUBMENU; currentState = MENU_STATE_MAJOR_SUBMENU;
subMenuController = NEW SimpleMenu( MENU_FIRST_DUEL_SUBMENU, this, Constants::MENU_FONT, 150,60); subMenuController = NEW SimpleMenu( MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150,60);
if (subMenuController){ if (subMenuController){
subMenuController->Add(SUBMENUITEM_CLASSIC,"Classic"); subMenuController->Add(SUBMENUITEM_CLASSIC,"Classic");
if (options[Options::MOMIR_MODE_UNLOCKED].number) if (options[Options::MOMIR_MODE_UNLOCKED].number)
@@ -547,7 +547,7 @@ void GameStateMenu::Render()
return; return;
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
WFont * mFont = resources.GetWFont(Constants::MENU_FONT); WFont * mFont = resources.GetWFont(Fonts::MENU_FONT);
if ((currentState & MENU_STATE_MAJOR) == MENU_STATE_MAJOR_LANG){ if ((currentState & MENU_STATE_MAJOR) == MENU_STATE_MAJOR_LANG){
}else if ((currentState & MENU_STATE_MAJOR) == MENU_STATE_MAJOR_LOADING_CARDS){ }else if ((currentState & MENU_STATE_MAJOR) == MENU_STATE_MAJOR_LOADING_CARDS){
if(!splashTex){ if(!splashTex){
@@ -580,7 +580,7 @@ void GameStateMenu::Render()
mFont->SetColor(ARGB(255,255,255,255)); mFont->SetColor(ARGB(255,255,255,255));
mFont->DrawString(text,SCREEN_WIDTH/2,SCREEN_HEIGHT - 50,JGETEXT_CENTER); mFont->DrawString(text,SCREEN_WIDTH/2,SCREEN_HEIGHT - 50,JGETEXT_CENTER);
}else{ }else{
mFont = resources.GetWFont(Constants::MAIN_FONT); mFont = resources.GetWFont(Fonts::MAIN_FONT);
PIXEL_TYPE colors[] = PIXEL_TYPE colors[] =
{ {
@@ -614,7 +614,7 @@ void GameStateMenu::Render()
if(options.newAward()) if(options.newAward())
alp = (int)(sin(timeIndex) * 255); alp = (int)(sin(timeIndex) * 255);
float olds = mFont->GetScale(); float olds = mFont->GetScale();
mFont = resources.GetWFont(Constants::OPTION_FONT); mFont = resources.GetWFont(Fonts::OPTION_FONT);
jq->SetColor(ARGB(abs(alp),255,255,255)); jq->SetColor(ARGB(abs(alp),255,255,255));
mFont->SetColor(ARGB(abs(alp),0,0,0)); mFont->SetColor(ARGB(abs(alp),0,0,0));
string s = _("Trophy Room");; string s = _("Trophy Room");;
@@ -622,7 +622,7 @@ void GameStateMenu::Render()
mFont->SetScale(50.0f/mFont->GetStringWidth(s.c_str())); mFont->SetScale(50.0f/mFont->GetStringWidth(s.c_str()));
renderer->RenderQuad(jq, SCREEN_WIDTH-64, 2); renderer->RenderQuad(jq, SCREEN_WIDTH-64, 2);
mFont->DrawString(s,SCREEN_WIDTH-10,9,JGETEXT_RIGHT); mFont->DrawString(s,SCREEN_WIDTH-10,9,JGETEXT_RIGHT);
mFont = resources.GetWFont(Constants::MENU_FONT); mFont = resources.GetWFont(Fonts::MENU_FONT);
mFont->SetScale(olds); mFont->SetScale(olds);
} }
} }
@@ -634,13 +634,13 @@ void GameStateMenu::Render()
void GameStateMenu::ButtonPressed(int controllerId, int controlId) void GameStateMenu::ButtonPressed(int controllerId, int controlId)
{ {
WFont * mFont = resources.GetWFont(Constants::MENU_FONT); WFont * mFont = resources.GetWFont(Fonts::MENU_FONT);
DebugTrace("GameStateMenu: controllerId " << controllerId << " selected"); DebugTrace("GameStateMenu: controllerId " << controllerId << " selected");
switch (controllerId){ switch (controllerId){
case MENU_LANGUAGE_SELECTION: case MENU_LANGUAGE_SELECTION:
setLang(controlId); setLang(controlId);
resources.reloadWFonts(); // Fix for choosing Chinese language at first time. resources.ReloadWFonts(); // Fix for choosing Chinese language at first time.
subMenuController->Close(); subMenuController->Close();
currentState = MENU_STATE_MAJOR_LOADING_CARDS | MENU_STATE_MINOR_SUBMENU_CLOSING; currentState = MENU_STATE_MAJOR_LOADING_CARDS | MENU_STATE_MINOR_SUBMENU_CLOSING;
break; break;
@@ -652,7 +652,7 @@ void GameStateMenu::ButtonPressed(int controllerId, int controlId)
switch (controlId) switch (controlId)
{ {
case MENUITEM_PLAY: case MENUITEM_PLAY:
subMenuController = NEW SimpleMenu( MENU_FIRST_DUEL_SUBMENU, this, Constants::MENU_FONT, 150,60); subMenuController = NEW SimpleMenu( MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150,60);
if (subMenuController){ if (subMenuController){
subMenuController->Add(SUBMENUITEM_1PLAYER,"1 Player"); subMenuController->Add(SUBMENUITEM_1PLAYER,"1 Player");
// TODO Put 2 players mode back // TODO Put 2 players mode back
+2 -2
View File
@@ -87,7 +87,7 @@ void GameStateOptions::Start()
optionsList->failMsg = ""; optionsList->failMsg = "";
optionsTabs->Add(optionsList); optionsTabs->Add(optionsList);
optionsMenu = NEW SimpleMenu(-102, this,Constants::MENU_FONT, 50,170); optionsMenu = NEW SimpleMenu(-102, this,Fonts::MENU_FONT, 50,170);
optionsMenu->Add(2, "Back to Main Menu"); optionsMenu->Add(2, "Back to Main Menu");
optionsMenu->Add(1, "Save & Back to Main Menu"); optionsMenu->Add(1, "Save & Back to Main Menu");
optionsMenu->Add(3, "Cancel"); optionsMenu->Add(3, "Cancel");
@@ -212,7 +212,7 @@ void GameStateOptions::Render()
"Please support this project with donations at http://wololo.net/wagic", "Please support this project with donations at http://wololo.net/wagic",
}; };
WFont * mFont = resources.GetWFont(Constants::MAGIC_FONT); WFont * mFont = resources.GetWFont(Fonts::MAGIC_FONT);
mFont->SetColor(ARGB(255,200,200,200)); mFont->SetColor(ARGB(255,200,200,200));
mFont->SetScale(1.0); mFont->SetScale(1.0);
float startpos = 272 - timer; float startpos = 272 - timer;
+7 -7
View File
@@ -166,15 +166,15 @@ string GameStateShop::descPurchase(int controlId, bool tiny){
return buffer; return buffer;
} }
void GameStateShop::beginPurchase(int controlId){ void GameStateShop::beginPurchase(int controlId){
WFont * mFont = resources.GetWFont(Constants::MENU_FONT); WFont * mFont = resources.GetWFont(Fonts::MENU_FONT);
mFont->SetScale(DEFAULT_MENU_FONT_SCALE); mFont->SetScale(DEFAULT_MENU_FONT_SCALE);
SAFE_DELETE(menu); SAFE_DELETE(menu);
if(mInventory[controlId] <= 0){ if(mInventory[controlId] <= 0){
menu = NEW SimpleMenu(-145,this,Constants::MENU_FONT,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,_("Sold Out").c_str()); menu = NEW SimpleMenu(-145,this,Fonts::MENU_FONT,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,_("Sold Out").c_str());
menu->Add(-1,"Ok"); menu->Add(-1,"Ok");
} }
else if(playerdata->credits - mPrices[controlId] < 0){ else if(playerdata->credits - mPrices[controlId] < 0){
menu = NEW SimpleMenu(-145,this,Constants::MENU_FONT,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,_("Not enough credits").c_str()); menu = NEW SimpleMenu(-145,this,Fonts::MENU_FONT,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,_("Not enough credits").c_str());
menu->Add(-1,"Ok"); menu->Add(-1,"Ok");
if(options[Options::CHEATMODE].number) { if(options[Options::CHEATMODE].number) {
menu->Add(-2,"Steal it"); menu->Add(-2,"Steal it");
@@ -186,7 +186,7 @@ void GameStateShop::beginPurchase(int controlId){
sprintf(buf,_("Purchase Booster: %i credits").c_str(),mPrices[controlId]); sprintf(buf,_("Purchase Booster: %i credits").c_str(),mPrices[controlId]);
else else
sprintf(buf,_("Purchase Card: %i credits").c_str(),mPrices[controlId]); sprintf(buf,_("Purchase Card: %i credits").c_str(),mPrices[controlId]);
menu = NEW SimpleMenu(-145,this,Constants::MENU_FONT,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,buf); menu = NEW SimpleMenu(-145,this,Fonts::MENU_FONT,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,buf);
menu->Add(controlId,"Yes"); menu->Add(controlId,"Yes");
menu->Add(-1,"No"); menu->Add(-1,"No");
@@ -410,7 +410,7 @@ void GameStateShop::Update(float dt)
if (menu) if (menu)
menu->Update(dt); menu->Update(dt);
else{ else{
menu = NEW SimpleMenu(11,this,Constants::MENU_FONT,SCREEN_WIDTH/2-100,20); menu = NEW SimpleMenu(11,this,Fonts::MENU_FONT,SCREEN_WIDTH/2-100,20);
menu->Add(22,"Ask about..."); menu->Add(22,"Ask about...");
menu->Add(14,"Check task board"); menu->Add(14,"Check task board");
if (options[Options::CHEATMODE].number) if (options[Options::CHEATMODE].number)
@@ -433,7 +433,7 @@ void GameStateShop::Update(float dt)
return; return;
} else if (taskList->getState() == TaskList::TASKS_ACTIVE && btn == JGE_BTN_MENU){ } else if (taskList->getState() == TaskList::TASKS_ACTIVE && btn == JGE_BTN_MENU){
if (!menu) { if (!menu) {
menu = NEW SimpleMenu(11,this,Constants::MENU_FONT,SCREEN_WIDTH/2-100,20); menu = NEW SimpleMenu(11,this,Fonts::MENU_FONT,SCREEN_WIDTH/2-100,20);
menu->Add(15,"Return to shop"); menu->Add(15,"Return to shop");
menu->Add(12,"Save & Back to Main Menu"); menu->Add(12,"Save & Back to Main Menu");
menu->Add(13, "Cancel"); menu->Add(13, "Cancel");
@@ -550,7 +550,7 @@ void GameStateShop::deleteDisplay(){
void GameStateShop::Render() void GameStateShop::Render()
{ {
//Erase //Erase
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
JRenderer * r = JRenderer::GetInstance(); JRenderer * r = JRenderer::GetInstance();
r->ClearScreen(ARGB(0,0,0,0)); r->ClearScreen(ARGB(0,0,0,0));
if(mStage == STAGE_FADE_IN) if(mStage == STAGE_FADE_IN)
+2 -2
View File
@@ -44,7 +44,7 @@ void GameStateStory::loadStoriesMenu(const char * root){
flow = NEW StoryFlow(stories[0]); flow = NEW StoryFlow(stories[0]);
break; break;
default: default:
menu = NEW SimpleMenu(103, this, Constants::MENU_FONT, 150,60); menu = NEW SimpleMenu(103, this, Fonts::MENU_FONT, 150,60);
for (size_t i = 0; i < stories.size(); ++i){ for (size_t i = 0; i < stories.size(); ++i){
menu->Add(i, stories[i].c_str()); menu->Add(i, stories[i].c_str());
} }
@@ -60,7 +60,7 @@ void GameStateStory::Start() {
void GameStateStory::Update(float dt) { void GameStateStory::Update(float dt) {
if (!menu && mEngine->GetButtonClick(JGE_BTN_MENU)){ if (!menu && mEngine->GetButtonClick(JGE_BTN_MENU)){
menu = NEW SimpleMenu(100, this, Constants::MENU_FONT, SCREEN_WIDTH/2-100, 25); menu = NEW SimpleMenu(100, this, Fonts::MENU_FONT, SCREEN_WIDTH/2-100, 25);
menu->Add(0,"Back to main menu"); menu->Add(0,"Back to main menu");
menu->Add(-1, "Cancel"); menu->Add(-1, "Cancel");
} }
+2 -2
View File
@@ -294,7 +294,7 @@ void GuiCombat::Render()
{ {
go->opponent()->mAvatar->SetHotSpot(18, 25); go->opponent()->mAvatar->SetHotSpot(18, 25);
enemy_avatar.Render(go->opponent()->mAvatar); enemy_avatar.Render(go->opponent()->mAvatar);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
mFont->SetColor(ARGB(255, 255, 64, 0)); mFont->SetColor(ARGB(255, 255, 64, 0));
{ {
char buf[10]; sprintf(buf, "%i", damage); char buf[10]; sprintf(buf, "%i", damage);
@@ -310,7 +310,7 @@ void GuiCombat::Render()
renderer->DrawLine(0, SCREEN_HEIGHT / 2 + 10, SCREEN_WIDTH, SCREEN_HEIGHT / 2 + 10, ARGB(255, 255, 64, 0)); renderer->DrawLine(0, SCREEN_HEIGHT / 2 + 10, SCREEN_WIDTH, SCREEN_HEIGHT / 2 + 10, ARGB(255, 255, 64, 0));
if (FIRST_STRIKE == step) if (FIRST_STRIKE == step)
{ {
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
mFont->SetColor(ARGB(255, 64, 255, 64)); mFont->SetColor(ARGB(255, 64, 255, 64));
mFont->DrawString("First strike damage", 370, 2); mFont->DrawString("First strike damage", 370, 2);
} }
+1 -1
View File
@@ -171,7 +171,7 @@ void GuiHandSelf::Render()
{ {
//Empty hand //Empty hand
if (state == Open && cards.size() == 0){ if (state == Open && cards.size() == 0){
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
mFont->SetColor(ARGB(255,255,0,0)); mFont->SetColor(ARGB(255,255,0,0));
if (OptionHandDirection::HORIZONTAL == options[Options::HANDDIRECTION].number){ if (OptionHandDirection::HORIZONTAL == options[Options::HANDDIRECTION].number){
back->SetColor(ARGB(255,255,0,0)); back->SetColor(ARGB(255,255,0,0));
+1 -1
View File
@@ -213,7 +213,7 @@ GuiMana::~GuiMana(){
void GuiMana::RenderStatic(){ void GuiMana::RenderStatic(){
int values[Constants::MTG_NB_COLORS]; int values[Constants::MTG_NB_COLORS];
int totalColors = 0; int totalColors = 0;
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
JRenderer * r = JRenderer::GetInstance(); JRenderer * r = JRenderer::GetInstance();
for (int i = 0; i < Constants::MTG_NB_COLORS; ++i) for (int i = 0; i < Constants::MTG_NB_COLORS; ++i)
values[i] = 0; values[i] = 0;
+1 -1
View File
@@ -90,7 +90,7 @@ void GuiPhaseBar::Render()
} }
//print phase name //print phase name
WFont * font = resources.GetWFont(Constants::MAIN_FONT); WFont * font = resources.GetWFont(Fonts::MAIN_FONT);
string currentP = _("your turn"); string currentP = _("your turn");
string interrupt = ""; string interrupt = "";
if (g->currentPlayer == g->players[1]){ if (g->currentPlayer == g->players[1]){
+2 -2
View File
@@ -23,7 +23,7 @@ void GuiAvatar::Render()
JRenderer * r = JRenderer::GetInstance(); JRenderer * r = JRenderer::GetInstance();
int life = player->life; int life = player->life;
int poisonCount = player->poisonCount; int poisonCount = player->poisonCount;
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
//Avatar //Avatar
int lifeDiff = life - currentLife; int lifeDiff = life - currentLife;
@@ -152,7 +152,7 @@ void GuiGameZone::Render(){
JRenderer::GetInstance()->FillRect(actX,actY,quad->mWidth * scale * actZ,quad->mHeight *scale * actZ, ARGB(abs(128 - wave),255,255,255)); JRenderer::GetInstance()->FillRect(actX,actY,quad->mWidth * scale * actZ,quad->mHeight *scale * actZ, ARGB(abs(128 - wave),255,255,255));
//Number of cards //Number of cards
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT); WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
char buffer[11]; char buffer[11];
int mAlpha = (int)(actA); int mAlpha = (int)(actA);
+1 -1
View File
@@ -5,7 +5,7 @@
MTGGamePhase::MTGGamePhase(int id):ActionElement(id){ MTGGamePhase::MTGGamePhase(int id):ActionElement(id){
animation = 0; animation = 0;
currentState = -1; currentState = -1;
mFont= resources.GetWFont("simon"); mFont= resources.GetWFont(Fonts::MAIN_FONT);
mFont->SetBase(0); // using 2nd font mFont->SetBase(0); // using 2nd font
} }
+2 -2
View File
@@ -1034,7 +1034,7 @@ void MTGMomirRule::Update(float dt){
void MTGMomirRule::Render(){ void MTGMomirRule::Render(){
if (!textAlpha) return; if (!textAlpha) return;
WFont * mFont = resources.GetWFont(Constants::MENU_FONT); WFont * mFont = resources.GetWFont(Fonts::MENU_FONT);
mFont->SetScale(2 - (float)textAlpha/130); mFont->SetScale(2 - (float)textAlpha/130);
mFont->SetColor(ARGB(textAlpha,255,255,255)); mFont->SetColor(ARGB(textAlpha,255,255,255));
mFont->DrawString(text.c_str(),SCREEN_WIDTH/2,SCREEN_HEIGHT/2,JGETEXT_CENTER); mFont->DrawString(text.c_str(),SCREEN_WIDTH/2,SCREEN_HEIGHT/2,JGETEXT_CENTER);
@@ -1130,7 +1130,7 @@ void HUDDisplay::Render(){
HUDDisplay::HUDDisplay(int _id):MTGAbility(_id, NULL){ HUDDisplay::HUDDisplay(int _id):MTGAbility(_id, NULL){
timestamp = 0; timestamp = 0;
popdelay = 2; popdelay = 2;
f = resources.GetWFont(Constants::MAIN_FONT); f = resources.GetWFont(Fonts::MAIN_FONT);
maxWidth = 0; maxWidth = 0;
} }
+7 -7
View File
@@ -18,7 +18,7 @@ OptionItem::OptionItem( int _id, string _displayValue): WGuiItem(_displayValue)
//OptionInteger //OptionInteger
void OptionInteger::Render(){ void OptionInteger::Render(){
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT); WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT);
mFont->SetColor(getColor(WGuiColor::TEXT)); mFont->SetColor(getColor(WGuiColor::TEXT));
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
@@ -68,7 +68,7 @@ void OptionSelect::Entering(JButton key){
} }
void OptionSelect::Render(){ void OptionSelect::Render(){
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT); WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT);
mFont->SetColor(getColor(WGuiColor::TEXT)); mFont->SetColor(getColor(WGuiColor::TEXT));
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
@@ -165,7 +165,7 @@ void OptionProfile::populate(){
void OptionProfile::Render(){ void OptionProfile::Render(){
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT); WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT);
mFont->SetScale(1); mFont->SetScale(1);
int spacing = 2+(int)mFont->GetHeight(); int spacing = 2+(int)mFont->GetHeight();
@@ -426,7 +426,7 @@ void OptionTheme::Render(){
renderer->RenderQuad(q,x, y,0,scale,scale); renderer->RenderQuad(q,x, y,0,scale,scale);
} }
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT); WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT);
mFont->SetColor(getColor(WGuiColor::TEXT_HEADER)); mFont->SetColor(getColor(WGuiColor::TEXT_HEADER));
mFont->DrawString(buf, x + 2, y + 2); mFont->DrawString(buf, x + 2, y + 2);
if(bChecked && author.size()){ if(bChecked && author.size()){
@@ -464,7 +464,7 @@ OptionKey::OptionKey(GameStateOptions* g, LocalKeySym from, JButton to) : WGuiIt
void OptionKey::Update(float dt) { if (btnMenu) btnMenu->Update(dt); } void OptionKey::Update(float dt) { if (btnMenu) btnMenu->Update(dt); }
void OptionKey::Render() { void OptionKey::Render() {
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT); WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT);
mFont->SetColor(getColor(WGuiColor::TEXT)); mFont->SetColor(getColor(WGuiColor::TEXT));
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
@@ -514,7 +514,7 @@ void OptionKey::KeyPressed(LocalKeySym key) {
g->UngrabKeyboard(this); g->UngrabKeyboard(this);
grabbed = false; grabbed = false;
btnMenu = NEW SimpleMenu(0, this, Constants::MENU_FONT, 80, 10); btnMenu = NEW SimpleMenu(0, this, Fonts::MENU_FONT, 80, 10);
for (int i = sizeof(btnList) / sizeof(btnList[0]) - 1; i >= 0; --i) { for (int i = sizeof(btnList) / sizeof(btnList[0]) - 1; i >= 0; --i) {
const KeyRep& rep = translateKey(btnList[i]); const KeyRep& rep = translateKey(btnList[i]);
btnMenu->Add(i, rep.first.c_str()); btnMenu->Add(i, rep.first.c_str());
@@ -524,7 +524,7 @@ bool OptionKey::isModal() { return grabbed || btnMenu; }
void OptionKey::Overlay() void OptionKey::Overlay()
{ {
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT); WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT);
mFont->SetColor(ARGB(255, 0, 0, 0)); mFont->SetColor(ARGB(255, 0, 0, 0));
if (grabbed) { if (grabbed) {
static const int x = 30, y = 45; static const int x = 30, y = 45;
+2 -2
View File
@@ -93,7 +93,7 @@ void SimpleMenu::drawVertPole(int x, int y, int height)
} }
void SimpleMenu::Render() { void SimpleMenu::Render() {
WFont * titleFont = resources.GetWFont("smallface"); WFont * titleFont = resources.GetWFont(Fonts::SMALLFACE_FONT);
WFont * mFont = resources.GetWFont(fontId); WFont * mFont = resources.GetWFont(fontId);
if (0 == mWidth) { if (0 == mWidth) {
float sY = mY + kVerticalMargin; float sY = mY + kVerticalMargin;
@@ -138,7 +138,7 @@ void SimpleMenu::Render() {
if (i > mCount-1) break; if (i > mCount-1) break;
if ((static_cast<SimpleMenuItem*>(mObjects[i]))->mY - kLineHeight * startId < mY + height - kLineHeight + 7) { if ((static_cast<SimpleMenuItem*>(mObjects[i]))->mY - kLineHeight * startId < mY + height - kLineHeight + 7) {
if (static_cast<SimpleMenuItem*>(mObjects[i])->hasFocus()){ if (static_cast<SimpleMenuItem*>(mObjects[i])->hasFocus()){
resources.GetWFont(Constants::MAIN_FONT)->DrawString(static_cast<SimpleMenuItem*>(mObjects[i])->desc.c_str(),mX+mWidth+10,mY+15); resources.GetWFont(Fonts::MAIN_FONT)->DrawString(static_cast<SimpleMenuItem*>(mObjects[i])->desc.c_str(),mX+mWidth+10,mY+15);
mFont->SetColor(ARGB(255,255,255,0)); mFont->SetColor(ARGB(255,255,255,0));
} else } else
mFont->SetColor(ARGB(150,255,255,255)); mFont->SetColor(ARGB(150,255,255,255));
+1 -1
View File
@@ -299,7 +299,7 @@ string SimplePad::Finish() {
void SimplePad::Render(){ void SimplePad::Render(){
//This could use some cleaning up to make margins more explicit //This could use some cleaning up to make margins more explicit
WFont * mFont = resources.GetWFont("f3"); WFont * mFont = resources.GetWFont(Fonts::MENU_FONT);
float offX = 0, offY = 0; float offX = 0, offY = 0;
float kH = mFont->GetHeight(); float kH = mFont->GetHeight();
+1 -1
View File
@@ -386,7 +386,7 @@ StoryDialog::StoryDialog(TiXmlElement* root, StoryFlow * mParent):StoryPage(mPar
graphics.push_back(NEW StoryText(text,x,y,align, font)); graphics.push_back(NEW StoryText(text,x,y,align, font));
} }
else if (strcmp(element->Value(), "title")==0) { else if (strcmp(element->Value(), "title")==0) {
graphics.push_back(NEW StoryText(text,x,y,"center", Constants::MENU_FONT)); graphics.push_back(NEW StoryText(text,x,y,"center", Fonts::MENU_FONT));
} }
else if (strcmp(element->Value(), "img")==0) { else if (strcmp(element->Value(), "img")==0) {
//special case to force center //special case to force center
+3 -3
View File
@@ -431,9 +431,9 @@ void TaskList::Update(float dt) {
void TaskList::Render() { void TaskList::Render() {
JRenderer * r = JRenderer::GetInstance(); JRenderer * r = JRenderer::GetInstance();
//Setup fonts. //Setup fonts.
WFont * f = resources.GetWFont(Constants::MAIN_FONT); WFont * f = resources.GetWFont(Fonts::MAIN_FONT);
WFont * f2 = resources.GetWFont(Constants::MAGIC_FONT); WFont * f2 = resources.GetWFont(Fonts::MAGIC_FONT);
WFont * f3 = resources.GetWFont(Constants::MENU_FONT); //OPTION_FONT WFont * f3 = resources.GetWFont(Fonts::MENU_FONT); //OPTION_FONT
f2->SetColor(ARGB(255, 205, 237, 240)); f2->SetColor(ARGB(255, 205, 237, 240));
f3->SetColor(ARGB(255, 219, 206, 151)); f3->SetColor(ARGB(255, 219, 206, 151));
+11 -8
View File
@@ -34,16 +34,16 @@ static PIXEL_TYPE gencolor(int id, PIXEL_TYPE color)
r0 = g0 = b0 = 255; r0 = g0 = b0 = 255;
switch (id) { switch (id) {
case 0: // simon 245, 228, 156 case Fonts::MAIN_FONT: // simon 245, 228, 156
r0 = 245; g0 = 228; b0 = 156; r0 = 245; g0 = 228; b0 = 156;
break; break;
case 1: // f3 255, 252, 175 case Fonts::MENU_FONT: // f3 255, 252, 175
r0 = 255; g0 = 252; b0 = 175; r0 = 255; g0 = 252; b0 = 175;
break; break;
case 2: // magic 219, 255, 151 case Fonts::MAGIC_FONT: // magic 219, 255, 151
r0 = 219; g0 = 255; b0 = 151; r0 = 219; g0 = 255; b0 = 151;
break; break;
case 3: // smallface 255, 255, 255 case Fonts::SMALLFACE_FONT: // smallface 255, 255, 255
r0 = 255; g0 = 255; b0 = 255; r0 = 255; g0 = 255; b0 = 255;
break; break;
default: default:
@@ -93,7 +93,8 @@ static int genmana(u8 c)
JRenderer * WFBFont::mRenderer = NULL; JRenderer * WFBFont::mRenderer = NULL;
WFBFont::WFBFont(const char *fontname, int lineheight, bool useVideoRAM) WFBFont::WFBFont(int inFontID, const char *fontname, int lineheight, bool useVideoRAM)
: WFont(inFontID)
{ {
mRenderer = JRenderer::GetInstance(); mRenderer = JRenderer::GetInstance();
@@ -312,7 +313,9 @@ void WFBFont::DrawString(const char *s, float x, float y, int align, float leftO
unsigned char c = *(unsigned short *)s & 0xFF; unsigned char c = *(unsigned short *)s & 0xFF;
if (ISGBK(c) || (s[1] == ':' && s[2] == ' ')) {} if (ISGBK(c) || (s[1] == ':' && s[2] == ' ')) {}
else { else {
WFont * mFont = resources.GetWLBFont(id); // tricky: the single byte font is always mFontID + kSingleByteFontOffset!
// See WResourceManager::InitFonts()
WFont * mFont = resources.GetWFont(mFontID + Fonts::kSingleByteFontOffset);
mFont->SetScale(GetScale()); mFont->SetScale(GetScale());
mFont->SetColor(GetColor()); mFont->SetColor(GetColor());
mFont->DrawString(s, x, y, align, leftOffset, width); mFont->DrawString(s, x, y, align, leftOffset, width);
@@ -472,7 +475,7 @@ void WFBFont::DrawString(std::string s, float x, float y, int align, float leftO
void WFBFont::SetColor(PIXEL_TYPE color) void WFBFont::SetColor(PIXEL_TYPE color)
{ {
mColor0 = color; mColor0 = color;
mColor = gencolor(id, color); mColor = gencolor(mFontID, color);
} }
float WFBFont::GetStringWidth(const char *s) const float WFBFont::GetStringWidth(const char *s) const
@@ -501,7 +504,7 @@ float WFBFont::GetStringWidth(const char *s) const
return xx; return xx;
} }
else { else {
WFont * mFont = resources.GetWLBFont(id); WFont * mFont = resources.GetWFont(mFontID + Fonts::kSingleByteFontOffset);
mFont->SetScale(GetScale()); mFont->SetScale(GetScale());
return mFont->GetStringWidth(s); return mFont->GetStringWidth(s);
} }
+16 -16
View File
@@ -65,11 +65,11 @@ void WGuiItem::Entering(JButton key){
mFocus = true; mFocus = true;
} }
float WGuiItem::minWidth(){ float WGuiItem::minWidth(){
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT); WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT);
return mFont->GetStringWidth(_(displayValue).c_str())+4; return mFont->GetStringWidth(_(displayValue).c_str())+4;
} }
float WGuiItem::minHeight(){ float WGuiItem::minHeight(){
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT); WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT);
return mFont->GetHeight(); return mFont->GetHeight();
} }
@@ -80,7 +80,7 @@ bool WGuiItem::Leaving(JButton key){
void WGuiItem::Render(){ void WGuiItem::Render(){
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT); WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT);
DWORD oldcolor = mFont->GetColor(); DWORD oldcolor = mFont->GetColor();
mFont->SetColor(getColor(WGuiColor::TEXT)); mFont->SetColor(getColor(WGuiColor::TEXT));
float fH = (height-mFont->GetHeight())/2; float fH = (height-mFont->GetHeight())/2;
@@ -162,7 +162,7 @@ PIXEL_TYPE WDecoStyled::getColor(int type){
//WGuiHeader //WGuiHeader
void WGuiHeader::Render(){ void WGuiHeader::Render(){
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT); WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT);
mFont->SetColor(getColor(WGuiColor::TEXT)); mFont->SetColor(getColor(WGuiColor::TEXT));
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
@@ -263,7 +263,7 @@ void WGuiList::Render(){
//List is empty. //List is empty.
if (!items.size() && failMsg != ""){ if (!items.size() && failMsg != ""){
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT); WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT);
mFont->SetColor(getColor(WGuiColor::TEXT_FAIL)); mFont->SetColor(getColor(WGuiColor::TEXT_FAIL));
mFont->DrawString(_(failMsg).c_str(),x+width/2, y, JGETEXT_RIGHT); mFont->DrawString(_(failMsg).c_str(),x+width/2, y, JGETEXT_RIGHT);
return; return;
@@ -401,7 +401,7 @@ string WDecoEnum::lookupVal(int value){
void WDecoEnum::Render() void WDecoEnum::Render()
{ {
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT); WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT);
mFont->SetColor(getColor(WGuiColor::TEXT)); mFont->SetColor(getColor(WGuiColor::TEXT));
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
mFont->DrawString(_(getDisplay()).c_str(), getX() + 2, getY() + 3); mFont->DrawString(_(getDisplay()).c_str(), getX() + 2, getY() + 3);
@@ -451,7 +451,7 @@ void WDecoConfirm::Entering(JButton key){
SAFE_DELETE(confirmMenu); SAFE_DELETE(confirmMenu);
mState = OP_CONFIRMED; mState = OP_CONFIRMED;
confirmMenu = NEW SimpleMenu(444, listener,Constants::MENU_FONT, 50,170); confirmMenu = NEW SimpleMenu(444, listener,Fonts::MENU_FONT, 50,170);
confirmMenu->Add(1,confirm.c_str()); confirmMenu->Add(1,confirm.c_str());
confirmMenu->Add(2,cancel.c_str()); confirmMenu->Add(2,cancel.c_str());
} }
@@ -968,7 +968,7 @@ void WGuiTabMenu::Add(WGuiBase * it){
} }
void WGuiTabMenu::Render(){ void WGuiTabMenu::Render(){
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT); WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT);
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
if (!items.size()) if (!items.size())
@@ -1000,7 +1000,7 @@ void WGuiTabMenu::save(){
//WGuiAward //WGuiAward
void WGuiAward::Overlay(){ void WGuiAward::Overlay(){
JRenderer * r = JRenderer::GetInstance(); JRenderer * r = JRenderer::GetInstance();
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT); WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT);
mFont->SetScale(0.8f); mFont->SetScale(0.8f);
mFont->SetColor(getColor(WGuiColor::TEXT)); mFont->SetColor(getColor(WGuiColor::TEXT));
@@ -1051,7 +1051,7 @@ void WGuiAward::Render(){
return; return;
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT); WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT);
mFont->SetScale(1); mFont->SetScale(1);
mFont->SetColor(getColor(WGuiColor::TEXT)); mFont->SetColor(getColor(WGuiColor::TEXT));
@@ -1293,7 +1293,7 @@ void WGuiListRow::Render(){
//List is empty. //List is empty.
if (!items.size() && failMsg != ""){ if (!items.size() && failMsg != ""){
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT); WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT);
mFont->SetColor(getColor(WGuiColor::TEXT_FAIL)); mFont->SetColor(getColor(WGuiColor::TEXT_FAIL));
mFont->DrawString(_(failMsg).c_str(),x+width/2, y, JGETEXT_RIGHT); mFont->DrawString(_(failMsg).c_str(),x+width/2, y, JGETEXT_RIGHT);
return; return;
@@ -1603,7 +1603,7 @@ void WGuiFilterItem::updateValue(){
SAFE_DELETE(mParent->subMenu); SAFE_DELETE(mParent->subMenu);
mState = STATE_CHOOSE_TYPE; mState = STATE_CHOOSE_TYPE;
SAFE_DELETE(mParent->subMenu); SAFE_DELETE(mParent->subMenu);
mParent->subMenu = NEW SimpleMenu(-1234,this,Constants::MENU_FONT,20,20,"Filter By...",10); mParent->subMenu = NEW SimpleMenu(-1234,this,Fonts::MENU_FONT,20,20,"Filter By...",10);
if(mParent->isAvailable(FILTER_SET)){ if(mParent->isAvailable(FILTER_SET)){
mParent->subMenu->Add(FILTER_SET,"Set"); mParent->subMenu->Add(FILTER_SET,"Set");
delMenu = false; delMenu = false;
@@ -1660,7 +1660,7 @@ void WGuiFilterItem::updateValue(){
SAFE_DELETE(mParent->subMenu); SAFE_DELETE(mParent->subMenu);
mParent->clearArgs(); mParent->clearArgs();
mState = STATE_CHOOSE_VAL; mState = STATE_CHOOSE_VAL;
mParent->subMenu = NEW SimpleMenu(-1234,this,Constants::MENU_FONT,20,20,"Filter:"); mParent->subMenu = NEW SimpleMenu(-1234,this,Fonts::MENU_FONT,20,20,"Filter:");
if(filterType == FILTER_TYPE){ if(filterType == FILTER_TYPE){
mParent->addArg("Artifact","t:Artifact;"); mParent->addArg("Artifact","t:Artifact;");
mParent->addArg("Artifact Creature","t:Artifact;&t:Creature;"); mParent->addArg("Artifact Creature","t:Artifact;&t:Creature;");
@@ -1892,7 +1892,7 @@ WGuiBase::CONFIRM_TYPE WGuiKeyBinder::needsConfirm() {
confirmationString = ss.str(); confirmationString = ss.str();
// Then create the menu. // Then create the menu.
confirmMenu = NEW SimpleMenu(0, this, Constants::MENU_FONT, 40, 130, "Conflict"); confirmMenu = NEW SimpleMenu(0, this, Fonts::MENU_FONT, 40, 130, "Conflict");
confirmMenu->Add(1, _("Cancel and return to the options menu").c_str()); confirmMenu->Add(1, _("Cancel and return to the options menu").c_str());
confirmMenu->Add(2, _("This is okay, validate and save").c_str()); confirmMenu->Add(2, _("This is okay, validate and save").c_str());
return CONFIRM_NEED; return CONFIRM_NEED;
@@ -1913,7 +1913,7 @@ WGuiBase::CONFIRM_TYPE WGuiKeyBinder::needsConfirm() {
confirmationString = s; confirmationString = s;
confirmingButton = btnToCheck[i]; confirmingButton = btnToCheck[i];
confirmMenu = NEW SimpleMenu(1, this, Constants::MENU_FONT, 40, 130, "Binding missing"); confirmMenu = NEW SimpleMenu(1, this, Fonts::MENU_FONT, 40, 130, "Binding missing");
confirmMenu->Add(1, _("Cancel and return to the options menu").c_str()); confirmMenu->Add(1, _("Cancel and return to the options menu").c_str());
confirmMenu->Add(2, _("This is okay, validate and save").c_str()); confirmMenu->Add(2, _("This is okay, validate and save").c_str());
return CONFIRM_NEED; return CONFIRM_NEED;
@@ -1936,7 +1936,7 @@ void WGuiKeyBinder::Render() {
WGuiList::Render(); WGuiList::Render();
if (confirmMenu) { if (confirmMenu) {
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT); WFont * mFont = resources.GetWFont(Fonts::OPTION_FONT);
mFont->SetColor(ARGB(255, 255, 0, 0)); mFont->SetColor(ARGB(255, 255, 0, 0));
renderer->FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ARGB(230, 255, 240, 240)); renderer->FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ARGB(230, 255, 240, 240));
+73 -117
View File
@@ -16,30 +16,36 @@
#include <sys/stat.h> #include <sys/stat.h>
#endif #endif
#include "../include/WFont.h" #include "../include/WFont.h"
extern bool neofont; extern bool neofont;
int idCounter = OTHERS_OFFSET; int idCounter = OTHERS_OFFSET;
WResourceManager resources; WResourceManager resources;
unsigned int vTime = 0;
namespace
{
const std::string kExtension_png(".png");
const std::string kExtension_gbk(".gbk");
}
int WResourceManager::RetrieveError(){ int WResourceManager::RetrieveError(){
return lastError; return lastError;
} }
bool WResourceManager::RemoveOldest(){
if(sampleWCache.RemoveOldest())
return true;
if(textureWCache.RemoveOldest())
return true;
if(psiWCache.RemoveOldest())
return true;
return false; bool WResourceManager::RemoveOldest(){
if(sampleWCache.RemoveOldest())
return true;
if(textureWCache.RemoveOldest())
return true;
if(psiWCache.RemoveOldest())
return true;
return false;
} }
//WResourceManager //WResourceManager
void WResourceManager::DebugRender(){ void WResourceManager::DebugRender(){
JRenderer* renderer = JRenderer::GetInstance(); JRenderer* renderer = JRenderer::GetInstance();
WFont * font = resources.GetWFont(Constants::MAIN_FONT); WFont * font = resources.GetWFont(Fonts::MAIN_FONT);
font->SetColor(ARGB(255,255,255,255)); font->SetColor(ARGB(255,255,255,255));
if(!font || !renderer) if(!font || !renderer)
@@ -173,14 +179,6 @@ WResourceManager::WResourceManager(){
mQuadList.reserve(0); mQuadList.reserve(0);
mQuadMap.clear(); mQuadMap.clear();
mWFontList.clear();
mWFontList.reserve(4);
mWFontMap.clear();
mWLBFontList.clear();
mWLBFontList.reserve(4);
mWLBFontMap.clear();
psiWCache.Resize(PSI_CACHE_SIZE,20); psiWCache.Resize(PSI_CACHE_SIZE,20);
sampleWCache.Resize(SAMPLES_CACHE_SIZE,MAX_CACHED_SAMPLES); sampleWCache.Resize(SAMPLES_CACHE_SIZE,MAX_CACHED_SAMPLES);
textureWCache.Resize(TEXTURES_CACHE_MINSIZE,MAX_CACHE_OBJECTS); textureWCache.Resize(TEXTURES_CACHE_MINSIZE,MAX_CACHE_OBJECTS);
@@ -193,7 +191,6 @@ WResourceManager::~WResourceManager(){
LOG("==Destroying WResourceManager=="); LOG("==Destroying WResourceManager==");
RemoveAll(); RemoveAll();
RemoveWFonts(); RemoveWFonts();
RemoveWLBFonts();
LOG("==Successfully Destroyed WResourceManager=="); LOG("==Successfully Destroyed WResourceManager==");
} }
@@ -248,7 +245,7 @@ JQuad * WResourceManager::RetrieveCard(MTGCard * card, int style, int submode){
} }
lastError = textureWCache.mError; lastError = textureWCache.mError;
if(jq){ if(jq){
jq->SetHotSpot(jq->mTex->mWidth / 2, jq->mTex->mHeight / 2); jq->SetHotSpot(static_cast<float>(jq->mTex->mWidth / 2), static_cast<float>(jq->mTex->mHeight / 2));
return jq; return jq;
} }
@@ -849,120 +846,81 @@ int WResourceManager::fileOK(string filename, bool relative){
return result; return result;
} }
int WResourceManager::reloadWLBFonts(){ void WResourceManager::InitFonts(const std::string& inLang)
vector<string> fontNames; {
vector<float> fontSizes; unsigned int idOffset = 0;
fontNames.resize(mWLBFontList.size()); if (inLang.compare("cn") == 0)
fontSizes.resize(mWLBFontList.size()); {
for ( map<string, int>::iterator itr = mWLBFontMap.begin(); itr != mWLBFontMap.end(); ++itr){ mFontFileExtension = kExtension_gbk;
fontNames[itr->second] = itr->first; LoadWFont("simon", 12, Fonts::MAIN_FONT);
fontSizes[itr->second] = mWLBFontList[itr->second]->GetHeight(); LoadWFont("f3", 16, Fonts::MENU_FONT);
} LoadWFont("magic", 16, Fonts::MAGIC_FONT);
RemoveWLBFonts(); LoadWFont("smallface", 12, Fonts::SMALLFACE_FONT);
for(size_t i = 0; i < fontNames.size(); ++i){
LoadWLBFont(fontNames[i],fontSizes[i]); idOffset = Fonts::kSingleByteFontOffset;
} }
return 1; mFontFileExtension = kExtension_png;
LoadWFont("simon", 11, Fonts::MAIN_FONT + idOffset);
GetWFont(Fonts::MAIN_FONT)->SetTracking(-1);
LoadWFont("f3", 16, Fonts::MENU_FONT + idOffset);
LoadWFont("magic", 16, Fonts::MAGIC_FONT + idOffset);
LoadWFont("smallface", 7, Fonts::SMALLFACE_FONT + idOffset);
} }
int WResourceManager::reloadWFonts(){ int WResourceManager::ReloadWFonts(){
RemoveWFonts();
string lang = options[Options::LANG].str; string lang = options[Options::LANG].str;
std::transform(lang.begin(), lang.end(), lang.begin(), ::tolower); std::transform(lang.begin(), lang.end(), lang.begin(), ::tolower);
if (lang.compare("cn") != 0) InitFonts(lang);
RemoveWFonts();
else if (mWFontList.size() == 0){
resources.LoadWFBFont("simon",12);
resources.LoadWFBFont("f3",16);
resources.LoadWFBFont("magic",16);
resources.LoadWFBFont("smallface",12);
}
return 1; return 1;
} }
WFont* WResourceManager::LoadWFont(const string& inFontname, int inFontHeight, int inFontID)
{
WFont* font = GetWFont(inFontID);
if (font)
{
return font;
}
WFont * WResourceManager::LoadWLBFont(const string &fontName, int height) { string mFontName = inFontname + mFontFileExtension;
map<string, int>::iterator itr = mWLBFontMap.find(fontName);
if (itr != mWLBFontMap.end()) return mWLBFontList[itr->second];
string mFontName = fontName + ".png";
string path = graphicsFile(mFontName); string path = graphicsFile(mFontName);
if (path.size() > 4 ) path = path.substr(0, path.size() - 4); //some stupid manipulation because of the way Font works in JGE if (path.size() > 4 ) path = path.substr(0, path.size() - 4); //some stupid manipulation because of the way Font works in JGE
int id = mWLBFontList.size();
mWLBFontList.push_back(NEW WLBFont(path.c_str(), height, true));
mWLBFontMap[fontName] = id;
mWLBFontList[id]->id = id;
return mWLBFontList[id]; if (mFontFileExtension == kExtension_gbk)
} {
font = NEW WFBFont(inFontID, path.c_str(), inFontHeight, true);
WFont * WResourceManager::LoadWFBFont(const string &fontName, int height) { }
map<string, int>::iterator itr = mWFontMap.find(fontName);
if (itr != mWFontMap.end()) return mWFontList[itr->second];
string mFontName = fontName + ".gbk";
string path = graphicsFile(mFontName);
if (path.size() > 4 ) path = path.substr(0, path.size() - 4); //some stupid manipulation because of the way WFont works in JGE
int id = mWFontList.size();
mWFontList.push_back(NEW WFBFont(path.c_str(), height, true));
mWFontMap[fontName] = id;
mWFontList[id]->id = id;
return mWFontList[id];
}
WFont * WResourceManager::GetWFont(const string &fontName) {
map<string, int>::iterator itr;
if (neofont) {
itr = mWFontMap.find(fontName);
if (itr != mWFontMap.end())
return mWFontList[itr->second];
else
return NULL;
} else {
itr = mWLBFontMap.find(fontName);
if (itr != mWLBFontMap.end())
return mWLBFontList[itr->second];
else
return NULL;
}
}
WFont * WResourceManager::GetWFont(int id) {
if (neofont) {
return mWFontList[id];
} else {
if (id >=0 && id < (int)mWLBFontList.size())
return mWLBFontList[id];
else
return NULL;
}
}
WFont * WResourceManager::GetWLBFont(int id) {
if (id >=0 && id < (int)mWLBFontList.size())
return mWLBFontList[id];
else else
return NULL; {
font = NEW WLBFont(inFontID, path.c_str(), inFontHeight, true);
}
mWFontMap[inFontID] = font;
return font;
} }
void WResourceManager::RemoveWLBFonts() { WFont* WResourceManager::GetWFont(int id)
for (vector<WLBFont *>::iterator font = mWLBFontList.begin(); font != mWLBFontList.end(); ++font) {
delete *font; WFont* font = NULL;
mWLBFontList.clear(); FontMap::iterator iter = mWFontMap.find(id);
mWLBFontMap.clear(); if (iter != mWFontMap.end())
{
font = iter->second;
}
return font;
} }
void WResourceManager::RemoveWFonts() { void WResourceManager::RemoveWFonts() {
for (vector<WFont *>::iterator font = mWFontList.begin(); font != mWFontList.end(); ++font) for (FontMap::iterator font = mWFontMap.begin(); font != mWFontMap.end(); ++font)
delete *font; {
mWFontList.clear(); delete font->second;
}
mWFontMap.clear(); mWFontMap.clear();
} }
@@ -989,8 +947,7 @@ JMusic * WResourceManager::ssLoadMusic(const char *fileName){
void WResourceManager::Refresh(){ void WResourceManager::Refresh(){
//Really easy cache relinking. //Really easy cache relinking.
reloadWFonts(); ReloadWFonts();
reloadWLBFonts();
sampleWCache.Refresh(); sampleWCache.Refresh();
textureWCache.Refresh(); textureWCache.Refresh();
psiWCache.Refresh(); psiWCache.Refresh();
@@ -1337,7 +1294,6 @@ WCache<cacheItem, cacheActual>::~WCache(){
for(it=managed.begin();it!=managed.end();it++){ for(it=managed.begin();it!=managed.end();it++){
SAFE_DELETE(it->second); SAFE_DELETE(it->second);
} }
} }