Ejemplo n.º 1
0
State::State(string name) {
    this->name = name;
    curSeq = new Sequence();
    addSequence(curSeq);
}
Ejemplo n.º 2
0
//collision - written by me, check every enemy against the player (and its bullets)-------------------------------
void testApp::collision()
{
	bool collided = false;

	//the type of object that is to be checked
	int collType = 0;

	for(int i=0; i<collidables.size(); i++)
	{
		collType = collidables[i]->getType();

		//the collidable is an 'enemy'
		if(collType==0)
		{
			//check whether a collision occured
			collided = player1.collided(collidables[i]->getX(), collidables[i]->getY(), collidables[i]->getRad(), collType);
			if(collided)
			{
				//if this is the first collision, begin the sound (an attempt to avoid the all triggered sounds)
				if(!begun)
				{
					begun=true;
				}
				//add the enemy's sequence to the sequences being played.
				addSequence(collidables[i]->getSeq(), collidables[i]->getAssoc(), collidables[i]->getMaxPlays());
				//destroy the enemy
				collidables[i]->destroy();
				//add points
				points+=20;
			}
		}
		//same as above, except with an obstacle
		else if(collType==1)
		{
			collided = player1.collided(collidables[i]->getX(), collidables[i]->getY(), collidables[i]->getWid(), collidables[i]->getHei(), collType);
			if(collided)
			{
				if(!begun)
				{
					begun=true;
				}
				addSequence(collidables[i]->getSeq(), collidables[i]->getAssoc(), collidables[i]->getMaxPlays());
				//add points
				points+=20;
			}
		}
		//same as above except with a powerup
		else
		{
			collided = player1.collided(collidables[i]->getX(), collidables[i]->getY(), collidables[i]->getRad(), collType);
			if(collided)
			{
				if(!begun)
				{
					begun=true;
				}
				addSequence(collidables[i]->getSeq(), collidables[i]->getAssoc(), collidables[i]->getMaxPlays());
				collidables[i]->destroy();
				//add points
				points+=30;
			}
		}
	}
}
Ejemplo n.º 3
0
bool
COSXKeyState::CUCHRKeyResource::getKeyRecord(
				KeySequence& keys, UInt16 index, UInt16& state) const
{
	const UInt8* base = reinterpret_cast<const UInt8*>(m_resource);
	const UCKeyStateRecord* sr =
		reinterpret_cast<const UCKeyStateRecord*>(base +
								m_sri->keyStateRecordOffsets[index]);
	const UCKeyStateEntryTerminal* kset =
		reinterpret_cast<const UCKeyStateEntryTerminal*>(sr->stateEntryData);

	UInt16 nextState = 0;
	bool found       = false;
	if (state == 0) {
		found     = true;
		nextState = sr->stateZeroNextState;
		if (!addSequence(keys, sr->stateZeroCharData)) {
			return false;
		}
	}
	else {
		// we have a next entry
		switch (sr->stateEntryFormat) {
		case kUCKeyStateEntryTerminalFormat:
			for (UInt16 j = 0; j < sr->stateEntryCount; ++j) {
				if (kset[j].curState == state) {
					if (!addSequence(keys, kset[j].charData)) {
						return false;
					}
					nextState = 0;
					found     = true;
					break;
				}
			}
			break;

		case kUCKeyStateEntryRangeFormat:
			// XXX -- not supported yet
			break;

		default:
			// XXX -- unknown format
			return false;
		}
	}
	if (!found) {
		// use a terminator
		if (m_st != NULL && state < m_st->keyStateTerminatorCount) {
			if (!addSequence(keys, m_st->keyStateTerminators[state - 1])) {
				return false;
			}
		}
		nextState = sr->stateZeroNextState;
		if (!addSequence(keys, sr->stateZeroCharData)) {
			return false;
		}
	}

	// next
	state = nextState;

	return true;
}
Ejemplo n.º 4
0
void PreferencesDialog::init() {
    tab = new QTabWidget( this, "Tab" );

    quizPage = new QScrollView( tab, "QuizPage" );
    quizPage->setResizePolicy( QScrollView::AutoOneFit );
    quizPageBox = new QWidget( quizPage->viewport(), "QuizPage" );
    quizPage->addChild( quizPageBox );

    quizAlgorithmsPanel = new QWidget( quizPageBox, "QuizAlgorithmsPanel" );
    quizAlgorithmsPanelLayout = new QHBoxLayout( quizAlgorithmsPanel );

    quizAlgorithmOptionsPanel = new QVButtonGroup( tr( "Algorithm" ), quizAlgorithmsPanel, "QuizAlgorithmOptionsPanel" );
    quizLengthOptionsPanel = new QVGroupBox( tr( "Length" ), quizAlgorithmsPanel, "QuizLengthOptionsPanel" );
    quizAlgorithmsPanelLayout->addWidget( quizAlgorithmOptionsPanel );
    quizAlgorithmsPanelLayout->addWidget( quizLengthOptionsPanel, 1 );

    quizCharacterImageOptionsPanel = new QHGroupBox( tr( "Images associated to characters" ), quizPageBox, "QuizCharacterImageOptions" );

    quizCharacterImageLocationLabel = new QLabel( tr( "CharacterImageLocation" ), quizCharacterImageOptionsPanel );
    quizCharacterImageLocationField = new QLineEdit( quizCharacterImageOptionsPanel );
    quizCharacterImageLocationField->setText( prefs->getQuizCharacterImageLocation() );
    quizCharacterImageLocationSetButton = new QPushButton( tr( "SetCharacterImageLocation" ), quizCharacterImageOptionsPanel );
    connect( quizCharacterImageLocationSetButton, SIGNAL( clicked() ), this, SLOT( setCharacterImageLocation() ) );
    quizCharacterImageLocationClearButton = new QPushButton( tr( "ClearCharacterImageLocation" ), quizCharacterImageOptionsPanel );
    connect( quizCharacterImageLocationClearButton, SIGNAL( clicked() ), this, SLOT( clearCharacterImageLocation() ) );
    quizCharacterImageOptionsPanel->addSpace( 10 );
    quizCharacterImageTypeCheckbox = new QCheckBox( tr( "IsCharacterImageAnimated" ), quizCharacterImageOptionsPanel );
    quizCharacterImageTypeCheckbox->setChecked( prefs->isQuizCharacterImagesAnimated() );

    revealingOptionsPanel = new QHGroupBox( tr( "RevealingOrders" ), quizPageBox, "RevealingOptionsPanel" );
  
    sequencesViewPanel = new QVBox( revealingOptionsPanel ); 
    sequencesViewPanel->setSpacing( 2 );
    sequencesView = new SmartListView( sequencesViewPanel, "SequencesView" );
    sequencesView->addColumn( QString::null );
    sequencesView->header()->hide();
    sequencesViewButtons = new QHBox( sequencesViewPanel );
    sequencesViewButtons->setSpacing( 2 );
    //sequencesViewButtonsFiller = new QWidget( sequencesViewButtons, "SequenceViewButtonsFiller" ); 
    addSequenceButton = new QPushButton( "+", sequencesViewButtons, "AddSequenceButton" );
    QToolTip::add( addSequenceButton, tr( "Add revealing sequence" ) );
    connect( addSequenceButton, SIGNAL( clicked() ), this, SLOT( addSequence() ) );
    removeSequenceButton = new QPushButton( "-", sequencesViewButtons, "RemoveSequenceButton" );
    QToolTip::add( removeSequenceButton, tr( "Remove revealing sequence" ) );
    connect( removeSequenceButton, SIGNAL( clicked() ), this, SLOT( removeSequence() ) );
    //sequencesViewButtons->setStretchFactor( sequencesViewButtonsFiller, 1 );

    initSequences();
    connect( sequencesView, SIGNAL( selectionChanged( QListViewItem* ) ), this, SLOT( updateUi() ) );

    revealingOptionsPanel->addSpace( 6 );

    sequencesLabelBox = new QVGroupBox( tr( "QuizWindow" ), revealingOptionsPanel, "SequencesLabelBox" );
    sequencesLabel = new QLabel( sequencesLabelBox );
    sequencesLabel->setPixmap( Resource::loadPixmap( "SequenceMapLandscape" ) );

    sequencesViewPanel->setMaximumHeight( sequencesLabelBox->sizeHint().height() );

    quizAlgoOriginalRadioButton = new QRadioButton( tr( "OriginalQuizAlgorithm" ), quizAlgorithmOptionsPanel );
    quizAlgoSuperMemo2RadioButton = new QRadioButton( tr( "SuperMemo2Algorithm" ), quizAlgorithmOptionsPanel );
    if( prefs->getQuizAlgorithm() == Preferences::ORIGINAL )
        quizAlgoOriginalRadioButton->setChecked( true );
    else if( prefs->getQuizAlgorithm() == Preferences::SUPERMEMO2 )
        quizAlgoSuperMemo2RadioButton->setChecked( true );

    quizLengthSlider = new QSlider( 0, OriginalQuiz::poolCount - 1, 1, 1, QSlider::Horizontal, quizLengthOptionsPanel, "QuizLengthSlider" );
    quizLengthLabelsPanel = new QHBox( quizLengthOptionsPanel, "QuizLengthLabelsPanel" );
    quizLengthShortestLabel = new QLabel( tr( "QuizLengthShortest" ), quizLengthLabelsPanel, "QuizLengthShortestLabel" );
    quizLengthMediumLabel = new QLabel( tr( "QuizLengthMedium" ), quizLengthLabelsPanel, "QuizLengthMediumLabel" );
    quizLengthMediumLabel->setAlignment( QLabel::AlignCenter );
    quizLengthLongestLabel = new QLabel( tr( "QuizLengthLongest" ), quizLengthLabelsPanel, "QuizLengthLongestLabel" );
    quizLengthLongestLabel->setAlignment( QLabel::AlignRight );
    
    quizLengthSlider->setValue( prefs->getQuizLength() ); 

    quizPageFiller = new QWidget( quizPageBox, "QuizPageFiller" );

    quizLayout = new QVBoxLayout( quizPageBox );
    quizLayout->addWidget( quizAlgorithmsPanel );
    quizLayout->addWidget( quizCharacterImageOptionsPanel );
    quizLayout->addWidget( revealingOptionsPanel );
    quizLayout->addWidget( quizPageFiller, 1 );

    fontPage = new QWidget( tab, "FontPage" );

    //fontsPanel = new QVGroupBox( tr( "Fonts" ), fontPage, "FontsPanel" );
    fontsPanel = new QVBox( fontPage, "FontsPanel" );
    fontsPanel->setSpacing( 2 );

    labelsFontPanel = new QHBox( fontsPanel, "LabelsFontPanel" );
    labelsFontPanel->setSpacing( 2 );
    labelsFontLabel = new QLabel( tr( "LabelsFont" ), labelsFontPanel, "LabelsFontLabel" );
    labelsFontFamilyComboBox = new QComboBox( labelsFontPanel, "LabelsFontFamilyComboBox" );
    labelsFontSizeComboBox = new QComboBox( labelsFontPanel, "LabelsFontSizeComboBox" );
    resetDefaultLabelsFontButton = new QPushButton( tr( "ResetDefaultValue" ), labelsFontPanel, "ResetDefaultLabelsFontButton" );
    connect( resetDefaultLabelsFontButton, SIGNAL( clicked() ), this, SLOT( resetDefaultLabelsFont() ) );

    initFontFamilyValues( labelsFontFamilyComboBox );
    selectFontFamily( labelsFontFamilyComboBox, prefs->getLabelsFontFamily() );
    initFontSizeValues( labelsFontSizeComboBox );
    selectFontSize( labelsFontSizeComboBox, prefs->getLabelsFontSizeModifier() );

    fontPanel = new QHBox( fontsPanel, "FontPanel" );
    fontPanel->setSpacing( 2 );
    fontLabel = new QLabel( tr( "FieldsFont" ), fontPanel, "FontLabel" );
    fontFamilyComboBox = new QComboBox( fontPanel, "FontFamilyComboBox" );
    fontSizeComboBox = new QComboBox( fontPanel, "FontSizeComboBox" );
    resetDefaultFontButton = new QPushButton( tr( "ResetDefaultValue" ), fontPanel, "ResetDefaultFontButton" );
    connect( resetDefaultFontButton, SIGNAL( clicked() ), this, SLOT( resetDefaultFont() ) );

    initFontFamilyValues( fontFamilyComboBox );
    selectFontFamily( fontFamilyComboBox, prefs->getFontFamily() );
    initFontSizeValues( fontSizeComboBox );
    selectFontSize( fontSizeComboBox, prefs->getFontSizeModifier() );

    fontOverridesPanel = new QVGroupBox( tr( "LanguageFontOverrides" ), fontsPanel, "LanguageFontsPanel" );
    fontOverridesScrollView = new QScrollView( fontOverridesPanel, "FontOverridesScrollView" );
    fontOverridesScrollView->setResizePolicy( QScrollView::AutoOneFit );
    fontOverridesBox = new QWidget( fontOverridesScrollView->viewport() );
    fontOverridesBoxLayout = new QVBoxLayout( fontOverridesBox );
    fontOverridesScrollView->addChild( fontOverridesBox );
    initFontOverrides();

    fontPageFiller = new QWidget( fontPage, "FontPageFiller" );

    fontPageLayout = new QVBoxLayout( fontPage );
    fontPageLayout->setSpacing( 2 );
    fontPageLayout->addWidget( fontsPanel );
    fontPageLayout->addWidget( fontPageFiller, 1 );

    interfacePage = new QWidget( tab, "InterfacePage" );

    miscInterfaceOptionsPanel = new QGrid( 2, interfacePage, "MiscInterfaceOptionsPanel" );

    digraphPanel = new QVGroupBox( tr( "BuiltInSupportForAccents" ), miscInterfaceOptionsPanel, "DigraphPanel" );
    digraphCheckBox = new QCheckBox( tr( "DigraphesEnabled" ), digraphPanel, "DigraphCheckBox" );
    digraphCheckBox->setChecked( prefs->isDigraphEnabled() );

    hideQuizButtonPanel = new QVGroupBox( tr( "QuizOptions" ), miscInterfaceOptionsPanel, "HideQuizButtonPanel" );
    hideQuizButtonCheckBox = new QCheckBox( tr( "hideQuizButtons" ), hideQuizButtonPanel, "HideQuizButtonCheckBox" );
    hideQuizButtonCheckBox->setChecked( prefs->areQuizButtonsHidden() );

    showAltTextInTermListPanel = new QVGroupBox( tr( "GlossaryManagerOptions" ), miscInterfaceOptionsPanel, "ShowAltTextInTermListPanel" );
    showAltTextInTermListCheckBox = new QCheckBox( tr( "ShowAltInTermList" ), showAltTextInTermListPanel, "ShowAltInTermListCheckBox" );
    showAltTextInTermListCheckBox->setChecked( prefs->isAltInTermListShown() );

    keyboardAccelPanel = new QVGroupBox( tr( "Keyboard Accelerators" ), interfacePage, "KeyboardAccelPanel" );
    keyboardAccelListView = new SmartListView( keyboardAccelPanel, "KeyboardAccelListView" );
    keyboardAccelListView->addColumn( tr( "Action" ), 280 );
    keyboardAccelListView->addColumn( tr( "Key" ), 140 );
    keyboardAccelListView->setSorting( -1 );
    keyboardAccelListView->setAllColumnsShowFocus( true );
    keyboardAccelListView->setStretchColumn( 0 );
    int actionCount = sizeof( action ) / sizeof( QAction* );
    for( int i = actionCount - 1; i >= 0; i-- ) {
        KeyActionListViewItem* actionItem = new KeyActionListViewItem( keyboardAccelListView, action[ i ], (Action)i );
        actionItem->setText( 0, action[ i ]->text() );
        actionItem->setPixmap( 0, action[ i ]->iconSet().pixmap() );
        keyboardAccelListView->insertItem( actionItem );
    }
    connect( keyboardAccelListView, SIGNAL( returnPressed( QListViewItem* ) ), this, SLOT( keyActionClicked( QListViewItem* ) ) );
    connect( keyboardAccelListView, SIGNAL( currentChanged( QListViewItem* ) ), this, SLOT( cancelSetAccelKey() ) );
    connect( tab, SIGNAL( selected( const QString& ) ), this, SLOT( cancelSetAccelKey() ) );

    keyboardAccelButtonPanel = new QWidget( keyboardAccelPanel, "KeyboardAccelButtonPanel" );
    keyboardAccelButtonPanelFiller = new QWidget( keyboardAccelButtonPanel, "KeyboardAccelButtonPanelFiller" );  
    clearAccelKeyButton = new QPushButton( tr( "Clear key" ), keyboardAccelButtonPanel );
    setAccelKeyButton = new QPushButton( tr( "Set key" ), keyboardAccelButtonPanel );
    resetAccelKeyButton = new QPushButton( tr( "Reset key" ), keyboardAccelButtonPanel );
    
    keyboardAccelButtonPanelLayout = new QHBoxLayout( keyboardAccelButtonPanel );
    keyboardAccelButtonPanelLayout->setSpacing( 2 );
    keyboardAccelButtonPanelLayout->addWidget( keyboardAccelButtonPanelFiller, 1 );
    keyboardAccelButtonPanelLayout->addWidget( clearAccelKeyButton );
    keyboardAccelButtonPanelLayout->addWidget( setAccelKeyButton );
    keyboardAccelButtonPanelLayout->addWidget( resetAccelKeyButton );

    connect( clearAccelKeyButton, SIGNAL( clicked() ), this, SLOT( clearAccelKey() ) );
    connect( setAccelKeyButton, SIGNAL( clicked() ), this, SLOT( setAccelKey() ) );
    connect( resetAccelKeyButton, SIGNAL( clicked() ), this, SLOT( resetAccelKey() ) );

    interfacePageFiller = new QWidget( interfacePage, "InterfacePageFiller" );

    interfacePageLayout = new QVBoxLayout( interfacePage );
    interfacePageLayout->setSpacing( 2 );
    interfacePageLayout->addWidget( miscInterfaceOptionsPanel );
    interfacePageLayout->addWidget( keyboardAccelPanel );
    interfacePageLayout->addWidget( interfacePageFiller, 1 );

    languagePage = new QWidget( tab, "LanguagePage" );

    languagesPanel = new QVBox( languagePage, "LanguagesPanel" );
    languagesPanel->setSpacing( 2 );

    studyLanguagesListView = new SmartListView( languagesPanel, "StudyLanguagesListView" );
    studyLanguagesListView->setAllColumnsShowFocus( true );
    studyLanguagesListView->addColumn( tr( "StudyLanguages" ) );
    studyLanguagesListView->setStretchColumn( 0 );
    languagesPanel->setStretchFactor( studyLanguagesListView, 1 );
   
    languageUpdateNotifier = new LanguageUpdateNotifier();
    connect( languageUpdateNotifier, SIGNAL( languageAdded( const QString& ) ), this, SLOT( addFontOverride( const QString& ) ) );
    connect( languageUpdateNotifier, SIGNAL( languageRemoved( const QString& ) ), this, SLOT( removeFontOverride( const QString& ) ) );

    initStudyLanguageValues();

    languagesRightPanel = new QWidget( languagesPanel, "LanguagesRightPanel" );
    languagesRightPanelLayout = new QVBoxLayout( languagesRightPanel );

    languagesRightPanelFiller = new QWidget( languagesRightPanel, "LanguageRightPanelFiller" );

    languagesRightPanelLayout->addWidget( languagesRightPanelFiller, 1 );

    languageLayout = new QVBoxLayout( languagePage );
    languageLayout->setSpacing( 2 );
    languageLayout->addWidget( languagesPanel, 1 );

    tab->addTab( quizPage, tr( "Quiz" ) );
    tab->addTab( languagePage, tr( "Languages" ) );
    tab->addTab( fontPage, tr( "Fonts" ) );
    tab->addTab( interfacePage, tr( "Interface" ) );

    mainLayout = new QVBoxLayout( this );
    mainLayout->addWidget( tab, 1 );

    setCaption( tr( "Preferences..." ) );

    updateUi();
}