Exemple #1
0
void IdentityForm::onImportClicked()
{
    QString path = QFileDialog::getOpenFileName(this,
                                                tr("Import profile", "import dialog title"),
                                                QDir::homePath(),
                                                tr("Tox save file (*.tox)", "import dialog filter"));
    if (path.isEmpty())
        return;

    QFileInfo info(path);
    QString profile = info.completeBaseName();

    if (info.suffix() != "tox")
    {
        QMessageBox::warning(this,
                             tr("Ignoring non-Tox file", "popup title"),
                             tr("Warning: you've chosen a file that is not a Tox save file; ignoring.", "popup text"));
        return;
    }

    QString profilePath = QDir(Settings::getSettingsDirPath()).filePath(profile + Core::TOX_EXT);

    if (QFileInfo(profilePath).exists() && !checkContinue(tr("Profile already exists", "import confirm title"),
            tr("A profile named \"%1\" already exists. Do you want to erase it?", "import confirm text").arg(profile)))
        return;

    QFile::copy(path, profilePath);
    bodyUI->profiles->addItem(profile);
}
Exemple #2
0
void MainMenu::show()
{
	// assert( false );
	
	if( currentActive )
	{
		currentActive->SetFont( fonts->medium.normal );
		menuCollection->setBackgroundImage( "" );
	}
	
	currentActive = NULL;

	checkContinue();

	MenuBaseImpl::show();
	win2->Show();
}
Exemple #3
0
void handleToxSave(const QString& path)
{
    Core* core = Core::getInstance();

    while (!core)
    {
        core = Core::getInstance();
        qApp->processEvents();
    }

    while (!core->isReady())
    {
        qApp->processEvents();
    }

    QFileInfo info(path);
    if (!info.exists())
        return;

    QString profile = info.completeBaseName();

    if (info.suffix() != "tox")
    {
        QMessageBox::warning(Widget::getInstance(),
                             QObject::tr("Ignoring non-Tox file", "popup title"),
                             QObject::tr("Warning: you've chosen a file that is not a Tox save file; ignoring.", "popup text"));
        return;
    }

    QString profilePath = QDir(Settings::getSettingsDirPath()).filePath(profile + Core::TOX_EXT);

    if (QFileInfo(profilePath).exists() && !checkContinue(QObject::tr("Profile already exists", "import confirm title"),
            QObject::tr("A profile named \"%1\" already exists. Do you want to erase it?", "import confirm text").arg(profile)))
        return;

    QFile::copy(path, profilePath);
    // no good way to update the ui from here... maybe we need a Widget:refreshUi() function...
    // such a thing would simplify other code as well I believe
    QMessageBox::information(Widget::getInstance(), QObject::tr("Profile imported"), QObject::tr("%1.tox was successfully imported").arg(profile));
}
Exemple #4
0
void IdentityForm::onRenameClicked()
{
    QString cur = bodyUI->profiles->currentText();
    QString title = tr("Rename \"%1\"", "renaming a profile").arg(cur);
    do
    {
        QString name = QInputDialog::getText(this, title, title+":");
        if (name.isEmpty()) break;
        name = Core::sanitize(name);
        QDir dir(Settings::getSettingsDirPath());
        QString file = dir.filePath(name+Core::TOX_EXT);
        if (!QFile::exists(file) || checkContinue(tr("Profile already exists", "rename confirm title"),
                tr("A profile named \"%1\" already exists. Do you want to erase it?", "rename confirm text").arg(cur)))
        {
            QFile::rename(dir.filePath(cur+Core::TOX_EXT), file);
            bodyUI->profiles->setItemText(bodyUI->profiles->currentIndex(), name);
            HistoryKeeper::renameHistory(cur, name);
            Settings::getInstance().setCurrentProfile(name);
            break;
        }
    } while (true);
}
Exemple #5
0
void IdentityForm::onDeleteClicked()
{
    if (Settings::getInstance().getCurrentProfile() == bodyUI->profiles->currentText())
    {
        QMessageBox::warning(this, tr("Profile currently loaded","current profile deletion warning title"), tr("This profile is currently in use. Please load a different profile before deleting this one.","current profile deletion warning text"));
    }
    else
    {        
        if (checkContinue(tr("Deletion imminent!","deletion confirmation title"),
                          tr("Are you sure you want to delete this profile?\nAssociated friend information and chat logs will be deleted as well.","deletion confirmation text")))
        {
            QString profile = bodyUI->profiles->currentText();
            QDir dir(Settings::getSettingsDirPath());

            QFile::remove(dir.filePath(profile + Core::TOX_EXT));
            QFile::remove(dir.filePath(profile + ".ini"));
            QFile::remove(HistoryKeeper::getHistoryPath(profile, 0));
            QFile::remove(HistoryKeeper::getHistoryPath(profile, 1));

            bodyUI->profiles->removeItem(bodyUI->profiles->currentIndex());
            bodyUI->profiles->setCurrentText(Settings::getInstance().getCurrentProfile());
        }
    }
}
void VisualizerApp::startContinueChecker()
{
  continue_timer_ = new QTimer( this );
  connect( continue_timer_, SIGNAL( timeout() ), this, SLOT( checkContinue() ));
  continue_timer_->start( 100 );
}
Exemple #7
0
MainMenu::MainMenu( MenuCollection* menu, MenuCollection::Fonts* fonts, Ogui* o_gui, Game* g, bool from_game ) :
  MenuBaseImpl( NULL ),
  menuCollection( menu ),
  fonts( fonts ),
  abortGame( NULL ),
  abortGameYes( NULL ),
  abortGameNo( NULL ),
  captureAllEvents( NULL ),
  continueButton( NULL ),
  currentActive( NULL ),
#ifdef PROJECT_SURVIVOR
  numberOfButtons( 9 ),
#else
	numberOfButtons( 7 ),
#endif
  fromGame( from_game ),
  quitPressed( false ),
  playerName( "Pertti" )
{
	assert( o_gui );
	assert( menu );
	assert( fonts );
	assert( g );
	game = g;

	ogui = o_gui;
	{
		int x = getLocaleGuiInt( "gui_mainmenu_window_x", 0 );
		int y = getLocaleGuiInt( "gui_mainmenu_window_y", 0 );
		int w = getLocaleGuiInt( "gui_mainmenu_window_w", 1024 );
		int h = getLocaleGuiInt( "gui_mainmenu_window_h", 150 );
		win = ogui->CreateSimpleWindow( x, y, w, h, NULL );
		win->Hide();
		win->SetUnmovable();
	}
	{
		int x = getLocaleGuiInt( "gui_mainmenu_window2_x", 0 );
		int y = getLocaleGuiInt( "gui_mainmenu_window2_y", 0 );
		int w = getLocaleGuiInt( "gui_mainmenu_window2_w", 0 );
		int h = getLocaleGuiInt( "gui_mainmenu_window2_h", 0 );
		win2 = ogui->CreateSimpleWindow( x, y, w, h, NULL );
		win2->Hide();
		win2->SetUnmovable();
	}
	fromGame = game->inCombat;

	// Main menu buttons
	buttonX	= getLocaleGuiInt( "gui_mainmenu_button_x", 65 );
	if ( fromGame )
			buttonY = getLocaleGuiInt( "gui_mainmenu_button_y_fromgame", 226 );
	else	buttonY = getLocaleGuiInt( "gui_mainmenu_button_y", 275 );

	buttonAddX = getLocaleGuiInt( "gui_mainmenu_button_add_x", getLocaleGuiInt( "gui_menu_common_button_add_x", 0 ) );
	buttonAddY = getLocaleGuiInt( "gui_mainmenu_button_add_y", getLocaleGuiInt( "gui_menu_common_button_add_y", 28 ) );
	buttonW = getLocaleGuiInt( "gui_mainmenu_button_w", getLocaleGuiInt( "gui_menu_common_button_w", 0 ) );
	buttonH = getLocaleGuiInt( "gui_mainmenu_button_h", getLocaleGuiInt( "gui_menu_common_button_h", 0 ) );

	// Adding the buttons
	if ( fromGame )
	{
		addButton( getLocaleGuiString( "gui_mm_resume" ),	COMMANDS_RESUME,	fonts->medium.normal, fonts->medium.highlighted );
		addSeparator();
	}
	else
	{
		continueButton = addButton( getLocaleGuiString( "gui_mm_continue" ),		COMMANDS_CONTINUE,	fonts->medium.normal, fonts->medium.highlighted );
		checkContinue();
		addSeparator();
	}

	

	addButton( getLocaleGuiString( "gui_mm_new_game" ),		COMMANDS_NEW_GAME,	fonts->medium.normal, fonts->medium.highlighted );
	addButton( getLocaleGuiString( "gui_mm_load_game" ),	COMMANDS_LOAD_GAME, fonts->medium.normal, fonts->medium.highlighted );
#ifdef PROJECT_SURVIVOR
	addButton( getLocaleGuiString( "gui_mm_survival" ),	COMMANDS_SURVIVAL, fonts->medium.normal, fonts->medium.highlighted );
	addButton( getLocaleGuiString( "gui_mm_coop" ),	COMMANDS_COOP, fonts->medium.normal, fonts->medium.highlighted );
#endif
	addButton( getLocaleGuiString( "gui_mm_profiles" ),		COMMANDS_PROFILES,	fonts->medium.normal, fonts->medium.highlighted );
	addButton( getLocaleGuiString( "gui_mm_options" ),		COMMANDS_OPTIONS,	fonts->medium.normal, fonts->medium.highlighted );
	addSeparator();
	addButton( getLocaleGuiString( "gui_mm_credits" ),		COMMANDS_CREDITS,	fonts->medium.normal, fonts->medium.highlighted );
	addButton( getLocaleGuiString( "gui_mm_quit" ),			COMMANDS_QUIT,		fonts->medium.normal, fonts->medium.highlighted );

	closeMenuByEsc = false;

	// disable profiles menu if from coop
	if( game->inCombat && game->isCooperative() )
	{
		std::list< OguiButton* >::iterator i = buttons.begin();
		for( i = buttons.begin(); i != buttons.end(); ++i )
		{
			if( (*i)->GetId() == COMMANDS_PROFILES )
			{
				(*i)->SetDisabled( true );
#ifdef PROJECT_SURVIVOR
				(*i)->SetText("");
#endif
			}
		}
	}

	firstUpdate = true;
}