Пример #1
0
// **************************************************************************
// AddItem ()
//
// Description:
//	Allows for the addition of a group's item(s).
//
// Parameters:
//  none
//
// Returns:
//  void
// **************************************************************************
void CKDocument::AddItem ()
	{
	// Get currently selected group:
	CKGroup *pGroup = GetSelectedGroup ();
	ASSERT (pGroup != NULL);

	// Get pointer to server that selected group belongs to:
	CKServer *pServer = pGroup->GetParentServer ();
	ASSERT (pServer != NULL);

	// Create an item add dialog.  Pass it a pointer to the group object
	// items are to be added to, and the associated OPC Server's browser
	// interface:
	CKItemAddDlg dlg (pGroup, pServer->GetIBrowse ());

	// Show as modal dialog.  If user hits "OK", we need to add items to 
	// project:
	if (dlg.DoModal () == IDOK)
		{
		// Get the number of items to add specified in dialog:
		int cnItems = dlg.GetItemCount ();

		// If number of items is non-zero, then add them to project:
		if (cnItems > 0)
			{
			// Get an object array containing the list of items to be added:
			CObArray &cList = dlg.GetItemList ();

			// If the number of items is large, then use a worker thread
			// to add them:
			if (cnItems > LARGE_ADDITEM_COUNT)
				{
				// Update status bar to indicate that we are adding items:
				CKStatusBarText cText (IDS_ADDING_ITEMS);

				// Create and fill a structure to pass to worker thread that
				// contains the items to add and specifies the "add items" task:
				WORKERTHREADARG tArg;
				tArg.eTask = WORKERTHREADARG::ADD_ITEMS;
				tArg.pvObjectA = (void *)&cList;
				tArg.pvObjectB = (void *)&cnItems;

				// Run a worker thread to add the items:
				RunWorkerThread (&tArg);
				}

			// Else if number of items is small, add them directly:
			else
				pGroup->AddItems (cList, cnItems);
			
			// Notify all views that item has been added:
			UpdateAllViews (NULL, HINT_ADD_ITEM, &cList);

			// Set document modified flag:
			SetModified ();
			}
		}
	}
Пример #2
0
void EditCoursesSongMenu::UpdateSongList()
{
	CString sGroup = GetSelectedGroup();

	m_aSongs.clear();
	const vector<Song*> &aSongs = SONGMAN->GetAllSongs();
	for( unsigned i = 0; i < aSongs.size(); ++i )
		if( !aSongs[i]->m_sGroupName.CompareNoCase(sGroup) )
			m_aSongs.push_back( aSongs[i] );

	m_iSelection[ROW_SONG] = 0;
}
Пример #3
0
// **************************************************************************
// AddItem ()
//
// Description:
//	Allows for the addition of a group's item(s).
//
// Parameters:
//	CObArray	&cList		Object array of items to add.
//	DWORD		dwCount		Number of items in cList.
//
// Returns:
//  void
// **************************************************************************
void CKDocument::AddItems (CObArray &cList, DWORD dwCount)
	{
	// Get the currently selected group:
	CKGroup *pGroup = GetSelectedGroup ();
	ASSERT (pGroup != NULL);

	// Add the items to the group:
	pGroup->AddItems (cList, dwCount);

	// Notify all views that items have been added:
	UpdateAllViews (NULL, HINT_ADD_ITEM, &cList);

	// Set the document modified flag:
	SetModified ();
	}
Пример #4
0
// **************************************************************************
// CloneGroup ()
//
// Description:
//	Allows for the cloning of a new group from an existing group. The new 
//	group will be attached the server's group list.
//
// Parameters:
//  none
//
// Returns:
//  void
// **************************************************************************
void CKDocument::CloneGroup ()
	{
	// Get currently selected group object:
	CKGroup *pSelGroup = GetSelectedGroup ();
	ASSERT (pSelGroup != NULL);

	// Clone group and save pointer to clone:
	CKGroup *pNewGroup = pSelGroup->Clone ();

	// If group was sucessfully cloned, indicated by non-NULL pointer, then
	// we need to update group view and set document modified flag:
	if (pNewGroup != NULL)
		{
		UpdateAllViews (NULL, HINT_ADD_GROUP, pNewGroup);
		SetModified ();
		}
	}
Пример #5
0
// **************************************************************************
// RemoveItems ()
//
// Description:
//	Allows for the removal of items on the selected group.
//
// Parameters:
//	CObArray	&cList			Object array of items to remove.
//	DWORD		dwCount			Number of items in cList.
//
// Returns:
//  void
// **************************************************************************
void CKDocument::RemoveItems (CObArray &cList, DWORD dwCount)
	{
	// Check that we specify a non-zero number of items (for debug only):
	ASSERT (dwCount > 0);

	
	// Get the currently selected group:
	CKGroup *pGroup = GetSelectedGroup ();
	ASSERT (pGroup != NULL);

	// Remove the items from the group:
	pGroup->RemoveItems (cList, dwCount);

	// Update the group view by reselecting the group:
	UpdateAllViews (NULL, HINT_SELECT_GROUP, (CObject *)pGroup);

	// Set the document modified flag:
	SetModified ();
	}
Пример #6
0
void EditCoursesSongMenu::SaveToCourseEntry( CourseEntry *pEntry )
{
	*pEntry = CourseEntry();
	pEntry->type = (CourseEntryType) m_iSelection[ROW_TYPE];

	/* Only set things relevant to this type. */
	if( g_bRowEnabledForType[pEntry->type][ROW_GROUP] )
		pEntry->group_name = GetSelectedGroup();
	if( g_bRowEnabledForType[pEntry->type][ROW_SONG] )
		pEntry->pSong = GetSelectedSong();
	if( g_bRowEnabledForType[pEntry->type][ROW_DIFFICULTY] )
		pEntry->difficulty = GetSelectedDifficulty();
	if( g_bRowEnabledForType[pEntry->type][ROW_LOW_METER] )
		pEntry->low_meter = GetLowMeter();
	if( g_bRowEnabledForType[pEntry->type][ROW_HIGH_METER] )
		pEntry->high_meter = GetHighMeter();
	if( g_bRowEnabledForType[pEntry->type][ROW_BEST_WORST_VALUE] )
		pEntry->players_index = GetBestWorst();

	if( pEntry->high_meter < pEntry->low_meter )
		swap( pEntry->low_meter, pEntry->high_meter );
}
Пример #7
0
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
	}
}
Пример #8
0
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
	}
}