summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/backgammon/aidialog.cpp44
-rw-r--r--noncore/games/backgammon/backgammon.cpp48
2 files changed, 46 insertions, 46 deletions
diff --git a/noncore/games/backgammon/aidialog.cpp b/noncore/games/backgammon/aidialog.cpp
index 9642ca5..7dfe403 100644
--- a/noncore/games/backgammon/aidialog.cpp
+++ b/noncore/games/backgammon/aidialog.cpp
@@ -1,96 +1,96 @@
#include "aidialog.h"
#include <qgroupbox.h>
AI_Dialog::AI_Dialog(QWidget* parent,const char* name,bool modal,WFlags f)
: QDialog(parent,name,modal,f)
{
setCaption("AI Configuration");
- QGroupBox* settings=new QGroupBox("Settings",this);
+ QGroupBox* settings=new QGroupBox(tr( "Settings" ),this);
settings->setGeometry(10,5,220,170);
- QLabel* rescue_label=new QLabel("<b>Rescue</b>",settings);
+ QLabel* rescue_label=new QLabel(tr( "<b>Rescue</b>" ),settings);
rescue_label->setGeometry(50,20,50,20);
rescue=new QSpinBox(0,6,1,settings);
rescue->setGeometry(100,20,40,20);
- QPushButton* rescuehelp=new QPushButton("?",settings);
+ QPushButton* rescuehelp=new QPushButton(tr( "?" ),settings);
rescuehelp->setGeometry(140,20,20,20);
connect(rescuehelp,SIGNAL(pressed()),this,SLOT(rescuehelp_pressed()));
connect(rescuehelp,SIGNAL(released()),this,SLOT(rescuehelp_released()));
- QLabel* eliminate_label=new QLabel("<b>Eliminate</b>",settings);
+ QLabel* eliminate_label=new QLabel(tr( "<b>Eliminate</b>" ),settings);
eliminate_label->setGeometry(50,40,50,20);
eliminate=new QSpinBox(0,6,1,settings);
eliminate->setGeometry(100,40,40,20);
- QPushButton* eliminatehelp=new QPushButton("?",settings);
+ QPushButton* eliminatehelp=new QPushButton(tr( "?" ),settings);
eliminatehelp->setGeometry(140,40,20,20);
connect(eliminatehelp,SIGNAL(pressed()),this,SLOT(eliminatehelp_pressed()));
connect(eliminatehelp,SIGNAL(released()),this,SLOT(eliminatehelp_released()));
- QLabel* expose_label=new QLabel("<b>Expose</b>",settings);
+ QLabel* expose_label=new QLabel(tr( "<b>Expose</b>" ),settings);
expose_label->setGeometry(50,60,50,20);
expose=new QSpinBox(0,6,1,settings);
expose->setGeometry(100,60,40,20);
- QPushButton* exposeehelp=new QPushButton("?",settings);
+ QPushButton* exposeehelp=new QPushButton(tr( "?" ),settings);
exposeehelp->setGeometry(140,60,20,20);
connect(exposeehelp,SIGNAL(pressed()),this,SLOT(exposehelp_pressed()));
connect(exposeehelp,SIGNAL(released()),this,SLOT(exposehelp_released()));
- QLabel* protect_label=new QLabel("<b>Protect</b>",settings);
+ QLabel* protect_label=new QLabel(tr( "<b>Protect</b>" ),settings);
protect_label->setGeometry(50,80,50,20);
protect=new QSpinBox(0,6,1,settings);
protect->setGeometry(100,80,40,20);
- QPushButton* protecthelp=new QPushButton("?",settings);
+ QPushButton* protecthelp=new QPushButton(tr( "?" ),settings);
protecthelp->setGeometry(140,80,20,20);
connect(protecthelp,SIGNAL(pressed()),this,SLOT(protecthelp_pressed()));
connect(protecthelp,SIGNAL(released()),this,SLOT(protecthelp_released()));
- QLabel* safe_label=new QLabel("<b>Safe</b>",settings);
+ QLabel* safe_label=new QLabel(tr( "<b>Safe</b>" ),settings);
safe_label->setGeometry(50,100,50,20);
safe=new QSpinBox(0,6,1,settings);
safe->setGeometry(100,100,40,20);
- QPushButton* safeehelp=new QPushButton("?",settings);
+ QPushButton* safeehelp=new QPushButton(tr( "?" ),settings);
safeehelp->setGeometry(140,100,20,20);
connect(safeehelp,SIGNAL(pressed()),this,SLOT(safehelp_pressed()));
connect(safeehelp,SIGNAL(released()),this,SLOT(safehelp_released()));
- QLabel* empty_label=new QLabel("<b>Empty</b>",settings);
+ QLabel* empty_label=new QLabel(tr( "<b>Empty</b>" ),settings);
empty_label->setGeometry(50,120,50,20);
empty=new QSpinBox(0,6,1,settings);
empty->setGeometry(100,120,40,20);
- QPushButton* emptyhelp=new QPushButton("?",settings);
+ QPushButton* emptyhelp=new QPushButton(tr( "?" ),settings);
emptyhelp->setGeometry(140,120,20,20);
connect(emptyhelp,SIGNAL(pressed()),this,SLOT(emptyhelp_pressed()));
connect(emptyhelp,SIGNAL(released()),this,SLOT(emptyhelp_released()));
- defaultvalues=new QPushButton("Default Values",settings);
+ defaultvalues=new QPushButton(tr( "Default Values" ),settings);
defaultvalues->setGeometry(60,140,90,20);
connect(defaultvalues,SIGNAL(clicked()),this,SLOT(setDefaultValues()));
- QGroupBox* helpbox=new QGroupBox("Help",this);
+ QGroupBox* helpbox=new QGroupBox(tr( "Help" ),this);
helpbox->setGeometry(10,185,220,90);
help=new QLabel(helpbox);
help->setGeometry(10,15,200,65);
setHelpText();
showMaximized();
}
AI_Dialog::~AI_Dialog()
{
}
void AI_Dialog::rescuehelp_pressed()
{
setHelpText("rescue");
}
void AI_Dialog::rescuehelp_released()
{
setHelpText();
}
@@ -161,51 +161,51 @@ void AI_Dialog::setAISettings(const AISettings& values)
rescue->setValue(values.rescue);
eliminate->setValue(values.eliminate);
expose->setValue(values.expose);
protect->setValue(values.protect);
safe->setValue(values.safe);
empty->setValue(values.empty);
}
AISettings AI_Dialog::getAISettings()
{
AISettings ai;
ai.rescue=rescue->value();
ai.eliminate=eliminate->value();
ai.expose=expose->value();
ai.protect=protect->value();
ai.safe= safe->value();
ai.empty=empty->value();
return ai;
}
void AI_Dialog::setHelpText(const QString& type)
{
if(type=="rescue")
{
- help->setText("Bring the pieces out of the endzone");
+ help->setText(tr( "Bring the pieces out of the endzone" ));
}
else if(type=="eliminate")
{
- help->setText("Eliminate an opponents piece");
+ help->setText(tr( "Eliminate an opponents piece" ));
}
else if(type=="expose")
{
- help->setText("Expose you own pieces.\nAfter such a move only one piece will remain in the slot");
+ help->setText(tr( "Expose you own pieces.\nAfter such a move only one piece will remain in the slot") );
}
else if(type=="protect")
{
- help->setText("Protect a single piece by\nputting another one in this slot");
+ help->setText(tr( "Protect a single piece by\nputting another one in this slot" ));
}
else if(type=="safe")
{
- help->setText("Move piece to a slot already\noccupied by the player");
+ help->setText(tr( "Move piece to a slot already\noccupied by the player" ));
}
else if(type=="empty")
{
- help->setText("Move piece to an empty slot");
+ help->setText(tr( "Move piece to an empty slot") );
}
else
{
- help->setText("Press and hold the ? buttton\nnext to a field for help");
+ help->setText(tr( "Press and hold the ? buttton\nnext to a field for help") );
}
}
diff --git a/noncore/games/backgammon/backgammon.cpp b/noncore/games/backgammon/backgammon.cpp
index c40f462..06523f1 100644
--- a/noncore/games/backgammon/backgammon.cpp
+++ b/noncore/games/backgammon/backgammon.cpp
@@ -4,49 +4,49 @@
#include "filedialog.h"
#include "playerdialog.h"
#include "rulesdialog.h"
#include "themedialog.h"
#include <qdatetime.h>
#include <qfile.h>
#include <qlayout.h>
#include <qmessagebox.h>
#include <qstring.h>
#include <qtimer.h>
#include <qmainwindow.h>
#include <qpe/qpeapplication.h>
#include <qpe/config.h>
#include <qpe/qpemenubar.h>
#include <qpe/resource.h>
#include <stdlib.h>
BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl)
: QMainWindow(parent, name, fl)
{
if (!name) setName("BackGammon");
- setCaption("Backgammon");
+ setCaption(tr( "Backgammon") );
setIcon( Resource::loadPixmap( "backgammon" ) );
//general counter varaible
int a=0;
//the game engine
move=new MoveEngine();
//load the default theme
Config conf("backgammon");
if(!conf.isValid())
{
qDebug("config file does not exist");
conf.setGroup("general");
conf.writeEntry("theme","default");
conf.setGroup("rules");
conf.writeEntry("move_with_pieces_out",false);
conf.writeEntry("nice_dice",false);
conf.setGroup("display");
conf.writeEntry("small",false);
conf.writeEntry("warning",true);
conf.setGroup("ai");
conf.writeEntry("rescue",6);
conf.writeEntry("eliminate",4);
conf.writeEntry("expose",1);
conf.writeEntry("protect",5);
@@ -84,72 +84,72 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl)
qDebug("theme file does not exist");
theme.setGroup("theme");
theme.writeEntry("board","casino_board_1");
theme.writeEntry("pieces1","casino_pieces_blue");
theme.writeEntry("pieces2","casino_pieces_white");
theme.writeEntry("dice1","casino_dice");
theme.writeEntry("dice2","casino_dice");
theme.writeEntry("table","casino_table_green");
theme.writeEntry("odds","casino_odds");
}
theme.setGroup("theme");
board_name=theme.readEntry("board","casino_board_1");
piecesA_name=theme.readEntry("pieces1","casino_pieces_blue");
piecesB_name=theme.readEntry("pieces2","casino_pieces_white");
diceA_name=theme.readEntry("dice1","casino_dice");
diceB_name=theme.readEntry("dice2","casino_dice");
table_name=theme.readEntry("table","casino_table_green");
odds_name=theme.readEntry("odds","casino_odds");
//the menu
QPEMenuBar* menuBar = new QPEMenuBar(this);
QPopupMenu* gamemenu= new QPopupMenu(this);
- gamemenu->insertItem("New",this,SLOT(newgame()));
+ gamemenu->insertItem(tr( "New" ),this,SLOT(newgame()));
gamemenu->insertSeparator();
- gamemenu->insertItem("Load",this,SLOT(loadgame()));
- gamemenu->insertItem("Save",this,SLOT(savegame()));
+ gamemenu->insertItem(tr( "Load" ),this,SLOT(loadgame()));
+ gamemenu->insertItem(tr( "Save" ),this,SLOT(savegame()));
gamemenu->insertSeparator();
- gamemenu->insertItem("Delete",this,SLOT(deletegame()));
- menuBar->insertItem("Game",gamemenu);
+ gamemenu->insertItem(tr( "Delete" ),this,SLOT(deletegame()));
+ menuBar->insertItem(tr( "Game" ),gamemenu);
QPopupMenu* thememenu= new QPopupMenu(this);
- thememenu->insertItem("New",this,SLOT(newtheme()));
+ thememenu->insertItem(tr( "New" ),this,SLOT(newtheme()));
thememenu->insertSeparator();
- thememenu->insertItem("Load",this,SLOT(loadtheme()));
- thememenu->insertItem("Save",this,SLOT(savetheme()));
+ thememenu->insertItem(tr( "Load"),this,SLOT(loadtheme()));
+ thememenu->insertItem(tr( "Save" ),this,SLOT(savetheme()));
thememenu->insertSeparator();
- thememenu->insertItem("Default",this,SLOT(themedefault()));
- thememenu->insertItem("Delete",this,SLOT(deletetheme()));
- menuBar->insertItem("Theme",thememenu);
+ thememenu->insertItem(tr( "Default"),this,SLOT(themedefault()));
+ thememenu->insertItem(tr( "Delete" ),this,SLOT(deletetheme()));
+ menuBar->insertItem(tr( "Theme" ),thememenu);
QPopupMenu* optionmenu=new QPopupMenu(this);
- optionmenu->insertItem("Player",this,SLOT(playerselect()));
+ optionmenu->insertItem(tr( "Player" ),this,SLOT(playerselect()));
optionmenu->insertSeparator();
- optionmenu->insertItem("AI",this,SLOT(modify_AI()));
- optionmenu->insertItem("Rules",this,SLOT(setrules()));
- menuBar->insertItem("Options",optionmenu);
+ optionmenu->insertItem(tr( "AI" ),this,SLOT(modify_AI()));
+ optionmenu->insertItem(tr( "Rules" ),this,SLOT(setrules()));
+ menuBar->insertItem(tr( "Options"),optionmenu);
QWidget* mainarea=new QWidget(this);
setCentralWidget(mainarea);
//the main area
QBoxLayout* layout=new QBoxLayout(mainarea,QBoxLayout::TopToBottom);
area=new QCanvas(235,235);
boardview=new BackGammonView(area,mainarea);
boardview->setMaximumHeight(240);
layout->addWidget(boardview);
connect(boardview,SIGNAL(mouse(int,int)),this,SLOT(mouse(int,int)));
//status bar
message=new QLabel("<b>Backgammon</b>",mainarea);
message->setAlignment(AlignHCenter);
layout->addWidget(message);
//the marker
marker_current=new QCanvasRectangle(area);
marker_current->setBrush(QColor(0,0,255));
marker_current->setSize(15,5);
marker_current->setZ(1);
for(a=0;a<4;a++)
{
marker_next[a]=new QCanvasRectangle(area);
@@ -489,78 +489,78 @@ void BackGammon::savetheme()
theme.writeEntry("table",table_name);
theme.writeEntry("odds",odds_name);
}
void BackGammon::themedefault()
{
if(QMessageBox::information(this,"Backgammon","Make Theme\n"+theme_name+"\nthe default theme","Yes","No"))
return;
Config conf("backgammon");
conf.setGroup("general");
conf.writeEntry("theme",theme_name);
}
void BackGammon::deletetheme()
{
FileDialog* file=new FileDialog(this,"Delete Theme",".theme");
if(!file->exec())
return;
theme_name=file->filename();
QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme";
- if(!QMessageBox::warning(this,"Backgammon","deleted theme "+theme_name+" ?","OK","Cancel"))
+ if(!QMessageBox::warning(this,tr( "Backgammon" ),tr( "deleted theme %1?").arg(theme_name),tr( "OK" ),tr( "Cancel" )))
{
QFile(theme_file).remove();
}
}
void BackGammon::modify_AI()
{
- AI_Dialog* ai_mod=new AI_Dialog(this,"Load Theme",".theme");
+ AI_Dialog* ai_mod=new AI_Dialog(this,tr( "Load Theme" ),".theme");
ai_mod->setAISettings(move->getAISettings());
if(!ai_mod->exec())
return;
//get the AI settings
AISettings ai=ai_mod->getAISettings();
move->setAISettings(ai);
//write new settings to conf file
Config conf("backgammon");
conf.setGroup("ai");
conf.writeEntry("rescue",ai.rescue);
conf.writeEntry("eliminate",ai.eliminate);
conf.writeEntry("expose",ai.expose);
conf.writeEntry("protect",ai.protect);
conf.writeEntry("safe",ai.safe);
conf.writeEntry("empty",ai.empty);
}
void BackGammon::setrules()
{
- RulesDialog* rulesdialog=new RulesDialog(this,"Load Theme",".theme");
+ RulesDialog* rulesdialog=new RulesDialog(this,tr( "Load Theme" ),".theme");
rulesdialog->setRules(rules);
if(!rulesdialog->exec())
return;
rules=rulesdialog->getRules();
Config conf("backgammon");
conf.setGroup("rules");
conf.writeEntry("move_with_pieces_out",rules.move_with_pieces_out);
conf.writeEntry("nice_dice",rules.generous_dice);
move->setRules(rules);
}
void BackGammon::draw()
{
Pieces pieces;
move->position(pieces);
for(int a=0;a<15;a++)
{
if(!pieces.player1[a].side)
{
p1[a]->setX(pieces.player1[a].x);
p1[a]->setY(pieces.player1[a].y);
p1[a]->setZ(pieces.player1[a].z);
p1[a]->show();
@@ -778,87 +778,87 @@ void BackGammon::done_dice4()
showdice();
draw();
area->update();
if(!dice1_played || !dice2_played || !dice3_played)
{
if(player==1)
{
move->diceroll(1,diceA1_value,diceA2_value,diceA3_value,diceA4_value,player1_auto);
}
else
{
move->diceroll(2,diceB1_value,diceB2_value,diceB3_value,diceB4_value,player2_auto);
}
}
}
void BackGammon::nomove()
{
if(player==1)
nomove_marker->setX(0);
else
nomove_marker->setX(170);
nomove_marker->show();
- message->setText("<b>no move</b>");
+ message->setText(tr( "<b>no move</b>" ));
dice1_played=true;
dice2_played=true;
dice3_played=true;
dice4_played=true;
if(player==1)
{
diceA1_value=7;
diceA2_value=7;
diceA3_value=7;
diceA4_value=7;
}
else
{
diceB1_value=7;
diceB2_value=7;
diceB3_value=7;
diceB4_value=7;
}
area->update();
QTimer::singleShot(2000,this,SLOT(nomove2()));
}
void BackGammon::nomove2()
{
nomove_marker->hide();
setplayer();
showdice();
draw();
area->update();
}
void BackGammon::finished(int theplayer)
{
nomove_marker->hide();
if(theplayer==1)
- message->setText("<b>Player 1 wins. Click on board for new game.</b>");
+ message->setText(tr( "<b>Player 1 wins. Click on board for new game.</b>" ));
else
- message->setText("<b>Player 2 wins. Click on board for new game.</b>");
+ message->setText(tr( "<b>Player 2 wins. Click on board for new game.</b>" ));
diceA1_value=7;
diceA2_value=7;
diceB1_value=7;
diceB2_value=7;
player=0;
showdice();
draw();
area->update();
gameFinished=true;
}
void BackGammon::showdice()
{
int value_diceA1=diceA1_value-1;
if(diceA1_value==7 && diceA3_value!=7)
value_diceA1=diceA3_value-1;
int value_diceA2=diceA2_value-1;
if(diceA2_value==7 && diceA4_value!=7)
value_diceA2=diceA4_value-1;
int value_diceB1=diceB1_value-1;
if(diceB1_value==7 && diceB3_value!=7)
value_diceB1=diceB3_value-1;
@@ -874,57 +874,57 @@ void BackGammon::showdice()
else
diceA1[index]->hide();
if(value_diceA2==index)
diceA2[index]->show();
else
diceA2[index]->hide();
if(value_diceB1==index)
diceB1[index]->show();
else
diceB1[index]->hide();
if(value_diceB2==index)
diceB2[index]->show();
else
diceB2[index]->hide();
}
}
void BackGammon::setplayer()
{
if(dice1_played && dice2_played && dice3_played && dice4_played && player==1)
{
- message->setText("<b>P2 turn</b>");
+ message->setText(tr( "<b>P2 turn</b>", "P means player" ));
dice_rolled=false;
player=2;
if(player2_auto)
QTimer::singleShot(2000,this,SLOT(autoroll_dice2()));
}
else if(dice1_played && dice2_played && dice3_played && dice4_played && player==2)
{
- message->setText("<b>P1 turn</b>");
+ message->setText(tr( "<b>P1 turn</b>", "P means player" ));
dice_rolled=false;
player=1;
if(player1_auto)
QTimer::singleShot(2000,this,SLOT(autoroll_dice1()));
}
}
void BackGammon::autoroll_dice1()
{
mouse(20,210);
}
void BackGammon::autoroll_dice2()
{
mouse(170,210);
}
void BackGammon::applytheme()
{
QImage boardbg(Resource::loadImage("backgammon/boards/"+board_name));
board->setImage(boardbg);
QImage tablebg(Resource::loadImage("backgammon/table/"+table_name));
table->setImage(tablebg);