* ostream printing of JGui objects.
This commit is contained in:
jean.chalard
2009-05-23 08:34:50 +00:00
parent 215e23a975
commit dd054c4963
32 changed files with 1505 additions and 528 deletions

View File

@@ -7,8 +7,8 @@
#include "../include/GameObserver.h"
#include "../include/Damage.h"
#include "../include/ManaCost.h"
#include "../include/GameOptions.h"
// WALDORF - added to support drawing big cards during interrupts
#include "../include/GameOptions.h"
// WALDORF - added to support drawing big cards during interrupts
#include "../include/CardGui.h"
#include "../include/Translate.h"
@@ -38,6 +38,11 @@ NextGamePhase::NextGamePhase(int id): Interruptible(id){
type = ACTION_NEXTGAMEPHASE;
}
ostream& NextGamePhase::toString(ostream& out) const
{
out << "NextGamePhase ::: ";
return out;
}
/* Ability */
int StackAbility::resolve(){
@@ -64,6 +69,11 @@ StackAbility::StackAbility(int id,MTGAbility * _ability): Interruptible(id),abil
type=ACTION_ABILITY;
}
ostream& StackAbility::toString(ostream& out) const
{
out << "StackAbility ::: ability : " << ability;
return out;
}
/* Spell Cast */
@@ -121,36 +131,36 @@ void Spell::Render(){
}else{
//
}
// WALDORF - added these lines to render a big card as well as the small one
// in the interrupt window. A big card will be rendered no matter whether
// the user has been using big cards or not. However, I do take into which
// kind of big card they like.
// The card will be rendered in the same place as the GuiHand
// card. It doesn't attempt to hide the GUIHand card, it
// just overwrites it.
// I stole the render code from RenderBig() in CardGUI.cpp
quad = source->getQuad();
if (quad){
quad->SetColor(ARGB(220,255,255,255));
float scale = 257.f / quad->mHeight;
renderer->RenderQuad(quad, 10 , 20 , 0.0f,scale,scale);
}
else
{
MTGCard * mtgcard = source->model;
JLBFont * font = GameApp::CommonRes->GetJLBFont("graphics/magic");
CardGui::alternateRender(mtgcard, NULL, 10 + 90 , 20 + 130, 0.0f,0.9f);
quad = source->getThumb();
if (quad){
float scale = 250 / quad->mHeight;
quad->SetColor(ARGB(40,255,255,255));
renderer->RenderQuad(quad, 20, 20, 0.0f, scale, scale);
}
}
// WALDORF - end
// WALDORF - added these lines to render a big card as well as the small one
// in the interrupt window. A big card will be rendered no matter whether
// the user has been using big cards or not. However, I do take into which
// kind of big card they like.
// The card will be rendered in the same place as the GuiHand
// card. It doesn't attempt to hide the GUIHand card, it
// just overwrites it.
// I stole the render code from RenderBig() in CardGUI.cpp
quad = source->getQuad();
if (quad){
quad->SetColor(ARGB(220,255,255,255));
float scale = 257.f / quad->mHeight;
renderer->RenderQuad(quad, 10 , 20 , 0.0f,scale,scale);
}
else
{
MTGCard * mtgcard = source->model;
JLBFont * font = GameApp::CommonRes->GetJLBFont("graphics/magic");
CardGui::alternateRender(mtgcard, NULL, 10 + 90 , 20 + 130, 0.0f,0.9f);
quad = source->getThumb();
if (quad){
float scale = 250 / quad->mHeight;
quad->SetColor(ARGB(40,255,255,255));
renderer->RenderQuad(quad, 20, 20, 0.0f, scale, scale);
}
}
// WALDORF - end
Damageable * target = getNextDamageableTarget();
@@ -167,6 +177,12 @@ void Spell::Render(){
}
}
ostream& Spell::toString(ostream& out) const
{
out << "Spell ::: cost : " << cost;
return out;
}
/* Put a card in graveyard */
@@ -206,6 +222,11 @@ void PutInGraveyard::Render(){
}
}
ostream& PutInGraveyard::toString(ostream& out) const
{
out << "PutInGraveyard ::: removeFromGame : " << removeFromGame;
return out;
}
/* Draw a Card */
DrawAction::DrawAction(int id, Player * _player, int _nbcards):Interruptible(id), nbcards(_nbcards), player(_player){
@@ -229,6 +250,12 @@ void DrawAction::Render(){
mFont->DrawString(buffer, x + 20 , y, JGETEXT_LEFT);
}
ostream& DrawAction::toString(ostream& out) const
{
out << "DrawAction ::: nbcards : " << nbcards << " ; player : " << player;
return out;
}
/* The Action Stack itself */
int ActionStack::addPutInGraveyard(MTGCardInstance * card){
PutInGraveyard * death = NEW PutInGraveyard(mCount,card);
@@ -445,11 +472,11 @@ void ActionStack::unpackDamageStacks(){
}
void ActionStack::repackDamageStacks(){
std::vector<JGuiObject *>::iterator iter = mObjects.begin() ;
while( iter != mObjects.end() ){
Interruptible * action = ((Interruptible *) *iter);
int found = 0;
std::vector<JGuiObject *>::iterator iter = mObjects.begin() ;
while( iter != mObjects.end() ){
Interruptible * action = ((Interruptible *) *iter);
int found = 0;
if (action->type == ACTION_DAMAGE){
Damage * damage = (Damage *) action;
for (int j = 0; j < mCount; j++){
@@ -467,8 +494,8 @@ void ActionStack::repackDamageStacks(){
}
}
}
}
if (!found) ++iter;
}
if (!found) ++iter;
}
/*
@@ -562,13 +589,13 @@ void ActionStack::Update(float dt){
GuiLayer::Update(dt);
}
if (askIfWishesToInterrupt){
// WALDORF - added code to use a game option setting to determine how
// long the Interrupt timer should be. If it is set to zero (0), the
// game will wait for ever for the user to make a selection.
if (GameOptions::GetInstance()->values[OPTIONS_INTERRUPT_SECONDS].getIntValue() > 0)
{
if (timer < 0) timer = GameOptions::GetInstance()->values[OPTIONS_INTERRUPT_SECONDS].getIntValue();
timer -= dt;
// WALDORF - added code to use a game option setting to determine how
// long the Interrupt timer should be. If it is set to zero (0), the
// game will wait for ever for the user to make a selection.
if (GameOptions::GetInstance()->values[OPTIONS_INTERRUPT_SECONDS].getIntValue() > 0)
{
if (timer < 0) timer = GameOptions::GetInstance()->values[OPTIONS_INTERRUPT_SECONDS].getIntValue();
timer -= dt;
if (timer < 0) cancelInterruptOffer();
}
}
@@ -686,17 +713,17 @@ int ActionStack::CombatDamages(int strike){
//Cleans history of last turn
int ActionStack::garbageCollect(){
std::vector<JGuiObject *>::iterator iter = mObjects.begin() ;
while( iter != mObjects.end() ){
Interruptible * current = ((Interruptible *) *iter);
if (current->state != NOT_RESOLVED){
iter = mObjects.erase( iter ) ;
std::vector<JGuiObject *>::iterator iter = mObjects.begin() ;
while( iter != mObjects.end() ){
Interruptible * current = ((Interruptible *) *iter);
if (current->state != NOT_RESOLVED){
iter = mObjects.erase( iter ) ;
mCount--;
SAFE_DELETE(current);
}else {
++iter ;
}
SAFE_DELETE(current);
}else {
++iter ;
}
}
return 1;
}
@@ -756,26 +783,26 @@ void ActionStack::Render(){
}
char buffer[200];
// WALDORF - changed "interrupt ?" to "Interrupt?". Don't display count down
// seconds if the user disables auto progressing interrupts by setting the seconds
// value to zero in Options.
if (GameOptions::GetInstance()->values[OPTIONS_INTERRUPT_SECONDS].getIntValue() == 0)
sprintf(buffer, _("Interrupt?").c_str());
else
sprintf(buffer, "%s %i", _("Interrupt?").c_str(),static_cast<int>(timer));
//WALDORF - removed all the unnecessary math. just display the prompt at the
// top of the box.
//mFont->DrawString(buffer, x0 + 5 , currenty - 40 - ((Interruptible *)mObjects[mCount-1])->mHeight);
mFont->DrawString(buffer, x0 + 5, y0);
if (mCount > 1) sprintf(buffer, _("X Interrupt - 0 No - [] No to All").c_str());
else sprintf(buffer, _("X Interrupt - 0 No").c_str());
// WALDORF - puts the button legend right under the prompt. the stack
// will be displayed below it now. no more need to do wierd currY math.
//mFont->DrawString(buffer, x0 + 5 , currenty);
// WALDORF - changed "interrupt ?" to "Interrupt?". Don't display count down
// seconds if the user disables auto progressing interrupts by setting the seconds
// value to zero in Options.
if (GameOptions::GetInstance()->values[OPTIONS_INTERRUPT_SECONDS].getIntValue() == 0)
sprintf(buffer, _("Interrupt?").c_str());
else
sprintf(buffer, "%s %i", _("Interrupt?").c_str(),static_cast<int>(timer));
//WALDORF - removed all the unnecessary math. just display the prompt at the
// top of the box.
//mFont->DrawString(buffer, x0 + 5 , currenty - 40 - ((Interruptible *)mObjects[mCount-1])->mHeight);
mFont->DrawString(buffer, x0 + 5, y0);
if (mCount > 1) sprintf(buffer, _("X Interrupt - 0 No - [] No to All").c_str());
else sprintf(buffer, _("X Interrupt - 0 No").c_str());
// WALDORF - puts the button legend right under the prompt. the stack
// will be displayed below it now. no more need to do wierd currY math.
//mFont->DrawString(buffer, x0 + 5 , currenty);
mFont->DrawString(buffer, x0 + 5, y0 + 14);
}else if (mode == ACTIONSTACK_TARGET && modal){
for (int i=0;i<mCount ;i++){