void LLPrefsIMImpl::setPersonalInfo( const std::string& visibility, bool im_via_email, const std::string& email) { mGotPersonalInfo = true; mOriginalIMViaEmail = im_via_email; mDirectoryVisibility = visibility; if(visibility == VISIBILITY_DEFAULT) { mOriginalHideOnlineStatus = false; childEnable("online_visibility"); } else if(visibility == VISIBILITY_HIDDEN) { mOriginalHideOnlineStatus = true; childEnable("online_visibility"); } else { mOriginalHideOnlineStatus = true; } childSetValue("online_visibility", mOriginalHideOnlineStatus); childSetLabelArg("online_visibility", "[DIR_VIS]", mDirectoryVisibility); childEnable("send_im_to_email"); childSetValue("send_im_to_email", im_via_email); childEnable("log_instant_messages"); childEnable("log_chat"); childEnable("busy_response"); //MK if (RRenabled && gAgent.mRRInterface.contains ("sendim")) { childDisable("busy_response"); } //mk childEnable("log_instant_messages_timestamp"); childEnable("log_chat_timestamp"); childEnable("log_chat_IM"); childEnable("log_date_timestamp"); //RN: get wide string so replace char can work (requires fixed-width encoding) LLWString busy_response = utf8str_to_wstring( gSavedPerAccountSettings.getString("BusyModeResponse") ); LLWString::replaceChar(busy_response, '^', '\n'); LLWString::replaceChar(busy_response, '%', ' '); childSetText("busy_response", wstring_to_utf8str(busy_response)); enableHistory(); // Truncate the e-mail address if it's too long (to prevent going off // the edge of the dialog). std::string display_email(email); if(display_email.size() > 30) { display_email.resize(30); display_email += "..."; } childSetLabelArg("send_im_to_email", "[EMAIL]", display_email); }
void GUI::sLoadGame() { QFileDialog dialog(this, tr("Load saved game")); if(dialog.exec() != QDialog::Accepted) return; if(game != nullptr) { delete game; game = nullptr; } try { game = new Game(dialog.selectedFiles().first().toStdString()); enableHistory(); drawBoard(); } catch(std::exception &e) { QMessageBox::critical(this, QGuiApplication::applicationDisplayName(), tr("Couldn't load saved game from %1\nReason: %2").arg( dialog.selectedFiles().first()).arg(e.what())); } }
void GUI::sNewGame() { QDialog dialog; QVBoxLayout *mainLayout = new QVBoxLayout(&dialog); int AIalgorithmCount = AI::getAlgorithmCount(); pobj.clear(); QGroupBox *sizes = new QGroupBox(tr("Board size")); QGridLayout *sizesLayout = new QGridLayout; QComboBox *sizesList = new QComboBox; for(auto s : Board::SIZES) { QString ss = QString::number(s); sizesList->addItem(ss + " x " + ss); } sizesLayout->addWidget(sizesList); sizes->setLayout(sizesLayout); mainLayout->addWidget(sizes); QGroupBox *algo = new QGroupBox(tr("AI algorithms")); QGridLayout *algoLayout = new QGridLayout; algoList = new QComboBox; for(int i = 0; i < AIalgorithmCount; i++) { algoList->addItem(tr("Algorithm %1").arg(i + 1)); } algoList->setEnabled(false); algoLayout->addWidget(algoList); algo->setLayout(algoLayout); mainLayout->addWidget(algo); for(int i = 0; i < 2; i++) { QGridLayout *innerLayout = new QGridLayout; QGroupBox *gb = new QGroupBox(tr("Player %1").arg(i + 1)); QLabel *nameLabel = new QLabel(tr("Name:")); QLineEdit *nameEdit = new QLineEdit; nameEdit->setMaxLength(12); innerLayout->addWidget(nameLabel, 0, 0); innerLayout->addWidget(nameEdit, 0, 1, 1, 2); QLabel *typeLabel = new QLabel(tr("Type:")); QRadioButton *human = new QRadioButton(tr("Human")); QRadioButton *ai = new QRadioButton(tr("AI")); connect(ai, SIGNAL(toggled(bool)), this, SLOT(sCheckAIButtons(bool))); human->setChecked(true); innerLayout->addWidget(typeLabel, 1, 0); innerLayout->addWidget(human, 1, 1); innerLayout->addWidget(ai, 1, 2); pobj.push_back(PlayerObjects(nameEdit, human, ai)); gb->setLayout(innerLayout); mainLayout->addWidget(gb); } QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok| QDialogButtonBox::Cancel); connect(buttons, SIGNAL(accepted()), &dialog, SLOT(accept())); connect(buttons, SIGNAL(rejected()), &dialog, SLOT(reject())); mainLayout->addWidget(buttons); dialog.setLayout(mainLayout); dialog.setModal(true); if(dialog.exec() != QDialog::Accepted || pobj.size() != 2) return; if(game != nullptr) { delete game; game = nullptr; } // Get board size from list index try { std::set<int>::iterator it = Board::SIZES.begin(); std::advance(it, sizesList->currentIndex()); game = new Game(*it); } catch(const std::exception &e) { QMessageBox::critical(this, QGuiApplication::applicationDisplayName(), tr("Couldn't create game board: ").arg(e.what())); return; } const Player *p; for(auto player : pobj) { if(player.human->isChecked()) { game->addPlayer(player.name->text().toStdString()); } else { p = game->addPlayer(player.name->text().toStdString(), Player::AI); ((AI*)p)->setAlgorithm(algoList->currentIndex()); } } game->initGame(); enableHistory(); drawBoard(); }
void LLPrefsIMImpl::setPersonalInfo(const std::string& visibility, bool im_via_email, const std::string& email) { mGotPersonalInfo = true; mOriginalIMViaEmail = im_via_email; mDirectoryVisibility = visibility; if(visibility == VISIBILITY_DEFAULT) { mOriginalHideOnlineStatus = false; childEnable("online_visibility"); } else if(visibility == VISIBILITY_HIDDEN) { mOriginalHideOnlineStatus = true; childEnable("online_visibility"); } else { mOriginalHideOnlineStatus = true; } childEnable("include_im_in_chat_console"); childEnable("include_im_in_chat_history"); childEnable("show_timestamps_check"); childEnable("friends_online_notify_checkbox"); childSetValue("online_visibility", mOriginalHideOnlineStatus); childSetLabelArg("online_visibility", "[DIR_VIS]", mDirectoryVisibility); childEnable("send_im_to_email"); childSetValue("send_im_to_email", im_via_email); childEnable("log_instant_messages"); childEnable("log_chat"); childEnable("busy_response"); childEnable("log_instant_messages_timestamp"); childEnable("log_chat_timestamp"); childEnable("log_chat_IM"); childEnable("log_date_timestamp"); childEnable("logfile_name_datestamp"); //RN: get wide string so replace char can work (requires fixed-width encoding) LLWString busy_response = utf8str_to_wstring( gSavedPerAccountSettings.getString("BusyModeResponse") ); LLWStringUtil::replaceChar(busy_response, '^', '\n'); LLWStringUtil::replaceChar(busy_response, '%', ' '); childSetText("busy_response", wstring_to_utf8str(busy_response)); // [RLVa:KB] - Checked: 2009-07-10 (RLVa-1.0.0g) if (gRlvHandler.hasBehaviour(RLV_BHVR_SENDIM)) { childDisable("busy_response"); } // [/RLVa:KB] enableHistory(); // Truncate the e-mail address if it's too long (to prevent going off // the edge of the dialog). std::string display_email(email); if(display_email.size() > 30) { display_email.resize(30); display_email += "..."; } childSetLabelArg("send_im_to_email", "[EMAIL]", display_email); }