- Chinese patch by linshier
This commit is contained in:
wagic.the.homebrew@gmail.com
2010-07-31 14:41:04 +00:00
parent 1704a20d09
commit f40af0b1cb
65 changed files with 21364 additions and 175 deletions
+1 -1
View File
@@ -152,7 +152,7 @@ void AIStats::Render(){
if (player == g->players[1]) x0 = 280;
JRenderer::GetInstance()->FillRoundRect(x0,10,200,180,5,ARGB(50,0,0,0));
JLBFont * f = resources.GetJLBFont("simon");
WFont * f = resources.GetWFont("simon");
int i = 0;
char buffer[512];
list<AIStat *>::iterator it;
+6 -6
View File
@@ -27,7 +27,7 @@ void NextGamePhase::Render(){
GameObserver * g = GameObserver::GetInstance();
int nextPhase = (g->getCurrentGamePhase() + 1) % Constants::MTG_PHASE_CLEANUP;
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
mFont->SetBase(0);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
char buffer[200];
@@ -51,7 +51,7 @@ ostream& NextGamePhase::toString(ostream& out) const
}
void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string alt1, string alt2, string action, bool bigQuad){
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
mFont->SetColor(ARGB(255,255,255,255));
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
mFont->DrawString(_(action).c_str(), x + 30 , y, JGETEXT_LEFT);
@@ -273,7 +273,7 @@ int PutInGraveyard::resolve(){
}
void PutInGraveyard::Render(){
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
mFont->SetBase(0);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
if (!removeFromGame){
@@ -310,7 +310,7 @@ int DrawAction::resolve(){
}
void DrawAction::Render(){
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
mFont->SetBase(0);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
char buffer[200];
@@ -736,7 +736,7 @@ void ActionStack::Render(){
if (current->state==NOT_RESOLVED) height += current->mHeight;
}
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
mFont->SetBase(0);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
mFont->SetColor(ARGB(255,255,255,255));
@@ -792,7 +792,7 @@ void ActionStack::Render(){
if (current->display) height += current->mHeight;
}
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
mFont->SetColor(ARGB(255,255,255,255));
+6 -5
View File
@@ -44,7 +44,7 @@ void CardGui::Update(float dt)
void CardGui::Render()
{
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
JRenderer * renderer = JRenderer::GetInstance();
GameObserver * game = GameObserver::GetInstance();
@@ -194,7 +194,7 @@ void CardGui::alternateRender(MTGCard * card, const Pos& pos){
renderer->RenderQuad(q, x, pos.actY, pos.actT, scale, scale);
}
// Write the title
JLBFont * font = resources.GetJLBFont("magic");
WFont * font = resources.GetWFont("magic");
float backup_scale = font->GetScale();
font->SetColor(ARGB((int)pos.actA, 0, 0, 0));
font->SetScale(0.8 * pos.actZ);
@@ -213,8 +213,9 @@ void CardGui::alternateRender(MTGCard * card, const Pos& pos){
font->SetScale(0.8 * pos.actZ);
const std::vector<string> txt = card->data->formattedText();
unsigned i = 0;
unsigned h = neofont ? 14 : 11;
for (std::vector<string>::const_iterator it = txt.begin(); it != txt.end(); ++it, ++i)
font->DrawString(it->c_str(), x + (22 - BigWidth / 2)*pos.actZ, pos.actY + (-BigHeight/2 + 80 + 11 * i)*pos.actZ);
font->DrawString(it->c_str(), x + (22 - BigWidth / 2)*pos.actZ, pos.actY + (-BigHeight/2 + 80 + h * i)*pos.actZ);
}
// Write the strength
@@ -285,7 +286,7 @@ void CardGui::alternateRender(MTGCard * card, const Pos& pos){
for (int i = card->data->types.size() - 1; i > 0; --i)
{
s += _(Subtypes::subtypesList->find(card->data->types[i]));
s += " - ";
s += _(" - ");
}
if(card->data->types.size())
s += _(Subtypes::subtypesList->find(card->data->types[0]));
@@ -382,7 +383,7 @@ void CardGui::RenderBig(MTGCard* card, const Pos& pos){
void CardGui::renderCountersBig(const Pos& pos){
// Write Named Counters
if (card->counters) {
JLBFont * font = resources.GetJLBFont("magic");
WFont * font = resources.GetWFont("magic");
font->SetColor(ARGB((int)pos.actA, 0, 0, 0));
font->SetScale(0.8 * pos.actZ);
std::vector<string> txt = card->formattedText();
+1 -1
View File
@@ -65,7 +65,7 @@ const vector<string>& CardPrimitive::formattedText()
s[found] = '/';
found = s.find_first_of("{}", found + 1);
}
std::string::size_type len = 30;
std::string::size_type len = neofont ? 24 :30;
while (s.length() > 0)
{
std::string::size_type cut = s.find_first_of("., \t)", 0);
+4 -4
View File
@@ -17,7 +17,7 @@
}
void CreditBonus::Render(float x, float y, JLBFont * font){
void CreditBonus::Render(float x, float y, WFont * font){
char buffer[512];
sprintf(buffer, "%s: %i", text.c_str(), value);
font->DrawString(buffer,x,y);
@@ -170,9 +170,9 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app){
void Credits::Render(){
GameObserver * g = GameObserver::GetInstance();
JRenderer * r = JRenderer::GetInstance();
JLBFont * f = resources.GetJLBFont(Constants::MAIN_FONT);
JLBFont * f2 = resources.GetJLBFont(Constants::MENU_FONT);
JLBFont * f3 = resources.GetJLBFont(Constants::MAGIC_FONT);
WFont * f = resources.GetWFont(Constants::MAIN_FONT);
WFont * f2 = resources.GetWFont(Constants::MENU_FONT);
WFont * f3 = resources.GetWFont(Constants::MAGIC_FONT);
f->SetScale(1);
f->SetColor(ARGB(255,255,255,255));
f2->SetScale(1);
+1 -1
View File
@@ -77,7 +77,7 @@ int Damage::resolve(){
}
void Damage::Render(){
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
mFont->SetBase(0);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
char buffer[200];
+1 -1
View File
@@ -51,7 +51,7 @@ void DamagerDamaged::clearDamage()
void DamagerDamaged::Render(CombatStep mode)
{
TransientCardView::Render();
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
mFont->SetBase(0);
switch (mode)
+2 -2
View File
@@ -73,7 +73,7 @@ int SacrificeCost::doPay(){
void SacrificeCost::Render(){
//TODO : real stuff
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
mFont->SetColor(ARGB(255,255,255,255));
char buffer[200];
@@ -163,7 +163,7 @@ int CounterCost::doPay(){
}
void CounterCost::Render(){
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
mFont->SetColor(ARGB(255,255,255,255));
char buffer[200];
+13 -8
View File
@@ -146,11 +146,16 @@ void GameApp::Create()
jq->SetHotSpot(16,16);
LOG("--Loading fonts");
resources.LoadJLBFont("simon",11);
resources.GetJLBFont("simon")->SetTracking(-1);
resources.LoadJLBFont("f3",16);
resources.LoadJLBFont("magic",16);
resources.LoadJLBFont("smallface", 7);
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");
@@ -340,7 +345,7 @@ void GameApp::Render()
{
if (systemError.size()){
fprintf(stderr, "%s", systemError.c_str());
JLBFont * mFont= resources.GetJLBFont("simon");
WFont * mFont= resources.GetWFont("simon");
if (mFont) mFont->DrawString(systemError.c_str(),1,1);
return;
}
@@ -360,7 +365,7 @@ void GameApp::Render()
float fps = mEngine->GetFPS();
totalFPS += fps;
nbUpdates+=1;
JLBFont * mFont= resources.GetJLBFont("simon");
WFont * mFont= resources.GetWFont("simon");
char buf[512];
sprintf(buf, "avg:%.02f - %.02f fps",totalFPS/nbUpdates, fps);
if (mFont) {
@@ -438,4 +443,4 @@ void GameApp::playMusic(string filename, bool loop) {
music = resources.ssLoadMusic(filename.c_str());
if (music) JSoundSystem::GetInstance()->PlayMusic(music, loop);
}
}
}
+7 -1
View File
@@ -40,7 +40,13 @@ int GameState::fillDeckMenu(SimpleMenu * _menu, string path, string smallDeckPre
sprintf(deckDesc, "%s",meta->name.c_str());
}
deckDesc[16] = 0;
_menu->Add(nbDecks,deckDesc,meta->desc);
//translate decks desc
Translator * t = Translator::GetInstance();
map<string,string>::iterator it = t->deckValues.find(meta->name);
if (it != t->deckValues.end())
_menu->Add(nbDecks,deckDesc,it->second);
else
_menu->Add(nbDecks,deckDesc,meta->desc);
}
}
return nbDecks;
+6 -6
View File
@@ -427,7 +427,7 @@ void GameStateDeckViewer::Update(float dt)
void GameStateDeckViewer::renderOnScreenBasicInfo(){
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
char buffer[256];
int myD = (displayed_deck == myDeck);
@@ -450,7 +450,7 @@ void GameStateDeckViewer::renderOnScreenBasicInfo(){
void GameStateDeckViewer::renderSlideBar(){
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
int total = displayed_deck->Size();
float filler = 15;
@@ -522,7 +522,7 @@ void GameStateDeckViewer::renderDeckBackground(){
void GameStateDeckViewer::renderOnScreenMenu(){
JLBFont * font = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * font = resources.GetWFont(Constants::MAIN_FONT);
font->SetColor(ARGB(255,255,255,255));
JRenderer * r = JRenderer::GetInstance();
float pspIconsSize = 0.5;
@@ -1184,7 +1184,7 @@ int GameStateDeckViewer::countCardsByType(const char * _type) {
}
void GameStateDeckViewer::renderCard(int id, float rotation){
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
MTGCard * card = cardIndex[id];
float max_scale = 0.96f;
@@ -1255,7 +1255,7 @@ void GameStateDeckViewer::renderCard(int id, float rotation){
float qtX = x + 40*scale;
char buffer[4096];
sprintf(buffer, "x%i", displayed_deck->count(card));
JLBFont * font = mFont;
WFont * font = mFont;
font->SetColor(ARGB(fontAlpha/2,0,0,0));
JRenderer::GetInstance()->FillRect(qtX, qtY,font->GetStringWidth(buffer) + 6,16,ARGB(fontAlpha/2,0,0,0));
font->DrawString(buffer, qtX + 4, qtY + 4);
@@ -1272,7 +1272,7 @@ void GameStateDeckViewer::renderCard (int id){
void GameStateDeckViewer::Render() {
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
JRenderer * r = JRenderer::GetInstance();
r->ClearScreen(ARGB(0,0,0,0));
+1 -1
View File
@@ -392,7 +392,7 @@ void GameStateDuel::Update(float dt)
void GameStateDuel::Render()
{
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
JRenderer * r = JRenderer::GetInstance();
r->ClearScreen(ARGB(0,0,0,0));
+7 -6
View File
@@ -9,6 +9,7 @@
#include "../include/DeckStats.h"
#include "../include/PlayerData.h"
#include "../include/utils.h"
#include "../include/WFont.h"
static const char* GAME_VERSION = "WTH?! 0.12.1 - by wololo";
@@ -364,7 +365,7 @@ void GameStateMenu::ensureMGuiController(){
if (!mGuiController) {
mGuiController = NEW JGuiController(100, this);
if (mGuiController) {
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
WFont * mFont = resources.GetWFont(Constants::MENU_FONT);
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_DECKEDITOR, mFont, "Deck Editor", 160, 50 + SCREEN_HEIGHT/2, mIcons[2], mIcons[3],"particle2.psi",resources.GetQuad("particles")));
@@ -542,7 +543,7 @@ void GameStateMenu::Render()
return;
JRenderer * renderer = JRenderer::GetInstance();
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
WFont * mFont = resources.GetWFont(Constants::MENU_FONT);
if ((currentState & MENU_STATE_MAJOR) == MENU_STATE_MAJOR_LANG){
}else if ((currentState & MENU_STATE_MAJOR) == MENU_STATE_MAJOR_LOADING_CARDS){
if(!splashTex){
@@ -575,7 +576,7 @@ void GameStateMenu::Render()
mFont->SetColor(ARGB(255,255,255,255));
mFont->DrawString(text,SCREEN_WIDTH/2,SCREEN_HEIGHT - 50,JGETEXT_CENTER);
}else{
mFont = resources.GetJLBFont(Constants::MAIN_FONT);
mFont = resources.GetWFont(Constants::MAIN_FONT);
PIXEL_TYPE colors[] =
{
@@ -609,7 +610,7 @@ void GameStateMenu::Render()
if(options.newAward())
alp = (int)(sin(timeIndex) * 255);
float olds = mFont->GetScale();
mFont = resources.GetJLBFont(Constants::OPTION_FONT);
mFont = resources.GetWFont(Constants::OPTION_FONT);
jq->SetColor(ARGB(abs(alp),255,255,255));
mFont->SetColor(ARGB(abs(alp),0,0,0));
string s = _("Trophy Room");;
@@ -617,7 +618,7 @@ void GameStateMenu::Render()
mFont->SetScale(50.0f/mFont->GetStringWidth(s.c_str()));
renderer->RenderQuad(jq, SCREEN_WIDTH-64, 2);
mFont->DrawString(s,SCREEN_WIDTH-10,9,JGETEXT_RIGHT);
mFont = resources.GetJLBFont(Constants::MENU_FONT);
mFont = resources.GetWFont(Constants::MENU_FONT);
mFont->SetScale(olds);
}
}
@@ -629,7 +630,7 @@ void GameStateMenu::Render()
void GameStateMenu::ButtonPressed(int controllerId, int controlId)
{
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
WFont * mFont = resources.GetWFont(Constants::MENU_FONT);
#if defined (WIN32) || defined (LINUX)
char buf[4096];
sprintf(buf, "cnotrollerId: %i", controllerId);
+4 -3
View File
@@ -176,8 +176,9 @@ void GameStateOptions::Render()
"Art: Ilya B, Julio, Jeck, J, Lakeesha",
"Check themeinfo.txt for the full credits of each theme!",
"",
"Dev Team: Abrasax, Daddy32, Dr.Solomat, J, Jeck",
"Leungclj, Salmelo, Superhiro, Psyringe, Wololo, Yeshua",
"Dev Team: Abrasax, almosthumane, Daddy32, Dr.Solomat"
"J, Jeck, Leungclj, linshier, Salmelo, Superhiro",
"Psyringe, Wololo, Yeshua",
"",
"Music by Celestial Aeon Project, http://www.jamendo.com",
"",
@@ -202,7 +203,7 @@ void GameStateOptions::Render()
"Please support this project with donations at http://wololo.net/wagic",
};
JLBFont * mFont = resources.GetJLBFont(Constants::MAGIC_FONT);
WFont * mFont = resources.GetWFont(Constants::MAGIC_FONT);
mFont->SetColor(ARGB(255,200,200,200));
mFont->SetScale(1.0);
float startpos = 272 - timer;
+2 -2
View File
@@ -171,7 +171,7 @@ string GameStateShop::descPurchase(int controlId, bool tiny){
return buffer;
}
void GameStateShop::beginPurchase(int controlId){
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
WFont * mFont = resources.GetWFont(Constants::MENU_FONT);
mFont->SetScale(DEFAULT_MENU_FONT_SCALE);
SAFE_DELETE(menu);
if(mInventory[controlId] <= 0){
@@ -556,7 +556,7 @@ void GameStateShop::deleteDisplay(){
void GameStateShop::Render()
{
//Erase
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
JRenderer * r = JRenderer::GetInstance();
r->ClearScreen(ARGB(0,0,0,0));
if(mStage == STAGE_FADE_IN)
+2 -2
View File
@@ -286,7 +286,7 @@ void GuiCombat::Render()
{
go->opponent()->mAvatar->SetHotSpot(18, 25);
enemy_avatar.Render(go->opponent()->mAvatar);
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
mFont->SetColor(ARGB(255, 255, 64, 0));
{
char buf[10]; sprintf(buf, "%i", damage);
@@ -302,7 +302,7 @@ void GuiCombat::Render()
renderer->DrawLine(0, SCREEN_HEIGHT / 2 + 10, SCREEN_WIDTH, SCREEN_HEIGHT / 2 + 10, ARGB(255, 255, 64, 0));
if (FIRST_STRIKE == step)
{
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
mFont->SetColor(ARGB(255, 64, 255, 64));
mFont->DrawString("First strike damage", 370, 2);
}
+1 -1
View File
@@ -180,7 +180,7 @@ void GuiHandSelf::Render()
{
//Empty hand
if (state == Open && cards.size() == 0){
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
mFont->SetColor(ARGB(255,255,0,0));
if (OptionHandDirection::HORIZONTAL == options[Options::HANDDIRECTION].number){
back->SetColor(ARGB(255,255,0,0));
+1 -1
View File
@@ -213,7 +213,7 @@ GuiMana::~GuiMana(){
void GuiMana::RenderStatic(){
int values[Constants::MTG_NB_COLORS];
int totalColors = 0;
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
JRenderer * r = JRenderer::GetInstance();
for (int i = 0; i < Constants::MTG_NB_COLORS; ++i)
values[i] = 0;
+4 -4
View File
@@ -93,7 +93,7 @@ void GuiPhaseBar::Render()
}
//print phase name
JLBFont * font = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * font = resources.GetWFont(Constants::MAIN_FONT);
string currentP = _("your turn");
string interrupt = "";
if (g->currentPlayer == g->players[1]){
@@ -105,13 +105,13 @@ void GuiPhaseBar::Render()
}
if (g->currentlyActing() != g->currentPlayer){
if (g->currentPlayer == g->players[0]) {
interrupt = " - "+_("opponent plays");
interrupt = _(" - ")+_("opponent plays");
}else{
interrupt = " - "+_("you play");
interrupt = _(" - ")+_("you play");
}
}
char buf[64]; sprintf(buf, "(%s%s) %s", currentP.c_str(),interrupt.c_str(),_(PhaseRing::phaseName(phase->id)).c_str());
char buf[64]; sprintf(buf, _("(%s%s) %s").c_str(), currentP.c_str(),interrupt.c_str(),_(PhaseRing::phaseName(phase->id)).c_str());
font->DrawString(buf, SCREEN_WIDTH-5, 2,JGETEXT_RIGHT);
}
+2 -2
View File
@@ -22,7 +22,7 @@ void GuiAvatar::Render()
GameObserver * game = GameObserver::GetInstance();
JRenderer * r = JRenderer::GetInstance();
int life = player->life;
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
//Avatar
int lifeDiff = life - currentLife;
@@ -128,7 +128,7 @@ void GuiGameZone::Render(){
JRenderer::GetInstance()->FillRect(actX,actY,quad->mWidth * scale * actZ,quad->mHeight *scale * actZ, ARGB(abs(128 - wave),255,255,255));
//Number of cards
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * mFont = resources.GetWFont(Constants::MAIN_FONT);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
char buffer[11];
int mAlpha = (int)(actA);
+3 -3
View File
@@ -229,6 +229,7 @@ int MTGAllCards::load(const char * config_file, const char * set_name,int autolo
if (!std::getline(setFile, s)) return total_cards;
if (!s.size()) continue;
if (s[s.size()-1] == '\r') s.erase(s.size()-1); // Handle DOS files
switch (conf_read_mode) {
case MTGAllCards::READ_ANYTHING:
if (s[0] == '['){
@@ -261,7 +262,6 @@ int MTGAllCards::load(const char * config_file, const char * set_name,int autolo
tempCard = NULL;
tempPrimitive = NULL;
} else {
if (s[s.size()-1] == '\r') s.erase(s.size()-1); // Handle DOS files
processConfLine(s, tempCard, tempPrimitive);
}
continue;
@@ -898,8 +898,8 @@ int MTGSetInfo::totalCards(){
string MTGSetInfo::getName(){
if(name.size())
return _(name); //Pretty name is translated.
return id; //Ugly name is not.
return name; //Pretty name is translated when rendering.
return id; //Ugly name as well.
}
string MTGSetInfo::getBlock(){
if(block < 0 || block >= (int) setlist.blocks.size())
+1 -1
View File
@@ -5,7 +5,7 @@
MTGGamePhase::MTGGamePhase(int id):ActionElement(id){
animation = 0;
currentState = -1;
mFont= resources.GetJLBFont("simon");
mFont= resources.GetWFont("simon");
mFont->SetBase(0); // using 2nd font
}
+2 -2
View File
@@ -350,7 +350,7 @@ void MTGMomirRule::Update(float dt){
void MTGMomirRule::Render(){
if (!textAlpha) return;
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
WFont * mFont = resources.GetWFont(Constants::MENU_FONT);
mFont->SetScale(2 - (float)textAlpha/130);
mFont->SetColor(ARGB(textAlpha,255,255,255));
mFont->DrawString(text.c_str(),SCREEN_WIDTH/2,SCREEN_HEIGHT/2,JGETEXT_CENTER);
@@ -446,7 +446,7 @@ void HUDDisplay::Render(){
HUDDisplay::HUDDisplay(int _id):MTGAbility(_id, NULL){
timestamp = 0;
popdelay = 2;
f = resources.GetJLBFont(Constants::MAIN_FONT);
f = resources.GetWFont(Constants::MAIN_FONT);
maxWidth = 0;
}
+1 -1
View File
@@ -3,7 +3,7 @@
#include "../include/GameOptions.h"
#include "../include/Translate.h"
MenuItem::MenuItem(int id, JLBFont *font, string text, int x, int y, JQuad * _off, JQuad * _on, const char * particle, JQuad * particleTex, bool hasFocus): JGuiObject(id), mFont(font), mX(x), mY(y)
MenuItem::MenuItem(int id, WFont *font, string text, int x, int y, JQuad * _off, JQuad * _on, const char * particle, JQuad * particleTex, bool hasFocus): JGuiObject(id), mFont(font), mX(x), mY(y)
{
mText = _(text);
updatedSinceLastRender = 1;
+6 -6
View File
@@ -17,7 +17,7 @@ OptionItem::OptionItem( int _id, string _displayValue): WGuiItem(_displayValue)
//OptionInteger
void OptionInteger::Render(){
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT);
mFont->SetColor(getColor(WGuiColor::TEXT));
JRenderer * renderer = JRenderer::GetInstance();
@@ -67,7 +67,7 @@ void OptionSelect::Entering(JButton key){
}
void OptionSelect::Render(){
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT);
mFont->SetColor(getColor(WGuiColor::TEXT));
JRenderer * renderer = JRenderer::GetInstance();
@@ -164,7 +164,7 @@ void OptionProfile::populate(){
void OptionProfile::Render(){
JRenderer * renderer = JRenderer::GetInstance();
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT);
mFont->SetScale(1);
int spacing = 2+(int)mFont->GetHeight();
@@ -403,7 +403,7 @@ void OptionTheme::Render(){
renderer->RenderQuad(q,x, y,0,scale,scale);
}
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT);
mFont->SetColor(getColor(WGuiColor::TEXT_HEADER));
mFont->DrawString(buf, x + 2, y + 2);
if(bChecked && author.size()){
@@ -438,7 +438,7 @@ OptionKey::OptionKey(GameStateOptions* g, LocalKeySym from, JButton to) : WGuiIt
void OptionKey::Update(float dt) { if (btnMenu) btnMenu->Update(dt); }
void OptionKey::Render() {
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT);
mFont->SetColor(getColor(WGuiColor::TEXT));
JRenderer * renderer = JRenderer::GetInstance();
@@ -498,7 +498,7 @@ bool OptionKey::isModal() { return grabbed || btnMenu; }
void OptionKey::Overlay()
{
JRenderer * renderer = JRenderer::GetInstance();
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT);
mFont->SetColor(ARGB(255, 0, 0, 0));
if (grabbed) {
static const int x = 30, y = 45;
+3 -3
View File
@@ -21,7 +21,7 @@
float ShopItems::_y4[] = {169,188,250,182,182,168,220,208,198,259,245};
ShopItem::ShopItem(int id, JLBFont *font, char* text, JQuad * _quad,JQuad * _thumb, float _xy[], bool hasFocus, int _price): JGuiObject(id), mFont(font), mText(text), quad(_quad), thumb(_thumb), price(_price)
ShopItem::ShopItem(int id, WFont *font, char* text, JQuad * _quad,JQuad * _thumb, float _xy[], bool hasFocus, int _price): JGuiObject(id), mFont(font), mText(text), quad(_quad), thumb(_thumb), price(_price)
{
for (int i = 0; i < 8; ++i){
xy[i] = _xy[i];
@@ -52,7 +52,7 @@ ShopItem::ShopItem(int id, JLBFont *font, char* text, JQuad * _quad,JQuad * _thu
Entering();
}
ShopItem::ShopItem(int id, JLBFont *font, int _cardid, float _xy[], bool hasFocus, MTGAllCards * collection, int _price, DeckDataWrapper * ddw): JGuiObject(id), mFont(font), price(_price){
ShopItem::ShopItem(int id, WFont *font, int _cardid, float _xy[], bool hasFocus, MTGAllCards * collection, int _price, DeckDataWrapper * ddw): JGuiObject(id), mFont(font), price(_price){
for (int i = 0; i < 8; ++i){
xy[i] = _xy[i];
}
@@ -227,7 +227,7 @@ bool ShopItem::ButtonPressed()
}
ShopItems::ShopItems(int id, JGuiListener* listener, JLBFont* font, int x, int y, MTGAllCards * _collection, int _setIds[]): JGuiController(id, listener), mX(x), mY(y), mFont(font), collection(_collection){
ShopItems::ShopItems(int id, JGuiListener* listener, WFont* font, int x, int y, MTGAllCards * _collection, int _setIds[]): JGuiController(id, listener), mX(x), mY(y), mFont(font), collection(_collection){
mHeight = 0;
showPriceDialog = -1;
dialog = NULL;
+4 -4
View File
@@ -18,7 +18,7 @@ JTexture* SimpleMenu::spadeRTex = NULL;
JTexture* SimpleMenu::spadeLTex = NULL;
JTexture* SimpleMenu::jewelTex = NULL;
JTexture* SimpleMenu::sideTex = NULL;
JLBFont* SimpleMenu::titleFont = NULL;
WFont* SimpleMenu::titleFont = NULL;
hgeParticleSystem* SimpleMenu::stars = NULL;
unsigned int SimpleMenu::refCount = 0;
// Here comes the magic of jewel graphics
@@ -86,8 +86,8 @@ void SimpleMenu::drawVertPole(int x, int y, int height) {
}
void SimpleMenu::Render() {
JLBFont * titleFont = resources.GetJLBFont("smallface");
JLBFont * mFont = resources.GetJLBFont(fontId);
WFont * titleFont = resources.GetWFont("smallface");
WFont * mFont = resources.GetWFont(fontId);
if (0 == mWidth) {
float sY = mY + VMARGIN;
for (int i = startId; i < startId + mCount; ++i) {
@@ -129,7 +129,7 @@ void SimpleMenu::Render() {
if (i > mCount-1) break;
if ((static_cast<SimpleMenuItem*>(mObjects[i]))->mY - LINE_HEIGHT * startId < mY + height - LINE_HEIGHT + 7) {
if (static_cast<SimpleMenuItem*>(mObjects[i])->hasFocus()){
resources.GetJLBFont(Constants::MAIN_FONT)->DrawString(static_cast<SimpleMenuItem*>(mObjects[i])->desc.c_str(),mX+mWidth+10,mY+15);
resources.GetWFont(Constants::MAIN_FONT)->DrawString(static_cast<SimpleMenuItem*>(mObjects[i])->desc.c_str(),mX+mWidth+10,mY+15);
mFont->SetColor(ARGB(255,255,255,0));
} else
mFont->SetColor(ARGB(150,255,255,255));
+2 -2
View File
@@ -19,7 +19,7 @@ SimpleMenuItem::SimpleMenuItem(SimpleMenu* _parent, int id, int fontId, string t
void SimpleMenuItem::RenderWithOffset(float yOffset)
{
JLBFont * mFont = resources.GetJLBFont(fontId);
WFont * mFont = resources.GetWFont(fontId);
//mFont->SetColor(ARGB(255,255,255,255));
mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER);
}
@@ -73,7 +73,7 @@ void SimpleMenuItem::Relocate(int x, int y)
int SimpleMenuItem::GetWidth()
{
JLBFont * mFont = resources.GetJLBFont(fontId);
WFont * mFont = resources.GetWFont(fontId);
mFont->SetScale(1.0);
return mFont->GetStringWidth(mText.c_str());
}
+1 -1
View File
@@ -299,7 +299,7 @@ string SimplePad::Finish() {
void SimplePad::Render(){
//This could use some cleaning up to make margins more explicit
JLBFont * mFont = resources.GetJLBFont("f3");
WFont * mFont = resources.GetWFont("f3");
int offX = 0, offY = 0;
int kH = mFont->GetHeight();
+6 -6
View File
@@ -7,7 +7,7 @@
#include "../include/Credits.h"
#include "../include/PlayerData.h"
#include "../include/MTGDeck.h"
#include <JLBFont.h>
#include "../include/WFont.h"
#include <JGE.h>
#include <JFileSystem.h>
@@ -40,14 +40,14 @@ StoryText::StoryText(string text, float _mX, float _mY, string _align, int _font
}
}
void StoryText::Render() {
JLBFont * mFont = resources.GetJLBFont(font);
WFont * mFont = resources.GetWFont(font);
mFont->SetColor(ARGB(200,255,255,255));
mFont->SetScale(1.0);
mFont->DrawString(text.c_str(), mX, mY, align);
}
float StoryText::getHeight() {
JLBFont * mFont = resources.GetJLBFont(font);
WFont * mFont = resources.GetWFont(font);
return mFont->GetHeight();
}
@@ -196,7 +196,7 @@ StoryPage::StoryPage(StoryFlow * mParent):mParent(mParent){
void StoryChoice::Render()
{
JLBFont * mFont = resources.GetJLBFont(font);
WFont * mFont = resources.GetWFont(font);
mFont->SetColor(ARGB(200,255,255,255));
if (mHasFocus) mFont->SetColor(ARGB(255,255,255,0));
mFont->SetScale(mScale);
@@ -204,7 +204,7 @@ void StoryChoice::Render()
}
float StoryChoice::getHeight() {
JLBFont * mFont = resources.GetJLBFont(font);
WFont * mFont = resources.GetWFont(font);
return mFont->GetHeight() * mScale;
}
@@ -521,7 +521,7 @@ bool StoryFlow::parse(string path)
if (!fileSystem->OpenFile(path.c_str())) return false;
int size = fileSystem->GetFileSize();
char *xmlBuffer = new char[size];
char *xmlBuffer = NEW char[size];
fileSystem->ReadFile(xmlBuffer, size);
TiXmlDocument doc;
+11 -11
View File
@@ -202,31 +202,31 @@ Task* Task::createFromStr(string params, bool rand) {
switch (exploded[0][0]) {
case TASK_WIN_AGAINST:
result = new TaskWinAgainst();
result = NEW TaskWinAgainst();
break;
case TASK_SLAUGHTER:
result = new TaskSlaughter();
result = NEW TaskSlaughter();
break;
case TASK_DELAY:
result = new TaskDelay();
result = NEW TaskDelay();
break;
case TASK_IMMORTAL:
result = new TaskImmortal();
result = NEW TaskImmortal();
break;
case TASK_MASSIVE_BURIAL:
result = new TaskMassiveBurial();
result = NEW TaskMassiveBurial();
break;
case TASK_WISDOM:
result = new TaskWisdom();
result = NEW TaskWisdom();
break;
case TASK_PACIFISM:
result = new TaskPacifism();
result = NEW TaskPacifism();
break;
default:
#if defined (WIN32) || defined (LINUX)
OutputDebugString("\nTasks.cpp::createFromStr: Undefined class type\n");
#endif
result = new TaskWinAgainst();
result = NEW TaskWinAgainst();
}
if (!result) {
@@ -430,9 +430,9 @@ void TaskList::Update(float dt) {
void TaskList::Render() {
JRenderer * r = JRenderer::GetInstance();
//Setup fonts.
JLBFont * f = resources.GetJLBFont(Constants::MAIN_FONT);
JLBFont * f2 = resources.GetJLBFont(Constants::MAGIC_FONT);
JLBFont * f3 = resources.GetJLBFont(Constants::MENU_FONT); //OPTION_FONT
WFont * f = resources.GetWFont(Constants::MAIN_FONT);
WFont * f2 = resources.GetWFont(Constants::MAGIC_FONT);
WFont * f3 = resources.GetWFont(Constants::MENU_FONT); //OPTION_FONT
f2->SetColor(ARGB(255, 205, 237, 240));
f3->SetColor(ARGB(255, 219, 206, 151));
+3 -3
View File
@@ -1,7 +1,7 @@
#include "../include/TextScroller.h"
#include "../include/WResourceManager.h"
#include "../include/utils.h"
#include <JLBFont.h>
#include "../include/WFont.h"
TextScroller::TextScroller(int fontId, float x, float y, float width, float speed):JGuiObject(0),fontId(fontId){
mWidth = width;
@@ -35,7 +35,7 @@ void TextScroller::Update(float dt){
if(!strings.size())
return;
start+=mSpeed*dt;
JLBFont * mFont = resources.GetJLBFont(fontId);
WFont * mFont = resources.GetWFont(fontId);
if (start > mFont->GetStringWidth(mText.c_str())){
start = -mWidth;
if (mRandom){
@@ -50,7 +50,7 @@ void TextScroller::Update(float dt){
}
void TextScroller::Render(){
JLBFont * mFont = resources.GetJLBFont(fontId);
WFont * mFont = resources.GetWFont(fontId);
mFont->DrawString(mText.c_str(),mX,mY,JGETEXT_LEFT,start,mWidth);
}
+39
View File
@@ -53,6 +53,7 @@ Translator::~Translator(){
}
Translator::Translator(){
initDone = false;
neofont = false;
//init();
}
@@ -68,6 +69,10 @@ void Translator::load(string filename, map<string,string> * dictionary) {
while(std::getline(file,s)){
if (!s.size()) continue;
if (s[s.size()-1] == '\r') s.erase(s.size()-1); //Handle DOS files
//Translate '@' to '\n'
char * sp = (char *)s.c_str();
for (int i = 0; sp[i]; i++)
if (sp[i] == '@') sp[i] = '\n';
size_t found = s.find('=');
if (found == string::npos) continue;
string s1 = s.substr(0,found);
@@ -103,6 +108,33 @@ void Translator::initCards(){
load(cards_dict,&tempValues);
}
void Translator::initDecks(){
string lang = options[Options::LANG].str;
if (!lang.size()) return;
string decks_dict = "Res/lang/" + lang + "_decks.txt";
// Load file
std::ifstream file(decks_dict.c_str());
if(file){
string s;
initDone = true;
while(std::getline(file,s)){
if (!s.size()) continue;
if (s[s.size()-1] == '\r') s.erase(s.size()-1); //Handle DOS files
// Translate '@' to '\n'
char * sp = (char *)s.c_str();
for (int i = 0; sp[i]; i++)
if (sp[i] == '@') sp[i] = '\n';
size_t found = s.find('=');
if (found == string::npos) continue;
string s1 = s.substr(0,found);
string s2 = s.substr(found+1);
deckValues[s1] = s2;
}
file.close();
}
}
void Translator::init() {
#if defined DEBUG_TRANSLATE
checkMisses = 0;
@@ -112,11 +144,17 @@ void Translator::init() {
string name = "Res/lang/" + lang + ".txt";
if (fileExists(name.c_str())){
// fixup for Chinese language support.
if (lang.compare("cn") == 0)
neofont = true;
else
neofont = false;
initDone = true;
load(name,&values);
}
initCards();
initDecks();
}
@@ -125,3 +163,4 @@ string _(string toTranslate){
return t->translate(toTranslate);
}
bool neofont;
+4 -4
View File
@@ -20,7 +20,7 @@ const KeyRep& translateKey(LocalKeySym key) {
char* str = XKeysymToString(key);
if (!str)
{
str = new char[11];
str = NEW char[11];
sprintf(str, "%lu", key);
}
const KeyRep k = make_pair(str, static_cast<JQuad*>(NULL));
@@ -64,7 +64,7 @@ const KeyRep& translateKey(LocalKeySym key) {
KeyRep k;
if (0 == s.length()) {
char*str = new char[11];
char*str = NEW char[11];
sprintf(str, "%d", key);
k = make_pair(str, static_cast<JQuad*>(NULL));
}
@@ -98,7 +98,7 @@ const KeyRep& translateKey(LocalKeySym key) {
}
else
{
char* str = new char[11];
char* str = NEW char[11];
sprintf(str, "%d", key);
fattable[key] = make_pair(str, static_cast<JQuad*>(static_cast<JQuad*>(NULL)));
}
@@ -177,7 +177,7 @@ const KeyRep& translateKey(JButton key) {
}
else
{
char* str = new char[11];
char* str = NEW char[11];
sprintf(str, "%d", key);
slimtable[key] = make_pair(str, static_cast<JQuad*>(static_cast<JQuad*>(NULL)));
}
+450
View File
@@ -0,0 +1,450 @@
#include "../include/config.h"
#include "../include/WFont.h"
#include "../include/WResourceManager.h"
#include "JFileSystem.h"
#define ISGBK(c) ((c) > 0x80 || (c) < 0x20 || (c) == '-')
static PIXEL_TYPE gencolor(int id, PIXEL_TYPE color)
{
unsigned int a, r, g, b, r0, g0, b0;
#if defined (WIN32) || defined (LINUX)
a = (color >> 24) & 0xFF;
r = (color >> 16) & 0xFF;
g = (color >> 8) & 0xFF;
b = (color >> 0) & 0xFF;
#else // PSP
# if defined (ABGR8888)
a = (color >> 24) & 0xFF;
b = (color >> 16) & 0xFF;
g = (color >> 8) & 0xFF;
r = (color >> 0) & 0xFF;
# elif defined (ABGR5551)
a = ((color >> 15) & 0x01) << 7;
b = ((color >> 10) & 0x1F) << 3;
g = ((color >> 5) & 0x1F) << 3;
r = ((color >> 0) & 0x1F) << 3;
# elif defined (ABGR4444)
a = ((color >> 12) & 0x0F) << 4;
b = ((color >> 8) & 0x0F) << 4;
g = ((color >> 4) & 0x0F) << 4;
r = ((color >> 0) & 0x0F) << 4;
# endif
#endif
r0 = g0 = b0 = 255;
switch (id) {
case 0: // simon 245, 228, 156
r0 = 245; g0 = 228; b0 = 156;
break;
case 1: // f3 255, 252, 175
r0 = 255; g0 = 252; b0 = 175;
break;
case 2: // magic 219, 255, 151
r0 = 219; g0 = 255; b0 = 151;
break;
case 3: // smallface 255, 255, 255
r0 = 255; g0 = 255; b0 = 255;
break;
default:
;
}
r = r * r0 / 255;
g = g * g0 / 255;
b = b * b0 / 255;
return ARGB(a,r,g,b);
}
//
JRenderer * WFBFont::mRenderer = NULL;
WFBFont::WFBFont(const char *fontname, int lineheight, bool useVideoRAM)
{
mRenderer = JRenderer::GetInstance();
mCharBuffer = NULL;
mSprites = NULL;
mGBCode = NULL;
mCurr = 0;
char chnFileName[32], engFileName[32];
sprintf(chnFileName, "%s.gbk", fontname);
sprintf(engFileName, "%s.asc", fontname);
JFileSystem *fileSys = JFileSystem::GetInstance();
int size = 0;
if (!fileSys->OpenFile(chnFileName))
return;
size = fileSys->GetFileSize();
mChnFont = NEW BYTE[size];
fileSys->ReadFile(mChnFont, size);
fileSys->CloseFile();
if (!fileSys->OpenFile(engFileName))
return;
size = fileSys->GetFileSize();
mEngFont = NEW BYTE[size];
fileSys->ReadFile(mEngFont, size);
fileSys->CloseFile();
mColor0 = ARGB(255, 255, 255, 255);
mColor = mColor0;
mFontSize = lineheight;
mScale = 1.0f;
// using 4-bit(half-byte) to store 1 pixel
mBytesPerRow = mFontSize / 2;
mBytesPerChar = mBytesPerRow*mFontSize;
mCacheImageWidth = 256;
mCacheImageHeight = 256;
mCol = mCacheImageWidth / mFontSize;
mRow = mCacheImageHeight / mFontSize;
mCacheSize = mCol * mRow;
mSprites = NEW JQuad*[mCacheSize];
mGBCode = NEW int[mCacheSize];
#if defined (WIN32) || defined (LINUX)
mCharBuffer = NEW DWORD[mFontSize*mFontSize];
#endif
mTexture = mRenderer->CreateTexture(mCacheImageWidth, mCacheImageHeight, true);
int index = 0;
for (int y = 0; y < mRow; y++) {
for (int x = 0; x<mCol; x++) {
mGBCode[index] = -1;
mSprites[index] = NEW JQuad(mTexture, x*mFontSize, y*mFontSize, mFontSize, mFontSize);
mSprites[index]->SetHotSpot(mFontSize / 2, mFontSize / 2);
index++;
}
}
}
WFBFont::~WFBFont()
{
SAFE_DELETE(mEngFont);
SAFE_DELETE(mChnFont);
SAFE_DELETE(mTexture);
if (mSprites) {
for (int i = 0; i < mCacheSize; i++) {
if (mSprites[i])
delete mSprites[i];
}
delete [] mSprites;
}
if (mGBCode)
delete [] mGBCode;
if (mCharBuffer)
delete [] mCharBuffer;
}
#if defined (WIN32) || defined (LINUX)
#else
static void SwizzlePlot(u8* out, PIXEL_TYPE color, int i, int j, unsigned int width)
{
unsigned int rowblocks = (width >> 4);
unsigned int blockx = (i >> 4);
unsigned int blocky = (j >> 3);
unsigned int x = (i - (blockx << 4));
unsigned int y = (j - (blocky << 3));
unsigned int block_index = blockx + ((blocky) * rowblocks);
unsigned int block_address = block_index << 7;
u8* p = out + (block_address + x + (y << 4));
PIXEL_TYPE* dest = (PIXEL_TYPE *)p;
*dest = color;
}
#endif
int WFBFont::PreCacheChar(const BYTE *ch)
{
int code;
bool isChinese = true;
BYTE* src;
int size, offset;
u8 gray;
if (*ch > 0xA0 && *(ch + 1) > 0xA0)
// get offset to the proper character bits (GB2312 encoding)
code = (((DWORD)(*ch - 0xA1)) * 0x5E + ((DWORD)(*(ch + 1) - 0xA1)));
else if (*ch > 0x80) {
// get offset to the character space's bits (GBK encoding)
code = 0;
}
else {
code = ((DWORD)*ch)|0x10000;
isChinese = false;
}
if (mGBCode[mCurr] != -1) {
for (int i = 0; i < mCacheSize; i++) {
if (mGBCode[i] == code)
return i;
}
}
int index = mCurr++;
if (mCurr >= mCacheSize)
mCurr = 0;
#if defined (WIN32) || defined (LINUX)
int x = 0;
int y = 0;
memset(mCharBuffer, 0, sizeof(DWORD) * mFontSize * mFontSize);
#else
u8* pTexture = (u8*) mTexture->mBits;
int x;
int y = (int)mSprites[index]->mY;
#endif
if (isChinese) {
size = mFontSize;
src = mChnFont + code * mBytesPerChar;
offset = 0;
}
else {
size = mFontSize / 2;
src = mEngFont + (code - 0x10000) * (mFontSize * size / 2);
offset = 0;
}
// set up the font texture buffer
for (int i = 0; i < mFontSize; i++) {
#if defined (WIN32) || defined (LINUX)
x = 0;
#else
x = (int)mSprites[index]->mX;
#endif
int j = 0;
#if 1
for (; j < offset; j++) {
#if defined (WIN32) || defined (LINUX)
mCharBuffer[y * mFontSize + x] = ARGB(0, 0, 0, 0);
#else
SwizzlePlot(pTexture, ARGB(0, 0, 0, 0), x * PIXEL_SIZE, y, mTexture->mTexWidth * PIXEL_SIZE);
#endif
x++;
}
#endif
for (; j < offset + size; j++) {
// as 4-bit(half-byte) stores 1 pixel
// get out the proper data according to the even or odd quality of the counter
gray = src[(i * size + j - offset) / 2];
gray = ((j - offset) & 1) ? (gray & 0xF0) : ((gray & 0x0F) << 4);
#if defined (WIN32) || defined (LINUX)
mCharBuffer[y * mFontSize + x] = ARGB(gray, 255, 255, 255);
#else
SwizzlePlot(pTexture, ARGB(gray, 255, 255, 255), x * PIXEL_SIZE, y, mTexture->mTexWidth * PIXEL_SIZE);
#endif
x++;
}
for (; j < mFontSize; j++) {
#if defined (WIN32) || defined (LINUX)
mCharBuffer[y * mFontSize + x] = ARGB(0, 0, 0, 0);
#else
SwizzlePlot(pTexture, ARGB(0, 0, 0, 0), x * PIXEL_SIZE, y, mTexture->mTexWidth * PIXEL_SIZE);
#endif
x++;
}
y++;
}
mGBCode[index] = code;
#if defined (WIN32) || defined (LINUX)
x = (int)mSprites[index]->mX;
y = (int)mSprites[index]->mY;
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, mFontSize, mFontSize, GL_RGBA, GL_UNSIGNED_BYTE, mCharBuffer);
#else
sceKernelDcacheWritebackAll();
#endif
return index;
}
void WFBFont::DrawString(const char *s, float x, float y, int align, float leftOffset, float width)
{
unsigned char c = *(unsigned short *)s & 0xFF;
if (ISGBK(c) || (s[1] == ':' && s[2] == ' ')) {}
else {
WFont * mFont = resources.GetWLBFont(id);
mFont->SetScale(GetScale());
mFont->SetColor(GetColor());
mFont->DrawString(s, x, y, align, leftOffset, width);
return;
}
BYTE* str = (BYTE*)s;
// (0, 0) refers to the center of the word, so fix it to the upper-left corner
x += (mFontSize * mScale) / 2;
y += (mFontSize * mScale) / 2;
switch (align) {
case JGETEXT_RIGHT:
x -= GetStringWidth(s);
break;
case JGETEXT_CENTER:
x -= GetStringWidth(s) / 2;
break;
case JGETEXT_LEFT:
default:
break;
}
mRenderer->BindTexture(mTexture);
BYTE* src = str;
float xx = x;
float yy = y;
int index;
bool isChinese=true;
while (*src != 0) {
if (yy > SCREEN_HEIGHT_F) // don't render or count outside the buttom of viewport
return;
else if (yy + mFontSize < 0.0f) { // don't render when outside the top of viewport, but counted
if (*src < ' ') { // control characters
if (*src == 0x0a) { // NEWLINE
xx = x;
yy += (mFontSize*mScale);
}
src += 1;
}
else {
if (*src > 0x80) // Chinese characters (GBK encoding)
src += 2;
else
src += 1;
xx += (mFontSize*mScale);
if (xx >= 480) {
xx = x;
yy += (mFontSize*mScale);
}
}
}
else {
if (*src < ' ') { // control characters
if (*src == 0x0a) { // NEWLINE
xx = x;
yy += (mFontSize * mScale);
}
src += 1;
}
else {
if (*src > 0x80) { // Chinese characters (GBK encoding)
index = PreCacheChar(src);
src += 2;
isChinese = true;
}
else {
index = PreCacheChar(src);
src += 1;
isChinese = false;
}
// fix for leftoffset and witdth's setting
float xPos, yPos, charWidth, charHeight;
mSprites[index]->GetTextureRect(&xPos, &yPos, &charWidth, &charHeight);
float xPos0 = xPos;
float charWidth0 = charWidth;
float delta = (isChinese) ? (charWidth * mScale) : (charWidth * mScale / 2);
if (leftOffset) {
if (leftOffset < 0){
xx -= leftOffset;
leftOffset = 0;
}
else if (leftOffset - delta > 0) {
leftOffset -= delta;
continue;
}
else {
xPos += leftOffset / mScale;
delta -= leftOffset;
leftOffset = 0;
charWidth = delta / mScale;
}
}
else if (width){
if (xx > x + width)
return;
if (xx + delta > x + width) {
delta = x + width - xx;
charWidth = delta / mScale;
}
}
mSprites[index]->SetTextureRect(xPos, yPos, charWidth, charHeight);
mSprites[index]->SetColor(mColor);
mRenderer->RenderQuad(mSprites[index], xx, yy, 0, mScale, mScale);
mSprites[index]->SetTextureRect(xPos0, yPos, charWidth0, charHeight);
xx += delta;
if (xx >= 480) {
xx = x;
yy += (mFontSize * mScale);
}
}
}
}
}
void WFBFont::DrawString(std::string s, float x, float y, int align, float leftOffset, float width)
{
DrawString(s.c_str(),x,y,align,leftOffset,width);
}
void WFBFont::SetColor(PIXEL_TYPE color)
{
mColor0 = color;
mColor = gencolor(id, color);
}
float WFBFont::GetStringWidth(const char *s) const
{
unsigned char c = *(unsigned short *)s & 0xFF;
if (ISGBK(c)) {
BYTE* src = (BYTE*)s;
float xx = 0;
bool isChinese=true;
while (*src != 0) {
if (*src > 0x80) { // Chinese
src += 2;
isChinese = true;
}
else { // Non-Chinese
src += 1;
isChinese = false;
}
if (isChinese)
xx += (mFontSize * mScale);
else
xx += (mFontSize * mScale) / 2;
}
return xx;
}
else {
WFont * mFont = resources.GetWLBFont(id);
mFont->SetScale(GetScale());
return mFont->GetStringWidth(s);
}
}
void WFBFont::SetScale(float scale)
{
mScale = scale;
}
float WFBFont::GetScale() const {return mScale;}
float WFBFont::GetHeight() const {return (mFontSize * mScale);}
+11 -11
View File
@@ -65,11 +65,11 @@ void WGuiItem::Entering(JButton key){
mFocus = true;
}
float WGuiItem::minWidth(){
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT);
return mFont->GetStringWidth(_(displayValue).c_str())+4;
}
float WGuiItem::minHeight(){
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT);
return mFont->GetHeight();
}
@@ -80,7 +80,7 @@ bool WGuiItem::Leaving(JButton key){
void WGuiItem::Render(){
JRenderer * renderer = JRenderer::GetInstance();
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT);
DWORD oldcolor = mFont->GetColor();
mFont->SetColor(getColor(WGuiColor::TEXT));
float fH = (height-mFont->GetHeight())/2;
@@ -162,7 +162,7 @@ PIXEL_TYPE WDecoStyled::getColor(int type){
//WGuiHeader
void WGuiHeader::Render(){
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT);
mFont->SetColor(getColor(WGuiColor::TEXT));
JRenderer * renderer = JRenderer::GetInstance();
@@ -263,7 +263,7 @@ void WGuiList::Render(){
//List is empty.
if (!items.size() && failMsg != ""){
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT);
mFont->SetColor(getColor(WGuiColor::TEXT_FAIL));
mFont->DrawString(_(failMsg).c_str(),x+width/2, y, JGETEXT_RIGHT);
return;
@@ -401,7 +401,7 @@ string WDecoEnum::lookupVal(int value){
void WDecoEnum::Render()
{
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT);
mFont->SetColor(getColor(WGuiColor::TEXT));
JRenderer * renderer = JRenderer::GetInstance();
mFont->DrawString(_(getDisplay()).c_str(), getX() + 2, getY() + 3);
@@ -968,7 +968,7 @@ void WGuiTabMenu::Add(WGuiBase * it){
}
void WGuiTabMenu::Render(){
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT);
JRenderer * renderer = JRenderer::GetInstance();
if (!items.size())
@@ -1000,7 +1000,7 @@ void WGuiTabMenu::save(){
//WGuiAward
void WGuiAward::Overlay(){
JRenderer * r = JRenderer::GetInstance();
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT);
mFont->SetScale(.8);
mFont->SetColor(getColor(WGuiColor::TEXT));
@@ -1051,7 +1051,7 @@ void WGuiAward::Render(){
return;
JRenderer * renderer = JRenderer::GetInstance();
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT);
mFont->SetScale(1);
mFont->SetColor(getColor(WGuiColor::TEXT));
@@ -1293,7 +1293,7 @@ void WGuiListRow::Render(){
//List is empty.
if (!items.size() && failMsg != ""){
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT);
mFont->SetColor(getColor(WGuiColor::TEXT_FAIL));
mFont->DrawString(_(failMsg).c_str(),x+width/2, y, JGETEXT_RIGHT);
return;
@@ -1937,7 +1937,7 @@ void WGuiKeyBinder::Render() {
WGuiList::Render();
if (confirmMenu) {
JRenderer * renderer = JRenderer::GetInstance();
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT);
mFont->SetColor(ARGB(255, 255, 0, 0));
renderer->FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ARGB(230, 255, 240, 240));
+121 -25
View File
@@ -13,6 +13,8 @@
#include <sys/types.h>
#include <sys/stat.h>
#endif
#include "../include/WFont.h"
extern bool neofont;
int idCounter = OTHERS_OFFSET;
@@ -35,7 +37,7 @@ bool WResourceManager::RemoveOldest(){
//WResourceManager
void WResourceManager::DebugRender(){
JRenderer* renderer = JRenderer::GetInstance();
JLBFont * font = resources.GetJLBFont(Constants::MAIN_FONT);
WFont * font = resources.GetWFont(Constants::MAIN_FONT);
font->SetColor(ARGB(255,255,255,255));
if(!font || !renderer)
@@ -166,9 +168,13 @@ WResourceManager::WResourceManager(){
mQuadList.reserve(0);
mQuadMap.clear();
mFontList.clear();
mFontList.reserve(4);
mFontMap.clear();
mWFontList.clear();
mWFontList.reserve(4);
mWFontMap.clear();
mWLBFontList.clear();
mWLBFontList.reserve(4);
mWLBFontMap.clear();
psiWCache.Resize(PSI_CACHE_SIZE,20);
sampleWCache.Resize(SAMPLES_CACHE_SIZE,MAX_CACHED_SAMPLES);
@@ -181,6 +187,8 @@ WResourceManager::WResourceManager(){
WResourceManager::~WResourceManager(){
LOG("==Destroying WResourceManager==");
RemoveAll();
RemoveWFonts();
RemoveWLBFonts();
for(vector<WManagedQuad*>::iterator it=managedQuads.begin();it!=managedQuads.end();it++){
WManagedQuad* wm = *it;
@@ -782,40 +790,127 @@ int WResourceManager::fileOK(string filename, bool relative){
return result;
}
int WResourceManager::reloadJLBFonts(){
int WResourceManager::reloadWLBFonts(){
vector<string> fontNames;
vector<float> fontSizes;
fontNames.resize(mFontList.size());
fontSizes.resize(mFontList.size());
for ( map<string, int>::iterator itr = mFontMap.begin(); itr != mFontMap.end(); ++itr){
fontNames[itr->second] = itr->first;
fontSizes[itr->second] = mFontList[itr->second]->GetHeight();
}
RemoveJLBFonts();
for(size_t i = 0; i < fontNames.size(); ++i){
LoadJLBFont(fontNames[i],fontSizes[i]);
fontNames.resize(mWLBFontList.size());
fontSizes.resize(mWLBFontList.size());
for ( map<string, int>::iterator itr = mWLBFontMap.begin(); itr != mWLBFontMap.end(); ++itr){
fontNames[itr->second] = itr->first;
fontSizes[itr->second] = mWLBFontList[itr->second]->GetHeight();
}
RemoveWLBFonts();
for(size_t i = 0; i < fontNames.size(); ++i){
LoadWLBFont(fontNames[i],fontSizes[i]);
}
return 1;
}
int WResourceManager::reloadWFonts(){
//TODO: LoadWFont().
#if 0
vector<string> fontNames;
vector<float> fontSizes;
fontNames.resize(mWFontList.size());
fontSizes.resize(mWFontList.size());
for ( map<string, int>::iterator itr = mWFontMap.begin(); itr != mWFontMap.end(); ++itr){
fontNames[itr->second] = itr->first;
fontSizes[itr->second] = mWFontList[itr->second]->GetHeight();
}
RemoveWFonts();
for(size_t i = 0; i < fontNames.size(); ++i){
LoadWFont(fontNames[i],fontSizes[i]);
}
#endif
return 1;
}
JLBFont * WResourceManager::LoadJLBFont(const string &fontName, int height){
map<string, int>::iterator itr = mFontMap.find(fontName);
WFont * WResourceManager::LoadWLBFont(const string &fontName, int height) {
map<string, int>::iterator itr = mWLBFontMap.find(fontName);
if (itr != mFontMap.end()) return mFontList[itr->second];
if (itr != mWLBFontMap.end()) return mWLBFontList[itr->second];
string mFontName = fontName + ".png";
string path = graphicsFile(mFontName);
if (path.size() > 4 ) path = path.substr(0, path.size() - 4); //some stupid manipulation because of the way JLBFont works in JGE
int id = mFontList.size();
mFontList.push_back(NEW JLBFont(path.c_str(), height, true));
mFontMap[fontName] = id;
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
int id = mWLBFontList.size();
mWLBFontList.push_back(NEW WLBFont(path.c_str(), height, true));
mWLBFontMap[fontName] = id;
mWLBFontList[id]->id = id;
return mFontList[id];
return mWLBFontList[id];
}
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
return NULL;
}
void WResourceManager::RemoveWLBFonts() {
for (vector<WLBFont *>::iterator font = mWLBFontList.begin(); font != mWLBFontList.end(); ++font)
delete *font;
mWLBFontList.clear();
mWLBFontMap.clear();
}
void WResourceManager::RemoveWFonts() {
for (vector<WFont *>::iterator font = mWFontList.begin(); font != mWFontList.end(); ++font)
delete *font;
mWFontList.clear();
mWFontMap.clear();
}
void WResourceManager::autoResize(){
#if defined WIN32 || defined LINUX
@@ -840,7 +935,8 @@ JMusic * WResourceManager::ssLoadMusic(const char *fileName){
void WResourceManager::Refresh(){
//Really easy cache relinking.
reloadJLBFonts();
reloadWFonts();
reloadWLBFonts();
sampleWCache.Refresh();
textureWCache.Refresh();
psiWCache.Refresh();