Example #1
0
K3Wizard::K3Wizard( QWidget *parent, const char *name, bool modal, Qt::WFlags f )
            : Q3Wizard( parent, name, modal, f )
{
  bool useIcons = KGlobalSettings::showIconsOnPushButtons();

  if ( useIcons )
  {
    KGuiItem back = KStandardGuiItem::back( KStandardGuiItem::UseRTL );
    KGuiItem forward = KStandardGuiItem::forward( KStandardGuiItem::UseRTL );

    backButton()->setIcon( back.icon() );
    nextButton()->setIcon( forward.icon() );

    finishButton()->setIcon( KIcon( "dialog-ok-apply" ) );
    cancelButton()->setIcon( KIcon( "dialog-cancel" ) );
    helpButton()->setIcon( KIcon( "help-contents" ) );

    backButton()->setText( i18n( "&Back" ) );
    nextButton()->setText( i18nc( "Opposite to Back","&Next" ) );
  }

  QFont font = titleFont();
  font.setBold( true );
  setTitleFont( font );
}
Example #2
0
KWizard::KWizard( QWidget *parent, const char *name, bool modal, WFlags f )
            : QWizard( parent, name, modal, f )
{
  bool useIcons = KGlobalSettings::showIconsOnPushButtons();

  if ( useIcons )
  {
    KGuiItem back = KStdGuiItem::back( KStdGuiItem::UseRTL );
    KGuiItem forward = KStdGuiItem::forward( KStdGuiItem::UseRTL );

    backButton()->setIconSet( back.iconSet() );
    nextButton()->setIconSet( forward.iconSet() );

    finishButton()->setIconSet( SmallIconSet( "apply" ) );
    cancelButton()->setIconSet( SmallIconSet( "button_cancel" ) );
    helpButton()->setIconSet( SmallIconSet( "help" ) );

    backButton()->setText( i18n( "&Back" ) );
    nextButton()->setText( i18n( "Opposite to Back","&Next" ) );
  }

  QFont font = titleFont();
  font.setBold( true );
  setTitleFont( font );
}
Example #3
0
levelChooser::levelChooser(QWidget *parent) : QWidget(parent) {
   dSelected = false;
   diffSelector = new difficultySelector(this);
   levSelector = new levelSelector(this);
   connect(diffSelector, SIGNAL(difficultySelected(int)), levSelector, SLOT(difficultySelected(int)));
   connect(diffSelector, SIGNAL(difficultySelected(int)), this, SLOT(diffSelected(int)));
   connect(levSelector, SIGNAL(levelSelected(QString)), this, SIGNAL(levelSelected(QString)));
   connect(levSelector, SIGNAL(reset()), this, SLOT(reset()));
   
   connect(levSelector, SIGNAL(backButton()), this, SLOT(backButton()));
   showHide();
}
void ReportAssistantDialog::currentPageChanged_slot(KPageWidgetItem * current , KPageWidgetItem * before)
{
    //Page changed
    buttonBox()->button(QDialogButtonBox::Cancel)->setEnabled(true);
    m_canClose = false;

    //Save data of the previous page
    if (before) {
        ReportAssistantPage* beforePage = dynamic_cast<ReportAssistantPage*>(before->widget());
        beforePage->aboutToHide();
    }

    //Load data of the current(new) page
    if (current) {
        ReportAssistantPage* currentPage = dynamic_cast<ReportAssistantPage*>(current->widget());
        nextButton()->setEnabled(currentPage->isComplete());
        currentPage->aboutToShow();
    }

    //If the current page is the last one, disable all the buttons until the bug is sent
    if (current->name() == QLatin1String(PAGE_BZSEND_ID)) {
        nextButton()->setEnabled(false);
        backButton()->setEnabled(false);
        finishButton()->setEnabled(false);
    }
}
void ConnectionWizard::setState(bool patch, bool end, bool back, bool next, bool finish)
{
	setAppropriate(pagePatch, patch ? true : false);
	setAppropriate(pageEnd, end ? true : false);
	
	backButton()->setEnabled(back ? true : false);
	nextButton()->setEnabled(next ? true : false);
	finishButton()->setEnabled(finish ? true : false);
}
void ReportAssistantDialog::assistantFinished(bool showBack)
{
    //The assistant finished: allow the user to close the dialog normally

    nextButton()->setEnabled(false);
    backButton()->setEnabled(showBack);
    finishButton()->setEnabled(true);
    buttonBox()->button(QDialogButtonBox::Cancel)->setEnabled(false);

    m_canClose = true;
}
Example #7
0
void NewProtocol::loginComplete()
{
    if (m_client == NULL)
        return;
    m_bConnect = false;
    m_client->setStatus(CorePlugin::m_plugin->getManualStatus(), true);
    m_connectWnd->setConnecting(false);
    setFinishEnabled(m_connectWnd, true);
    getContacts()->addClient(m_client);
    m_client = NULL;
    cancelButton()->hide();
    backButton()->hide();
}
void KexiCSVExportWizard::layOutButtonRow(QHBoxLayout * layout)
{
    Q3Wizard::layOutButtonRow(layout);

    //find the last sublayout
    QLayout *l = layout->itemAt(layout->count()-1)->layout();
    if (dynamic_cast<QBoxLayout*>(l)) {
        if (!m_defaultsBtn) {
            m_defaultsBtn = new KPushButton(i18n("Defaults"), this);
            QWidget::setTabOrder(backButton(), m_defaultsBtn);
            connect(m_defaultsBtn, SIGNAL(clicked()), this, SLOT(slotDefaultsButtonClicked()));
        }
        if (!m_exportOptionsSection->isVisible())
            m_defaultsBtn->hide();
        dynamic_cast<QBoxLayout*>(l)->insertWidget(0, m_defaultsBtn);
    }
}
Example #9
0
KPrWebPresentationWizard::KPrWebPresentationWizard( const QString &_config, KPrDocument *_doc,
                                                  KPrView *_view )
    : KWizard( 0, "", false ), config( _config ), webPres( config, _doc, _view )
{
    doc = _doc;
    view = _view;

    setupPage1();
    setupPage2();
    setupPage3();
    setupPage4();
    setupPage5();

    connect( nextButton(), SIGNAL( clicked() ), this, SLOT( pageChanged() ) );
    connect( backButton(), SIGNAL( clicked() ), this, SLOT( pageChanged() ) );
    connect( finishButton(), SIGNAL( clicked() ), this, SLOT( finish() ) );
}
void MigrateDialog::pageSelected(const QString&)
{
    if (currentPage() != page2)
        return;
    backButton()->hide();
    setFinishEnabled(page2, false);
    list<QCheckBox*>::iterator it;
    for (it = m_boxes.begin(); it != m_boxes.end(); ++it){
        if ((*it)->isChecked()){
            m_bProcess = true;
            break;
        }
    }
    if (!m_bProcess){
        reject();
        return;
    }
    unsigned totalSize = 0;
    for (it = m_boxes.begin(); it != m_boxes.end(); ++it){
        if (!(*it)->isChecked())
            continue;
        QString path = QFile::decodeName(user_file(QFile::encodeName((*it)->text())).c_str());
#ifdef WIN32
        path += "\\";
#else
        path += "/";
#endif
        QFile icq_conf(path + "icq.conf");
        totalSize += icq_conf.size();
        QString history_path = path + "history";
#ifdef WIN32
        history_path += "\\";
#else
        history_path += "/";
#endif
        QDir history(history_path);
        QStringList l = history.entryList("*.history", QDir::Files);
        for (QStringList::Iterator it = l.begin(); it != l.end(); ++it){
            QFile hf(history_path + (*it));
            totalSize += hf.size();
        }
    }
    barCnv->setTotalSteps(totalSize);
    QTimer::singleShot(0, this, SLOT(process()));
}
Example #11
0
ProviderDB::ProviderDB(QWidget *parent) :
  KWizard(parent, "", true),
  cfg(0)
{
  setCaption(i18n("Create New Account"));

  wiz = this;

  page1 = new PDB_Intro(this);
  addPage(page1, "");
  setHelpEnabled(page1, false);
  // TODO  p1->w->setFocusPolicy(StrongFocus);

  page2 = new PDB_Country(this);
  addPage(page2, "");
  setHelpEnabled(page2, false);

  page3 = new PDB_Provider(this);
  addPage(page3, "");
  setHelpEnabled(page3, false);

  page4 = new PDB_UserInfo(this);
  addPage(page4, "");
  setHelpEnabled(page4, false);

  page5 = new PDB_DialPrefix(this);
  addPage(page5, "");
  setHelpEnabled(page5, false);

  page9 = new PDB_Finished(this);
  addPage(page9, "");
  setHelpEnabled(page9, false);
  setFinish(page9, true);
  setFinishEnabled(page9, true);

  connect((const QObject *)nextButton(), SIGNAL(clicked()),
  	  this, SLOT(pageSelected()));
  connect((const QObject *)backButton(), SIGNAL(clicked()),
  	  this, SLOT(pageSelected()));

  //  resize(minimumSize());
  adjustSize();
}
Example #12
0
void NewProtocol::pageChanged(const QString&)
{
    if (currentPage() == m_connectWnd){
        emit apply();
        m_bConnect = true;
        unsigned status = CorePlugin::m_plugin->getManualStatus();
        if (status == STATUS_OFFLINE)
            status = STATUS_ONLINE;
        m_client->setStatus(status, false);
        m_connectWnd->setConnecting(true);
        setBackEnabled(m_connectWnd, false);
        setNextEnabled(currentPage(), false);
        setFinishEnabled(m_connectWnd, false);
    }
    if (m_last && (currentPage() == m_last)){
        setFinishEnabled(m_connectWnd, false);
        cancelButton()->show();
        backButton()->show();
        finishButton()->hide();
        showPage(protocolPage);
        protocolChanged(0);
    }
}
KexiCSVExportWizard::KexiCSVExportWizard(const KexiCSVExport::Options& options,
        QWidget * parent)
        : K3Wizard(parent)
        , m_options(options)
// , m_mode(mode)
// , m_itemId(itemId)
        , m_fileSavePage(0)
        , m_defaultsBtn(0)
        , m_importExportGroup(KGlobal::config()->group("ImportExport"))
        , m_rowCount(-1)
        , m_rowCountDetermined(false)
        , m_cancelled(false)
{
    if (m_options.mode == KexiCSVExport::Clipboard) {
        finishButton()->setText(i18n("Copy"));
        backButton()->hide();
    } else {
        finishButton()->setText(i18n("Export"));
    }
    helpButton()->hide();

    QString infoLblFromText;
    KexiGUIMessageHandler msgh(this);
    m_tableOrQuery = new KexiDB::TableOrQuerySchema(
        KexiMainWindowIface::global()->project()->dbConnection(), m_options.itemId);
    if (m_tableOrQuery->table()) {
        if (m_options.mode == KexiCSVExport::Clipboard) {
            setWindowTitle(i18n("Copy Data From Table to Clipboard"));
            infoLblFromText = i18n("Copying data from table:");
        } else {
            setWindowTitle(i18n("Export Data From Table to CSV File"));
            infoLblFromText = i18n("Exporting data from table:");
        }
    } else if (m_tableOrQuery->query()) {
        if (m_options.mode == KexiCSVExport::Clipboard) {
            setWindowTitle(i18n("Copy Data From Query to Clipboard"));
            infoLblFromText = i18n("Copying data from table:");
        } else {
            setWindowTitle(i18n("Export Data From Query to CSV File"));
            infoLblFromText = i18n("Exporting data from query:");
        }
    } else {
        msgh.showErrorMessage(KexiMainWindowIface::global()->project()->dbConnection(),
                              i18n("Could not open data for exporting."));
        m_cancelled = true;
        return;
    }
    // OK, source data found.

    // Setup pages

    // 1. File Save Page
    if (m_options.mode == KexiCSVExport::File) {
        m_fileSavePage = new KexiStartupFileWidget(
            KUrl("kfiledialog:///CSVImportExport"), //startDir
            KexiStartupFileWidget::Custom | KexiStartupFileWidget::SavingFileBasedDB,
            this);
        m_fileSavePage->setObjectName("m_fileSavePage");
        m_fileSavePage->setMinimumHeight(kapp->desktop()->availableGeometry().height() / 2);
        m_fileSavePage->setAdditionalFilters(csvMimeTypes().toSet());
        m_fileSavePage->setDefaultExtension("csv");
        m_fileSavePage->setLocationText(
            KexiUtils::stringToFileName(m_tableOrQuery->captionOrName()));
        connect(m_fileSavePage, SIGNAL(rejected()), this, SLOT(reject()));
        addPage(m_fileSavePage, i18n("Enter Name of File You Want to Save Data To"));
    }

    // 2. Export options
    m_exportOptionsPage = new QWidget(this);
    m_exportOptionsPage->setObjectName("m_exportOptionsPage");
    QGridLayout *exportOptionsLyr = new QGridLayout(m_exportOptionsPage);
    exportOptionsLyr->setObjectName("exportOptionsLyr");
    m_infoLblFrom = new KexiCSVInfoLabel(infoLblFromText, m_exportOptionsPage);
    KexiPart::Info *partInfo = Kexi::partManager().infoForClass(
            QString("org.kexi-project.%1").arg(m_tableOrQuery->table() ? "table" : "query"));
    if (partInfo)
        m_infoLblFrom->setIcon(partInfo->itemIcon());
    m_infoLblFrom->separator()->hide();
    exportOptionsLyr->addWidget(m_infoLblFrom, 0, 0, 0, 2);

    m_infoLblTo = new KexiCSVInfoLabel(
        (m_options.mode == KexiCSVExport::File) ? i18n("To CSV file:") : i18n("To clipboard:"),
        m_exportOptionsPage
    );
    if (m_options.mode == KexiCSVExport::Clipboard)
        m_infoLblTo->setIcon("edit-paste");
    exportOptionsLyr->addWidget(m_infoLblTo, 1, 0, 1, 3);

    m_showOptionsButton = new KPushButton(KGuiItem(i18n("Show Options >>"), "configure"),
                                          m_exportOptionsPage);
    connect(m_showOptionsButton, SIGNAL(clicked()), this, SLOT(slotShowOptionsButtonClicked()));
    exportOptionsLyr->addWidget(m_showOptionsButton, 2, 2, 0, 0);
    m_showOptionsButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

    // -<options section>
    m_exportOptionsSection = new Q3GroupBox(1, Qt::Vertical, i18n("Options"), m_exportOptionsPage);
    m_exportOptionsSection->setObjectName("m_exportOptionsSection");
    m_exportOptionsSection->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    exportOptionsLyr->addWidget(m_exportOptionsSection, 3, 3, 0, 1);
    QWidget *exportOptionsSectionWidget
    = new QWidget(m_exportOptionsSection);
    exportOptionsSectionWidget->setObjectName("exportOptionsSectionWidget");
    QGridLayout *exportOptionsSectionLyr = new QGridLayout(exportOptionsSectionWidget);
    exportOptionsLyr->setObjectName("exportOptionsLyr");

    // -delimiter
    m_delimiterWidget = new KexiCSVDelimiterWidget(false, //!lineEditOnBottom
            exportOptionsSectionWidget);
    m_delimiterWidget->setDelimiter(defaultDelimiter());
    exportOptionsSectionLyr->addWidget(m_delimiterWidget, 0, 1);
    QLabel *delimiterLabel = new QLabel(i18n("Delimiter:"), exportOptionsSectionWidget);
    delimiterLabel->setBuddy(m_delimiterWidget);
    exportOptionsSectionLyr->addWidget(delimiterLabel, 0, 0);

    // -text quote
    QWidget *textQuoteWidget = new QWidget(exportOptionsSectionWidget);
    QHBoxLayout *textQuoteLyr = new QHBoxLayout(textQuoteWidget);
    exportOptionsSectionLyr->addWidget(textQuoteWidget, 1, 1);
    m_textQuote = new KexiCSVTextQuoteComboBox(textQuoteWidget);
    m_textQuote->setTextQuote(defaultTextQuote());
    textQuoteLyr->addWidget(m_textQuote);
    textQuoteLyr->addStretch(0);
    QLabel *textQuoteLabel = new QLabel(i18n("Text quote:"), exportOptionsSectionWidget);
    textQuoteLabel->setBuddy(m_textQuote);
    exportOptionsSectionLyr->addWidget(textQuoteLabel, 1, 0);

    // - character encoding
    m_characterEncodingCombo = new KexiCharacterEncodingComboBox(exportOptionsSectionWidget);
    m_characterEncodingCombo->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    exportOptionsSectionLyr->addWidget(m_characterEncodingCombo, 2, 1);
    QLabel *characterEncodingLabel = new QLabel(i18n("Text encoding:"), exportOptionsSectionWidget);
    characterEncodingLabel->setBuddy(m_characterEncodingCombo);
    exportOptionsSectionLyr->addWidget(characterEncodingLabel, 2, 0);

    // - checkboxes
    m_addColumnNamesCheckBox = new QCheckBox(i18n("Add column names as the first row"),
            exportOptionsSectionWidget);
    m_addColumnNamesCheckBox->setChecked(true);
    exportOptionsSectionLyr->addWidget(m_addColumnNamesCheckBox, 3, 1);
//! @todo 1.1: for copying use "Always use above options for copying" string
    m_alwaysUseCheckBox = new QCheckBox(i18n("Always use above options for exporting"),
                                        m_exportOptionsPage);
    exportOptionsLyr->addWidget(m_alwaysUseCheckBox, 4, 4, 0, 1);
// exportOptionsSectionLyr->addWidget( m_alwaysUseCheckBox, 4, 1 );
    m_exportOptionsSection->hide();
    m_alwaysUseCheckBox->hide();
    // -</options section>

// exportOptionsLyr->setColumnStretch(3, 1);
    exportOptionsLyr->addItem(
        new QSpacerItem(0, 0, QSizePolicy::Preferred, QSizePolicy::MinimumExpanding), 5, 0, 1, 2);

// addPage(m_exportOptionsPage, i18n("Set Export Options"));
    addPage(m_exportOptionsPage,
            m_options.mode == KexiCSVExport::Clipboard ? i18n("Copying") : i18n("Exporting"));
    setFinishEnabled(m_exportOptionsPage, true);

    // load settings
    if (m_options.mode != KexiCSVExport::Clipboard
            && readBoolEntry("ShowOptionsInCSVExportDialog", false)) {
        show();
        slotShowOptionsButtonClicked();
    }
    if (readBoolEntry("StoreOptionsForCSVExportDialog", false)) {
        // load defaults:
        m_alwaysUseCheckBox->setChecked(true);
        QString s = readEntry("DefaultDelimiterForExportingCSVFiles", defaultDelimiter());
        if (!s.isEmpty())
            m_delimiterWidget->setDelimiter(s);
        s = readEntry("DefaultTextQuoteForExportingCSVFiles", defaultTextQuote());
        m_textQuote->setTextQuote(s); //will be invaliudated here, so not a problem
        s = readEntry("DefaultEncodingForExportingCSVFiles");
        if (!s.isEmpty())
            m_characterEncodingCombo->setSelectedEncoding(s);
        m_addColumnNamesCheckBox->setChecked(
            readBoolEntry("AddColumnNamesForExportingCSVFiles", true));
    }

    updateGeometry();

    // -keep widths equal on page #2:
    int width = qMax(m_infoLblFrom->leftLabel()->sizeHint().width(),
                     m_infoLblTo->leftLabel()->sizeHint().width());
    m_infoLblFrom->leftLabel()->setFixedWidth(width);
    m_infoLblTo->leftLabel()->setFixedWidth(width);
}
FollowStreamDialog::FollowStreamDialog(QWidget &parent, CaptureFile &cf, follow_type_t type) :
    WiresharkDialog(parent, cf),
    ui(new Ui::FollowStreamDialog),
    b_find_(NULL),
    follow_type_(type),
    follower_(NULL),
    show_type_(SHOW_ASCII),
    truncated_(false),
    client_buffer_count_(0),
    server_buffer_count_(0),
    client_packet_count_(0),
    server_packet_count_(0),
    last_packet_(0),
    last_from_server_(0),
    turns_(0),
    save_as_(false),
    use_regex_find_(false),
    terminating_(false)
{
    ui->setupUi(this);
    loadGeometry(parent.width() * 2 / 3, parent.height());

    switch(type)
    {
    case FOLLOW_TCP:
        follower_ = get_follow_by_name("TCP");
        break;
    case FOLLOW_SSL:
        follower_ = get_follow_by_name("SSL");
        break;
    case FOLLOW_UDP:
        follower_ = get_follow_by_name("UDP");
        break;
    case FOLLOW_HTTP:
        follower_ = get_follow_by_name("HTTP");
        break;
    default :
        g_assert_not_reached();
    }

    memset(&follow_info_, 0, sizeof(follow_info_));
    follow_info_.show_stream = BOTH_HOSTS;

    ui->teStreamContent->installEventFilter(this);

    connect(ui->leFind, SIGNAL(useRegexFind(bool)), this, SLOT(useRegexFind(bool)));

    QComboBox *cbcs = ui->cbCharset;
    cbcs->blockSignals(true);
    cbcs->addItem(tr("ASCII"), SHOW_ASCII);
    cbcs->addItem(tr("C Arrays"), SHOW_CARRAY);
    cbcs->addItem(tr("EBCDIC"), SHOW_EBCDIC);
    cbcs->addItem(tr("Hex Dump"), SHOW_HEXDUMP);
    cbcs->addItem(tr("UTF-8"), SHOW_UTF8);
    cbcs->addItem(tr("UTF-16"), SHOW_UTF16);
    cbcs->addItem(tr("YAML"), SHOW_YAML);
    cbcs->addItem(tr("Raw"), SHOW_RAW);
    cbcs->blockSignals(false);

    b_filter_out_ = ui->buttonBox->addButton(tr("Filter Out This Stream"), QDialogButtonBox::ActionRole);
    connect(b_filter_out_, SIGNAL(clicked()), this, SLOT(filterOut()));

    b_print_ = ui->buttonBox->addButton(tr("Print"), QDialogButtonBox::ActionRole);
    connect(b_print_, SIGNAL(clicked()), this, SLOT(printStream()));

    b_save_ = ui->buttonBox->addButton(tr("Save as" UTF8_HORIZONTAL_ELLIPSIS), QDialogButtonBox::ActionRole);
    connect(b_save_, SIGNAL(clicked()), this, SLOT(saveAs()));

    b_back_ = ui->buttonBox->addButton(tr("Back"), QDialogButtonBox::ActionRole);
    connect(b_back_, SIGNAL(clicked()), this, SLOT(backButton()));

    ProgressFrame::addToButtonBox(ui->buttonBox, &parent);

    connect(ui->buttonBox, SIGNAL(helpRequested()), this, SLOT(helpButton()));
    connect(ui->teStreamContent, SIGNAL(mouseMovedToTextCursorPosition(int)),
            this, SLOT(fillHintLabel(int)));
    connect(ui->teStreamContent, SIGNAL(mouseClickedOnTextCursorPosition(int)),
            this, SLOT(goToPacketForTextPos(int)));
    connect(&cap_file_, SIGNAL(captureEvent(CaptureEvent *)),
            this, SLOT(captureEvent(CaptureEvent *)));

    fillHintLabel(-1);
}
Example #15
0
int main() {
    //RNG
    srand((unsigned int)time(NULL));

	//Load up our textures
	loadGlobalTextures();
	//Load Our Font
	loadGlobalFonts();

	//Load up the Game
	mainWindow.create(sf::VideoMode(WINDOW_WIDTH,WINDOW_HEIGHT), windowName);
	Game theGame;

	//Frame Clock
	sf::Clock frameClock;
	frameClock.restart();

	//Menu Stuff - TODO, make separate class?
	sf::Texture splashTex;
	if (EXTERNAL_FILE_MODE)
		splashTex.loadFromFile(PROJECT_DIRECTORY + SPLASH_IMAGE);
	else
		splashTex.loadFromFile(SPLASH_IMAGE);
	sf::Sprite splashBox(splashTex);
	//New Game
	TextButton newGameButton("New Game", 64, sf::Color::Green);
    newGameButton.setSelectedColor(sf::Color::Red);
    newGameButton.text.setPosition(WINDOW_WIDTH/2 - newGameButton.text.getGlobalBounds().width/2, 160);
	//Load Game
	TextButton loadGameButton("Load Game", 64, sf::Color::Green);
    loadGameButton.setSelectedColor(sf::Color::Red);
    loadGameButton.text.setPosition(WINDOW_WIDTH/2 - loadGameButton.text.getGlobalBounds().width/2, 260);
	//Instant Play
    TextButton playButton("Instant Play", 64, sf::Color::Green);
    playButton.setSelectedColor(sf::Color::Red);
    playButton.text.setPosition(WINDOW_WIDTH/2 - playButton.text.getGlobalBounds().width/2, 360);
	//Settings Button
	TextButton settingsButton("Settings", 64, sf::Color::Green);
	settingsButton.setSelectedColor(sf::Color::Red);
    settingsButton.text.setPosition(WINDOW_WIDTH/2 - settingsButton.text.getGlobalBounds().width/2, 460);
	//Quit Button
	TextButton quitButton("Quit Game", 64, sf::Color::Green);
	quitButton.setSelectedColor(sf::Color::Red);
    quitButton.text.setPosition(WINDOW_WIDTH/2 - quitButton.text.getGlobalBounds().width/2, 560);
	//Logo
	sf::Text logo = createText("Chap Shmup", 96, sf::Color::Green, FONT_2);
	logo.setPosition(WINDOW_WIDTH/2 - logo.getGlobalBounds().width/2, 16);

	//Settings Screen
	//Title
	sf::Text settingsTitle = createText("Settings", 96, sf::Color::Green, FONT_2);
	settingsTitle.setPosition(WINDOW_WIDTH/2 - settingsTitle.getGlobalBounds().width/2, 16);
	//TODO
	//Actual Settings
	//Back
	TextButton backButton("Back", 64, sf::Color::Green);
	backButton.setSelectedColor(sf::Color::Red);
    backButton.text.setPosition(WINDOW_WIDTH/2 - backButton.text.getGlobalBounds().width/2, 560);

    //New Game Screen
    //Title
    sf::Text newGameTitle = createText("New Game", 96, sf::Color::Green, FONT_2);
	newGameTitle.setPosition(WINDOW_WIDTH/2 - newGameTitle.getGlobalBounds().width/2, 16);
	//Story Blurb
	sf::Text storyText = createText("2:00am, 21 Dec 2712", 32, sf::Color::Green);
	storyText.setPosition(WINDOW_WIDTH/4 - storyText.getGlobalBounds().width/2, 160);

	//Character Input
	sf::Text charInputText = createText("Character Info:", 32, sf::Color::Green);
	charInputText.setPosition(3*WINDOW_WIDTH/4 - charInputText.getGlobalBounds().width/2, 160);
	sf::Text nameInputText = createText("Your Name:", 32, sf::Color::Green);
	nameInputText.setPosition(3*WINDOW_WIDTH/4 - nameInputText.getGlobalBounds().width, 260);

	//Next Button
	TextButton nextButton("Next", 64, sf::Color::Green);
	nextButton.setSelectedColor(sf::Color::Red);
    nextButton.text.setPosition(WINDOW_WIDTH/2 - nextButton.text.getGlobalBounds().width/2, 560);

	//Run the window
	while (mainWindow.isOpen()) {
		//Get elapsed time
		sf::Time elapsedTime = frameClock.restart();
		sf::Event e;
		while(mainWindow.pollEvent(e))
		{
			if (e.type == sf::Event::Closed)
            {
				mainWindow.close();
			}
			if (e.type == sf::Event::KeyPressed && e.key.code == sf::Keyboard::Escape) {
                if (GAME_MODE == "Main Menu")
                {
                    mainWindow.close();
                }
                else
                {
                    GAME_MODE = "Main Menu";
                }
			}
			if (e.type == sf::Event::MouseButtonPressed)
			{
				if (GAME_MODE == "Main Menu")
				{
					//Buttons!
					if (mouseWithin(newGameButton.text))
					{
						GAME_MODE = "New Game";
					}
					else if (mouseWithin(loadGameButton.text))
					{
						GAME_MODE = "Load Game";
					}
					else if (mouseWithin(playButton.text))
					{
						GAME_MODE = "Play Level";
						theGame.start();
					}
					else if (mouseWithin(settingsButton.text))
					{
						GAME_MODE = "Settings";
					}
					else if (mouseWithin(quitButton.text))
					{
						mainWindow.close();
					}
				}
				else if (GAME_MODE == "Settings")
                {
                    if (mouseWithin(backButton.text))
					{
						GAME_MODE = "Main Menu";
					}
                }
                else if (GAME_MODE == "New Game")
                {
                    if (mouseWithin((nextButton.text)))
                    {
                        GAME_MODE = "Play Level";
						theGame.start();
                    }
                }
			}
		}
		//GAME_MODE: Main Menu
		if (GAME_MODE == "Main Menu")
        {
		    //Updating
		    playButton.update(elapsedTime.asSeconds());
		    settingsButton.update(elapsedTime.asSeconds());
		    quitButton.update(elapsedTime.asSeconds());
		    newGameButton.update(elapsedTime.asSeconds());
		    loadGameButton.update(elapsedTime.asSeconds());

		    //Drawing
			mainWindow.clear();
			playButton.draw(mainWindow);
			settingsButton.draw(mainWindow);
			quitButton.draw(mainWindow);
			loadGameButton.draw(mainWindow);
			newGameButton.draw(mainWindow);
			mainWindow.draw(logo);
			mainWindow.display();
		}
		//GAME_MODE: Play Game
		else if (GAME_MODE == "Play Level")
        {
			//Updating
			theGame.update(elapsedTime.asSeconds());

			//Drawing
			mainWindow.clear();
			theGame.draw(mainWindow);
			mainWindow.display();

			//Game ended?
			if (theGame.isLevelOver())
                GAME_MODE = "Main Menu";
		}
		//GAME_MODE: Settings
		else if (GAME_MODE == "Settings")
        {
            //Updating
            backButton.update(elapsedTime.asSeconds());

            //Drawing
			mainWindow.clear();
			mainWindow.draw(settingsTitle);
			backButton.draw(mainWindow);
			mainWindow.display();
		}
		else if (GAME_MODE == "New Game")
        {
            //Update
            nextButton.update(elapsedTime.asSeconds());

            //Draw
            mainWindow.clear();
            mainWindow.draw(newGameTitle);
            mainWindow.draw(storyText);
            mainWindow.draw(charInputText);
            mainWindow.draw(nameInputText);
            nextButton.draw(mainWindow);
            mainWindow.display();
        }
        else if (GAME_MODE == "Load Game")
        {
            //Update


            //Draw
            mainWindow.clear();
            mainWindow.draw(splashBox);
            mainWindow.display();
        }

		//Try to keep approx 60 fps
		sf::Time timeToPause = sf::milliseconds(16) - frameClock.getElapsedTime();
		sf::sleep(timeToPause);
	}

	//Terminate
	//system("pause");
	return EXIT_SUCCESS;
}
Example #16
0
void ViewSceneScreen::LoadResources()
{
    BaseScreen::LoadResources();
 
    ScopedPtr<Scene> scene(new Scene());
    Entity *entity = scene->GetRootNode(GameCore::Instance()->GetScenePath());
    scene->AddNode(entity);
    scene->ReleaseRootNode(GameCore::Instance()->GetScenePath());
    
    DVASSERT(camera == NULL);
    camera = new Camera();
    
	Core* core = DAVA::Core::Instance();
	float32 aspect = core->GetVirtualScreenHeight() / core->GetVirtualScreenWidth();
    
	camera->SetupPerspective(70.f, aspect, 0.5f, 2500.f);
	camera->SetLeft(Vector3(1, 0, 0));
	camera->SetUp(Vector3(0, 0, 1.f));
    camera->SetTarget(Vector3(0, 0, 0));
    camera->SetPosition(Vector3(0, 0, 100));


    //TODO: debug
    camera->SetPosition(Vector3(18.7855f, 111.0697f, 57.0635f));
    camera->SetDirection(Vector3(-1.2904f, 9.0496f, -4.0545f));
    //ENDOFTODO

    
    scene->AddCamera(camera);
    scene->SetCurrentCamera(camera);
    
    const Rect screenRect = GetRect();
    ScopedPtr<UI3DView> sceneView(new UI3DView(screenRect));
    sceneView->SetScene(scene);
    sceneView->SetInputEnabled(false);
    AddControl(sceneView);
    
    ScopedPtr<UIButton> backButton(CreateButton(Rect(0, 0, 90, 30), L"Back"));
    backButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &ViewSceneScreen::OnBack));
    backButton->SetDebugDraw(true);
    AddControl(backButton);
    
    
    const float32 joyPADSize = 100.f;
    
    moveJoyPAD = new UIJoypad(Rect(0, screenRect.dy - joyPADSize, joyPADSize, joyPADSize));
    moveJoyPAD->GetBackground()->SetSprite("~res:/Gfx/Joypad/joypad", 0);
    moveJoyPAD->SetStickSprite("~res:/Gfx/Joypad/joypad", 1);

    AddControl(moveJoyPAD);
    
    viewJoyPAD = new UIJoypad(Rect(screenRect.dx - joyPADSize, screenRect.dy - joyPADSize, joyPADSize, joyPADSize));
    viewJoyPAD->GetBackground()->SetSprite("~res:/Gfx/Joypad/joypad", 0);
    viewJoyPAD->SetStickSprite("~res:/Gfx/Joypad/joypad", 1);
    AddControl(viewJoyPAD);
    
    viewXAngle = 0;
    viewYAngle = 0;
    
    DVASSERT(info == NULL);
    info = new UIStaticText(Rect(0, 0, screenRect.dx, 30.f));
    info->SetFont(font);
    info->SetTextColor(Color::White);
    info->SetTextAlign(ALIGN_VCENTER | ALIGN_RIGHT);
    
    AddControl(info);
}