void EditCoursesSongMenu::ChangeToRow( Row newRow ) { m_SelectedRow = newRow; for( int i=0; i<2; i++ ) m_sprArrows[i].SetY( ROW_Y(newRow) ); m_sprArrows[0].SetDiffuse( CanGoLeft()?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); m_sprArrows[1].SetDiffuse( CanGoRight()?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); m_sprArrows[0].EnableAnimation( CanGoLeft() ); m_sprArrows[1].EnableAnimation( CanGoRight() ); }
int CPlainTextEditor::FindWordRight(int iPos) { char c; c = mszText.GetChar(iPos); if (IsWhiteSpace(c)) { for (;;) { if (CanGoRight(iPos)) { iPos++; c = mszText.GetChar(iPos); if (!IsWhiteSpace(c)) { return iPos; } } else { return iPos; } } } else if (IsNormalChar(c)) { for (;;) { if (CanGoRight(iPos)) { iPos++; c = mszText.GetChar(iPos); if (!IsNormalChar(c)) { return iPos; } } else { return iPos; } } } else { if (CanGoRight(iPos)) { iPos++; } return iPos; } }
void CPlainTextEditor::CutLine(CChars* pszDest) { int iCount; int iStart; int iEnd; if (!IsSelected()) { iCount = GetCharCountAlongLine(miEditPos); iStart = FindStartOfLine(miEditPos); iEnd = FindEndOfLine(miEditPos); if (CanGoRight(iEnd)) { iEnd++; } pszDest->AppendSubString(mszText, iStart, iEnd); mszText.Remove(iStart, iEnd); ResetUpDown(); miEditPos = FindPositionAlongLine(iStart, iCount); } else { Cut(pszDest); } }
int CPlainTextEditor::FindRight(int iCurrentPos) { if (CanGoRight(iCurrentPos)) { iCurrentPos++; } return iCurrentPos; }
void ScreenMiniMenu::MenuRight( PlayerNumber pn, const InputEventType type ) { if( CanGoRight() ) { m_iCurAnswers[m_iCurLine]++; AfterAnswerChanged(); } }
bool ScreenPrompt::MenuRight( const InputEventPlus &input ) { if( CanGoRight() ) { Change( +1 ); return true; } return false; }
void EditMenu::Right() { if( CanGoRight() ) { m_iSelection[m_SelectedRow]++; OnRowValueChanged( m_SelectedRow ); m_soundChangeValue.PlayRandom(); } }
void EditCoursesSongMenu::Right() { if( CanGoRight() ) { m_iSelection[m_SelectedRow]++; OnRowValueChanged( m_SelectedRow ); m_soundChangeValue.Play(); } }
void PlayerControl( int player ) { int a = player, b = player; bool moved = false; if( players == 1 ) { a = 0; b = 1; } if( hitKey[a].left || hitKey[b].left ) { if( GameTickCount() >= timeMove[player] ) { timeMove[player] += 12; if( CanGoLeft( player ) ) GoLeft( player ); } moved = true; } if( hitKey[a].right || hitKey[b].right ) { if( GameTickCount() >= timeMove[player] ) { timeMove[player] += 12; if( CanGoRight( player ) ) GoRight( player ); } moved = true; } if( !moved ) timeMove[player] = GameTickCount( ); if( hitKey[a].rotate == 1 || hitKey[b].rotate == 1 ) { if( CanRotate( player ) ) DoRotate( player ); } if( hitKey[a].drop == 1 || hitKey[b].drop == 1 ) { DoDrop( player ); } if( hitKey[a].drop == 0 && hitKey[b].drop == 0 ) { StopDrop( player ); } }
void EditCoursesMenu::ChangeToRow( Row newRow ) { m_SelectedRow = newRow; const float fRowY = ROW_Y(newRow); const bool bCanGoLeft = CanGoLeft(), bCanGoRight = CanGoRight(); m_sprArrows[0].SetY( fRowY ); m_sprArrows[1].SetY( fRowY ); m_sprArrows[0].SetDiffuse( bCanGoLeft?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); m_sprArrows[1].SetDiffuse( bCanGoRight?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); m_sprArrows[0].EnableAnimation( bCanGoLeft ); m_sprArrows[1].EnableAnimation( bCanGoRight ); }
void CPlainTextEditor::Delete(void) { if (!IsSelected()) { if (CanGoRight(miEditPos)) { mszText.RemoveCharacter(miEditPos); ResetUpDown(); } } else { miEditPos = DeleteSelection(); ResetUpDown(); } }
void AIControl( int player ) { if( timeAI[player] > GameTickCount() ) return; timeAI[player] += moveQuick[player]? character[player].speedRush: character[player].speedNormal; switch( RandomBefore( 2 ) ) { case 0: if( destinationR[player] != blobR[player] ) { if( CanRotate(player) ) { DoRotate( player ); } } break; case 1: if( destinationX[player] != blobX[player] ) { if( destinationX[player] > blobX[player] ) { if( CanGoRight( player ) ) GoRight( player ); } else { if( CanGoLeft( player ) ) GoLeft( player ); } } break; } if( destinationX[player] == blobX[player] && destinationR[player] == blobR[player] && RandomBefore( 100 ) < character[player].intellect ) { DoDrop( player ); } }
void CPlainTextEditor::DeleteLine(void) { int iCount; int iStart; int iEnd; iCount = GetCharCountAlongLine(miEditPos); if (!IsSelected()) { iStart = FindStartOfLine(miEditPos); iEnd = FindEndOfLine(miEditPos); } else { if (miSelectionAnchor < miSelectionFloating) { iStart = miSelectionAnchor; iEnd = miSelectionFloating; } else { iStart = miSelectionFloating; iEnd = miSelectionAnchor; } iStart = FindStartOfLine(iStart); iEnd = FindEndOfLine(iEnd); } if (CanGoRight(iEnd)) { iEnd++; } mszText.Remove(iStart, iEnd); ResetUpDown(); miEditPos = FindPositionAlongLine(iStart, iCount); }
void EditCoursesMenu::Right() { if( m_bInSongMenu ) { m_SongMenu.Right(); return; } if( CanGoRight() ) { m_iSelection[m_SelectedRow]++; switch( m_SelectedRow ) { case ROW_ENTRY_TYPE: GetSelectedEntry()->type = GetSelectedEntryType(); break; } OnRowValueChanged( m_SelectedRow ); m_soundChangeValue.Play(); } }
void DoRotate( int player ) { MBoolean possible; EraseSpriteBlobs( player ); blobR[player] = ( blobR[player] + 1 ) % 4; possible = CanMoveDirection( player, 0, halfway[player]? 1: 0 ); StartTweak( player, 0, 1, 0 ); // only rotates clockwise if( !possible ) { if( blobR[player] == downRotate ) { if( halfway[player] ) halfway[player] = false; else blobY[player]--; if( ++blobSpin[player] >= 4 ) { blobTime[player] = animTime[player] = GameTickCount( ); role[player] = kLockdownBlobs; anim[player] = 0; PlayStereoFrequency( player, kPlace, player ); } } if( blobR[player] == leftRotate ) { if( CanGoRight(player) ) GoRight( player ); else { blobR[player]++; StartTweak( player, 0, 2, 0 ); } } if( blobR[player] == rightRotate ) { if( CanGoLeft(player) ) GoLeft( player ); else { blobR[player]++; StartTweak( player, 0, 2, 0 ); if( !CanMoveDirection( player, 0, halfway[player]? 1: 0 ) ) { if( halfway[player] ) halfway[player] = false; else blobY[player]--; if( ++blobSpin[player] >= 4 ) { blobTime[player] = animTime[player] = GameTickCount( ); role[player] = kLockdownBlobs; anim[player] = 0; PlayStereoFrequency( player, kPlace, player ); } } } } } DrawSpriteBlobs( player, kNoSuction ); PlayStereo( player, kRotate ); }
void EditMenu::OnRowValueChanged( Row row ) { m_sprArrows[0].SetDiffuse( CanGoLeft()?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); m_sprArrows[1].SetDiffuse( CanGoRight()?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); m_sprArrows[0].EnableAnimation( CanGoLeft() ); m_sprArrows[1].EnableAnimation( CanGoRight() ); switch( row ) { case ROW_GROUP: m_textValue[ROW_GROUP].SetText( SONGMAN->ShortenGroupName(GetSelectedGroup()) ); m_GroupBanner.LoadFromGroup( GetSelectedGroup() ); m_GroupBanner.ScaleToClipped( GROUP_BANNER_WIDTH, GROUP_BANNER_HEIGHT ); m_pSongs.clear(); SONGMAN->GetSongs( m_pSongs, GetSelectedGroup() ); m_iSelection[ROW_SONG] = 0; // fall through case ROW_SONG: m_textValue[ROW_SONG].SetText( "" ); m_SongBanner.LoadFromSong( GetSelectedSong() ); m_SongBanner.ScaleToClipped( SONG_BANNER_WIDTH, SONG_BANNER_HEIGHT ); m_SongTextBanner.LoadFromSong( GetSelectedSong() ); // fall through case ROW_STEPS_TYPE: m_textValue[ROW_STEPS_TYPE].SetText( GAMEMAN->StepsTypeToString(GetSelectedStepsType()) ); // fall through case ROW_DIFFICULTY: m_textValue[ROW_DIFFICULTY].SetText( DifficultyToString(GetSelectedDifficulty()) ); m_Meter.SetFromSteps( GetSelectedNotes() ); // fall through case ROW_SOURCE_STEPS_TYPE: m_textLabel[ROW_SOURCE_STEPS_TYPE].SetDiffuse( GetSelectedNotes()?RageColor(1,1,1,0):RageColor(1,1,1,1) ); m_textValue[ROW_SOURCE_STEPS_TYPE].SetDiffuse( GetSelectedNotes()?RageColor(1,1,1,0):RageColor(1,1,1,1) ); m_textValue[ROW_SOURCE_STEPS_TYPE].SetText( GAMEMAN->StepsTypeToString(GetSelectedSourceStepsType()) ); // fall through case ROW_SOURCE_DIFFICULTY: m_textLabel[ROW_SOURCE_DIFFICULTY].SetDiffuse( GetSelectedNotes()?RageColor(1,1,1,0):RageColor(1,1,1,1) ); m_textValue[ROW_SOURCE_DIFFICULTY].SetDiffuse( GetSelectedNotes()?RageColor(1,1,1,0):RageColor(1,1,1,1) ); m_textValue[ROW_SOURCE_DIFFICULTY].SetText( DifficultyToString(GetSelectedSourceDifficulty()) ); m_SourceMeter.SetFromSteps( GetSelectedSourceNotes() ); m_SourceMeter.SetZoomY( GetSelectedNotes()?0.f:1.f ); m_Actions.clear(); if( GetSelectedNotes() ) { m_Actions.push_back( ACTION_EDIT ); m_Actions.push_back( ACTION_DELETE ); } else if( GetSelectedSourceNotes() ) { m_Actions.push_back( ACTION_COPY ); m_Actions.push_back( ACTION_AUTOGEN ); m_Actions.push_back( ACTION_BLANK ); } else { m_Actions.push_back( ACTION_BLANK ); } m_iSelection[ROW_ACTION] = 0; // fall through case ROW_ACTION: m_textValue[ROW_ACTION].SetText( ActionToString(GetSelectedAction()) ); break; default: ASSERT(0); // invalid row } }
void ScreenPrompt::MenuRight( const InputEventPlus &input ) { if( CanGoRight() ) Change( +1 ); }
void AutoControl( int player ) { if( autoPattern ) { switch( autoPattern->command ) { case kMessage: StartBalloon( autoPattern->message ); autoPattern++; break; case kIdleTicks: if( !tutorialTime ) { tutorialTime = GameTickCount() + autoPattern->d1; } else { if( GameTickCount() >= tutorialTime ) { tutorialTime = 0; autoPattern++; } } break; case kRetrieve: if( role[player] == kWaitForRetrieval ) { nextA[player] = abs( autoPattern->d1 ); nextB[player] = abs( autoPattern->d2 ); nextM[player] = (autoPattern->d1 < 0); nextG[player] = (autoPattern->d1 == kBombBottom) && (autoPattern->d2 == kBombTop); if( !nextG[player] ) { nextA[player] = pieceMap[ nextA[player] ]; nextB[player] = pieceMap[ nextB[player] ]; } role[player] = kRetrieveBlobs; autoPattern++; } break; case kPosition: if( (role[player] != kFalling) || (blobX[player] == autoPattern->d1) ) { autoPattern++; } else if( GameTickCount() >= timeMove[player] ) { timeMove[player] = GameTickCount() + 12; if( blobX[player] > autoPattern->d1 ) { if( CanGoLeft( player ) ) GoLeft( player ); } else { if( CanGoRight( player ) ) GoRight( player ); } } break; case kSpin: if( role[player] != kFalling ) { autoPattern++; } else if( CanRotate( player ) ) { DoRotate( player ); autoPattern++; } break; case kBlockUntilLand: if( role[player] != kFalling ) { autoPattern++; } break; case kBlockUntilDrop: if( !dropping[player] ) DoDrop( player ); if( role[player] != kFalling ) { autoPattern++; } break; case kPunish: if( role[player] == kWaitForRetrieval ) { lockGrays[player] = autoPattern->d1; SetupGrays( player ); blobTime[player] = GameTickCount( ); role[player] = kDropGrays; autoPattern++; } break; case kComplete: EndTutorial( ); break; case kBlockUntilComplete: if( role[player] == kWaitForRetrieval ) { autoPattern++; } break; } } }
void EditCoursesSongMenu::OnRowValueChanged( Row row ) { LOG->Trace( "EditCoursesSongMenu::OnRowValueChanged(%i)", row ); m_sprArrows[0].SetDiffuse( CanGoLeft()?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); m_sprArrows[1].SetDiffuse( CanGoRight()?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); m_sprArrows[0].EnableAnimation( CanGoLeft() ); m_sprArrows[1].EnableAnimation( CanGoRight() ); CString sGroup = GetSelectedGroup(); Song *pSong = GetSelectedSong(); switch( row ) { case ROW_GROUP: { CHECKPOINT; m_textValue[ROW_GROUP].SetText( sGroup ); UpdateSongList(); pSong = GetSelectedSong(); } // fall through case ROW_SONG: CHECKPOINT; m_textValue[ROW_SONG].SetText( pSong? pSong->GetTranslitMainTitle():CString("") ); // fall through case ROW_TYPE: CHECKPOINT; m_textValue[ROW_TYPE].SetText( CourseEntryTypeToString(GetSelectedType()) ); for( int i = 0; i < NUM_ROWS; ++i ) m_textValue[i].SetDiffuse( g_bRowEnabledForType[GetSelectedType()][i]? RageColor(1,1,1,1):RageColor(0.4f,0.4f,0.4f,1) ); // fall through case ROW_DIFFICULTY: { CHECKPOINT; Difficulty dc = GetSelectedDifficulty(); if( dc == DIFFICULTY_INVALID ) m_textValue[ROW_DIFFICULTY].SetText( "(any)" ); else m_textValue[ROW_DIFFICULTY].SetText( DifficultyToString(dc) ); // fall through } case ROW_LOW_METER: CHECKPOINT; if( GetLowMeter() == -1 ) m_textValue[ROW_LOW_METER].SetText( "(any)" ); else m_textValue[ROW_LOW_METER].SetText( ssprintf("%d",GetLowMeter()) ); // fall through case ROW_HIGH_METER: CHECKPOINT; if( GetHighMeter() == -1 ) m_textValue[ROW_HIGH_METER].SetText( "(any)" ); else m_textValue[ROW_HIGH_METER].SetText( ssprintf("%d",GetHighMeter()) ); // fall through case ROW_BEST_WORST_VALUE: CHECKPOINT; m_textValue[ROW_BEST_WORST_VALUE].SetText( ssprintf("%d",GetBestWorst()+1) ); break; default: ASSERT(0); // invalid row } }
void EditCoursesMenu::OnRowValueChanged( Row row ) { LOG->Trace( "EditCoursesMenu::OnRowValueChanged(%i)", row ); const bool bCanGoLeft = CanGoLeft(), bCanGoRight = CanGoRight(); m_sprArrows[0].SetDiffuse( bCanGoLeft?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); m_sprArrows[1].SetDiffuse( bCanGoRight?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); m_sprArrows[0].EnableAnimation( bCanGoLeft ); m_sprArrows[1].EnableAnimation( bCanGoRight ); Course* pCourse = GetSelectedCourse(); CourseEntry* pEntry = GetSelectedEntry(); switch( row ) { case ROW_COURSE: CHECKPOINT; m_textValue[ROW_COURSE].SetText( pCourse->GetFullDisplayTitle() ); m_CourseBanner.LoadFromCourse( pCourse ); m_CourseBanner.ScaleToClipped( COURSE_BANNER_WIDTH, COURSE_BANNER_HEIGHT ); m_iSelection[ROW_ENTRY] = 0; pEntry = GetSelectedEntry(); if( pEntry == NULL ) { CourseEntry ce; const vector<Song*> &apSongs = SONGMAN->GetAllSongs(); ASSERT( !apSongs.empty() ); ce.pSong = apSongs[0]; pCourse->m_entries.push_back( ce ); pEntry = GetSelectedEntry(); } // fall through case ROW_COURSE_OPTIONS: CHECKPOINT; m_textValue[ROW_COURSE_OPTIONS].SetText( ssprintf( "(START) %s, %s, ", pCourse->m_bRepeat ? "repeat" : "no repeat", pCourse->m_bRandomize ? "randomize" : "no randomize" ) + ssprintf( (pCourse->m_iLives==-1) ? "use bar life" : "%d lives", pCourse->m_iLives ) ); // fall through case ROW_ACTION: CHECKPOINT; m_textValue[ROW_ACTION].SetText( "(START) " + ActionToString(GetSelectedAction()) ); // fall through case ROW_ENTRY: CHECKPOINT; m_textValue[ROW_ENTRY].SetText( ssprintf("%d of %d",m_iSelection[ROW_ENTRY]+1, (int)GetSelectedCourse()->m_entries.size()) ); m_iSelection[ROW_ENTRY_TYPE] = pEntry->type; // fall through case ROW_ENTRY_TYPE: CHECKPOINT; m_textValue[ROW_ENTRY_TYPE].SetText( pEntry ? CourseEntryTypeToString(pEntry->type) : CString("(none)") ); // fall through case ROW_ENTRY_OPTIONS: CHECKPOINT; { CStringArray as; const bool *bShow = g_bRowEnabledForType[GetSelectedEntry()->type]; if( bShow[song] ) as.push_back( pEntry->pSong ? pEntry->pSong->GetFullTranslitTitle() : CString("(missing song)") ); if( bShow[group] ) as.push_back( pEntry->group_name.empty() ? CString("(no group)") : pEntry->group_name ); if( bShow[difficulty] ) if( pEntry->difficulty != DIFFICULTY_INVALID ) as.push_back( DifficultyToString(pEntry->difficulty) ); if( bShow[low_meter] ) if( pEntry->low_meter > 0 ) as.push_back( ssprintf("low meter %d", pEntry->low_meter) ); if( bShow[high_meter] ) if( pEntry->high_meter > 0 ) as.push_back( ssprintf("high meter %d", pEntry->high_meter) ); if( bShow[best_worst_value] ) if( pEntry->players_index != -1 ) as.push_back( ssprintf("rank %d", pEntry->players_index+1) ); m_textValue[ROW_ENTRY_OPTIONS].SetText( "(START) " + join(", ",as) ); } // fall through case ROW_ENTRY_PLAYER_OPTIONS: CHECKPOINT; { CString s = "(START) "; PlayerOptions po; po.FromString( pEntry->modifiers ); if( po.GetString().empty() ) s += "(none)"; else s += po.GetString(); m_textValue[ROW_ENTRY_PLAYER_OPTIONS].SetText( s ); } // fall through case ROW_ENTRY_SONG_OPTIONS: CHECKPOINT; { CString s = "(START) "; SongOptions so; so.FromString( pEntry->modifiers ); if( so.GetString().empty() ) s += "(none)"; else s += so.GetString(); m_textValue[ROW_ENTRY_SONG_OPTIONS].SetText( s ); } break; default: ASSERT(0); // invalid row } }