Esempio n. 1
0
/** Convert an integer into a string representing its hexadecimal value
  *
  * \param vInt  The integer to stringify
  * \param vBase How many characters in the binary string.
  *              Should be 1, 2, 4 or 8
  *
  */
std::string RainbruRPG::Core::StringConv::
itobin(int vInt, const int vBase){
  string out;

  // Using if...else statemenst instead of case to avoid cross 
  // initializations

  // We also need to use a different bitset for each case because
  // the argument of a template cannot be a variable

  if (vBase==1){
     bitset<1> num1(vInt);
     out+=BITSET_STR(num1);
  }
  else if (vBase==2){
     bitset<2> num2(vInt);
     out+=BITSET_STR(num2);
  }
  else if (vBase==4){
     bitset<4> num4(vInt);
     out+=BITSET_STR(num4);
  }
  else if (vBase==8){
     bitset<8> num8(vInt);
     out+=BITSET_STR(num8);
  }
  else{
    LOGW(_("StringConv::itobin base parameter unrecognized"));

  }

  return out;
}
NewGameDialog::NewGameDialog(int row,int col,int num, QWidget *parent):QDialog(parent){
    this->p1="Human";
    this->p2="Human";
    this->setupUi(this);
    connect(this->player1ComboBox,SIGNAL(activated(QString)),this,SLOT(selectPlayer1(QString)));
    connect(this->player2ComboBox,SIGNAL(activated(QString)),this,SLOT(selectPlayer2(QString)));
    this->selectPlayerGroupBox->hide();
    this->serverGroupBox->hide();
    QRegExp num2("[0-9]{0,2}"),num4("[0-9]{0,4}");
    this->rowText->setValidator(new QRegExpValidator(num2,this));
    this->columnText->setValidator(new QRegExpValidator(num2,this));
    this->mineText->setValidator(new QRegExpValidator(num4,this));
    this->serverAddress->setText(lastIP);
    this->portNumber->setText(lastPort);
    if(row!=-1 && col!=-1 && num!=-1){
        this->rowText->setText(qstr(row));
        this->columnText->setText(qstr(col));
        this->mineText->setText(qstr(num));
    }
}