void CChangeOrderDlg::removeSelected(const CompactIntArray &selected) {
  CListBox *lb = getListBox();
  for(intptr_t i = selected.size() - 1; i >= 0; i--) {
    m_editList.removeIndex(selected[i]);
    lb->DeleteString(selected[i]);
  }
}
Exemple #2
0
void xSceneOpenDlg::OnFloderChanged()
{
    CListBox * listFloder = (CListBox *)GetDlgItem(IDC_SceneOpen_Floder);
    CListBox * listScene = (CListBox *)GetDlgItem(IDC_SceneOpen_Scene);

    while (listScene->GetCount())
        listScene->DeleteString(0);

    int isel = listFloder->GetCurSel();

    if (isel < 0)
        return ;

    CString strFloder;

    listFloder->GetText(isel, strFloder);

    ResourceGroup * rg = ResourceManager::Instance()->GetResourceGroup();

    Archive * ar = rg->GetArchive((LPCTSTR)strFloder);

    Archive::FileInfoVisitor v = ar->GetFileInfos();

    while (!v.eof())
    {
        const TString128 & filename = v.Cursor()->second.name;

        if (File::GetExternName(filename) == "scene")
        {
            listScene->AddString(filename.c_str());
        }

        ++v;
    }
}
Exemple #3
0
void SettingsDlg::OnDeltaposSpinModify(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
	CListBox *listbox;
	CListBox *listbox2;
	listbox = (CListBox*)GetDlgItem(IDC_AUDIO_CODECS_ALL);
	listbox2 = (CListBox*)GetDlgItem(IDC_AUDIO_CODECS);
	if (pNMUpDown->iDelta == -1) {
		//add
		int selected = listbox->GetCurSel();
		if (selected != LB_ERR) 
		{
			CString str;
			listbox->GetText(selected, str);
			listbox2->AddString(str);
			listbox->DeleteString(selected);
			listbox->SetCurSel( selected < listbox->GetCount() ? selected : selected-1 );
		}
	} else {
		//remove
		int selected = listbox2->GetCurSel();
		if (selected != LB_ERR) 
		{
			CString str;
			listbox2->GetText(selected, str);
			listbox->AddString(str);
			listbox2->DeleteString(selected);
			listbox2->SetCurSel( selected < listbox2->GetCount() ? selected : selected-1 );
		}
	}
	*pResult = 0;
}
Exemple #4
0
void CProjectView::OnLibdel() 
{
   int nItem;
   CListBox* pLB = (CListBox*)GetDlgItem(IDP_LIBLIST);
   nItem = pLB->GetCurSel();
   pLB->DeleteString(nItem);
}
Exemple #5
0
//客户端连接断开消息函数
LONG CTCPServerDlg::OnClientConnect(WPARAM wParam,LPARAM lParam)
{
	int iIndex;
	TCHAR *szAddress = (TCHAR*)lParam;
	CString strAddrss = szAddress;
	
	CListBox * pLstConn = (CListBox*)GetDlgItem(IDC_LST_CONN);
	ASSERT(pLstConn != NULL);

	if (wParam == 0)
	{
		pLstConn->AddString(strAddrss + _T("建立连接"));
	}
	else
	{
		iIndex = pLstConn->FindString(iIndex,strAddrss + _T("建立连接"));
		if (iIndex != LB_ERR)
		{
			pLstConn->DeleteString(iIndex); 
		}
	}

	//释放内存
	delete[] szAddress;
	szAddress = NULL;
	return 0;
}
Exemple #6
0
void xTerrainVegDlg::_UnloadScene(Event * sender)
{
	CListBox * list = (CListBox *)GetDlgItem(IDC_TV_List);

	while (list->GetCount())
		list->DeleteString(0);

	MForest::Instance()->RemoveAllVegetationBlock();
}
void CSpellBaseParmDlg::OnRemoveTotem() 
{
	CListBox *pList;
	pList = (CListBox *)GetDlgItem(IDC_REQUIRESTOTEM);

	int nCurSel = pList->GetCurSel();
	if (nCurSel != LB_ERR)

	pList->DeleteString(nCurSel);
}
Exemple #8
0
void CDizzyDialog::OnDeleteButton() 
{
	UpdateData(true);
	CListBox* pListBox = (CListBox*) GetDlgItem(IDC_INPUT_LIST);
	if (pListBox->DeleteString(pListBox->GetCurSel()) != LB_ERR) 
	{
		RecalculateRotation();
	}	
	UpdateData(false);
}
Exemple #9
0
void CSelectDialog::OnRemoveButtonClicked() {
	CListBox* fieldList = (CListBox*)GetDlgItem( IDC_FIELDLIST );
	CListBox* chosenList = (CListBox*)GetDlgItem( IDC_CHOSENLIST );
	for ( int i=chosenList->GetCount()-1; i>=0; i-- ) {
		if ( chosenList->GetSel( i ) ) {
			CString temp;
			chosenList->GetText( i, temp );
			fieldList->AddString( temp );
			chosenList->DeleteString( i );
		}
	}
}
Exemple #10
0
void CNewsHubDlg::OnBnClickedServerFinish()
{
  CListBox* pRunningServers = (CListBox*)GetDlgItem(IDC_RUNNING_SERVERS);
  
  int row = pRunningServers->GetCurSel();
  if (row != LB_ERR)
  {
    ServerLoop* serverLoop = (ServerLoop*)pRunningServers->GetItemDataPtr(row);
    delete serverLoop;
    pRunningServers->DeleteString(row);
  }
}
Exemple #11
0
void xTerrainVegDlg::_refrushList()
{
	CListBox * list = (CListBox *)GetDlgItem(IDC_TV_List);

	while (list->GetCount())
		list->DeleteString(0);

	for (int i = 0; i < MForest::Instance()->GetVegetationCount(); ++i)
	{
		MVegetation * veg = MForest::Instance()->GetVegetation(i);

		list->InsertString(i, veg->Name.c_str());
	}
}
Exemple #12
0
void CSelectDialog::OnDownButtonClicked() {
	CListBox* chosenList = (CListBox*)GetDlgItem( IDC_CHOSENLIST );
	for ( int i=chosenList->GetCount()-2; i>=0; i-- ) {
		if ( chosenList->GetSel( i ) ) {
			if ( !chosenList->GetSel( i+1 ) ) {
				char temp[4000];
				chosenList->GetText( i+1, temp );
				chosenList->InsertString( i, temp );
				chosenList->SetSel( i+2, TRUE );
				chosenList->DeleteString( i+2 );
			}
		}
	}
}
Exemple #13
0
void CGroupAddDialog::BuildAndRemoveSelected(CListBox& lb, std::vector<std::string>& str)
{
	str.clear();

	int	selcnt = lb.GetSelCount();
	if (selcnt) {
		int	*sels = new int[selcnt];
		lb.GetSelItems(selcnt, sels);
		for(int x=selcnt -1; x >= 0; --x) {
			str.push_back(lb.GetText(sels[x]));
			lb.DeleteString(sels[x]);
		}
	}
}
Exemple #14
0
void CSelectDialog::OnUpButtonClicked() {
	CListBox* chosenList = (CListBox*)GetDlgItem( IDC_CHOSENLIST );
	for ( int i=1; i<chosenList->GetCount(); i++ ) {
		if ( chosenList->GetSel( i ) ) {
			char temp[4000];
			if ( !chosenList->GetSel( i-1 ) ) {
				chosenList->GetText( i, temp );
				chosenList->InsertString( i-1, temp );
				chosenList->SetSel( i-1, TRUE );
				chosenList->DeleteString( i+1 );
			}
		}
	}
}
void CSaveMovieDialog::OnButtonRemove()
{
	CListBox * pListBox = (CListBox *)GetDlgItem(IDC_LIST_BITMAP_FILENAME);

	for (int i=0;i < pListBox->GetCount();i++)
	{
		if ( pListBox->GetSel(i) > 0 )
		{	
			//    selected.
			pListBox->DeleteString(i);
			i--;
		}
	}
}
Exemple #16
0
void CDizzyDialog::OnDownButton() 
{
	UpdateData(true);
	CListBox* pListBox = (CListBox*) GetDlgItem(IDC_INPUT_LIST);
	int iOffset = pListBox->GetCurSel();
	if ((iOffset != LB_ERR) && (iOffset != pListBox->GetCount()-1)) {
		CString strCurrent;
		pListBox->GetText(iOffset, strCurrent);
		pListBox->DeleteString(iOffset);
		iOffset++;
		pListBox->InsertString(iOffset, strCurrent);
		pListBox->SetCurSel(iOffset);
		RecalculateRotation();
	}
	UpdateData(false);
}
Exemple #17
0
void CPreferences::LoadPreferences()
{
	CListBox *listBox = (CListBox *)GetDlgItem(IDC_LIST_PREFERENCES);
	int prefCount = listBox->GetCount();
	// Remove all existing pre before reloading
	listBox->DeleteString(prefCount);
	ItrTableRowsCallbackData_CPreferences itSHTable(this,
		&CPreferences::ItrPreferencesTableRowsCallbackFn);
	FindDataBase prefDataBase(FDB_PrefDatabase, true);
	if (prefDataBase.Open() == 0) {
		itSHTable.IterateTableRows(prefDataBase, "Preferences");
	}
	CComboBox *pComboBox((CComboBox *)GetDlgItem(IDC_COMBO_DEFPREF));
	pComboBox->InsertString(0, _T(""));
	pComboBox->SelectString(0, mLoadedPreferenceName);
}
void CSaveMovieDialog::OnButtonUp()
{
	CListBox * pListBox = (CListBox *)GetDlgItem(IDC_LIST_BITMAP_FILENAME);
	if ( pListBox->GetSelCount() != 1 )
		return;

	if ( pListBox->GetCurSel() <= 0 )
		return;

	int sel = pListBox->GetCurSel();
	CString currentText;
	pListBox->GetText (sel, currentText );
	pListBox->InsertString(sel-1 , currentText);
	pListBox->DeleteString(sel+1);

	pListBox->SetSel(sel-1, TRUE);
}
void CCreatePatchGroupDlg::OnBnClickedButtonDelgroup()
{
	// TODO: Add your control notification handler code here
	CListBox* pList = (CListBox*)GetDlgItem(IDC_LIST_GROUPLIST);

	int nMaxItems = pList->GetSelCount();
	LPINT rgIndex = new INT[nMaxItems];
	memset(rgIndex, 0, sizeof(INT)*nMaxItems);
	pList->GetSelItems(nMaxItems, rgIndex);

	for (int i=0; i<nMaxItems; i++)
	{
		pList->DeleteString(rgIndex[i]-i);
	}

	delete []rgIndex;
}
Exemple #20
0
void CPreferences::OnBnClickedOk()
{
	// Call the funtion
	/// check which check box is sleated
	// Load/Save
	if (IsDlgButtonChecked(IDC_RADIO_SAVE)) { // Save
		CString prefName;
		GetDlgItemText(IDC_EDIT_PREFERENCE_NAME, prefName);
		CListBox *listBox = (CListBox *)GetDlgItem(IDC_LIST_PREFERENCES);
		int indexInListBox = listBox->FindString(-1, prefName);
		if (indexInListBox >= 0) { // Already has this preference name
			if (MessageBox(prefName + _T(" already exists.\nDo you want to overwrite."),
				0, MB_YESNO) == IDNO) {
					CEdit *pEdit((CEdit*)GetDlgItem(IDC_EDIT_PREFERENCE_NAME));
					pEdit->SetFocus();
					pEdit->SetSel(0, -1);
					return;
			}
		}
		SavePreference(prefName);
		listBox->AddString(prefName);
		((CComboBox *)GetDlgItem(IDC_COMBO_DEFPREF))->AddString(prefName);
	}
	else if (IsDlgButtonChecked(IDC_RADIO_LOAD)) { // Load
		CListBox *listBox = (CListBox *)GetDlgItem(IDC_LIST_PREFERENCES);
		int curSel = listBox->GetCurSel();
		if (curSel >= 0) { // User has selected
			CString prefName;
			listBox->GetText(curSel, prefName);
			LoadPreference(prefName);
		}
	}
	else if (IsDlgButtonChecked(IDC_RADIO_DELETE)) { // Delete
		CListBox *listBox = (CListBox *)GetDlgItem(IDC_LIST_PREFERENCES);
		int curSel = listBox->GetCurSel();
		if (curSel >= 0) { // User has selected
			CString prefName;
			listBox->GetText(curSel, prefName);
			if (DeletePreference(prefName)) {
				listBox->DeleteString(curSel);
				CComboBox *pComboBox((CComboBox *)GetDlgItem(IDC_COMBO_DEFPREF));
				pComboBox->DeleteString(pComboBox->FindString(1, prefName));
			}
		}
	}
}
Exemple #21
0
void CNewsHubDlg::MessageDelivered(NewsHub::ClientQueueThreadLoop* queue, const NewsHub::Socket & socket, const unsigned int messageId, const std::string & message)
{
  CListBox* pSentMessages = (CListBox*)GetDlgItem(IDC_SENT_MESSAGES);
  for (int i = 0; i < pSentMessages->GetCount(); ++i)
  {
    MessageInfo* messageInfo = (MessageInfo*)pSentMessages->GetItemDataPtr(i);
    if ((messageInfo->queue == queue) && (messageInfo->messageId == messageId))
    {
      CString str;
      pSentMessages->GetText(i, str);
      pSentMessages->DeleteString(i);
      pSentMessages->InsertString(i, str + _T(": Delivered"));
      pSentMessages->SetItemDataPtr(i, messageInfo);
      pSentMessages->SetCurSel(i);
      break;
    }
  }
}
Exemple #22
0
void CAddDlg::OnBnClickedOk()
{
	// 获得主窗口句柄,用来在列表框中增加数据(虽然这样不安全,但个人喜欢)
	CTextCodeConverterDlg* MainDlg = (CTextCodeConverterDlg*)this->GetParent();	
	ASSERT(MainDlg->GetSafeHwnd());

	// 取得主窗口中的列表框句柄
	CListBox* listBox = (CListBox*)MainDlg->GetDlgItem(IDC_LIST1);
	ASSERT(listBox->GetSafeHwnd());

	GetDlgItemText(IDC_EDIT1,m_strEdit);

	// 如果在启动窗口时为修改内容,则删除对应位置数据之后,然后在增加
	if (m_bUpdate == TRUE)
	{
		listBox->DeleteString(listBox->GetCurSel());
		listBox->InsertString(listBox->GetCurSel(),m_strEdit);
	}
	OnOK();
}
void CLoadFailedTextureDialog::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CDialog::OnShowWindow(bShow, nStatus);
	
	CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LOADFAILED_LIST);

	if (NULL != pListBox)
	{
		int i = 0;
		for (i = 0; i < pListBox->GetCount(); i++)
		{
			pListBox->DeleteString(0);
		}

		for (i = 0; i < (int)m_dwLoadFailedTextureTableCount; i++)
		{
			pListBox->InsertString(i, m_pLoadFailedTextureTable[i].szTextureName);
		}	
	}
	
}
Exemple #24
0
void CFanmotorDlg::RemoveBridgeEvent(BSTR BridgeID)
{
	int i;
	CListBox* listBoxBridges = (CListBox*)GetDlgItem(IDC_BRIDGE_LISTBOX);
	CBridgeInfo* bridgeInfo = NULL;
	
	for (i=0; i<listBoxBridges->GetCount(); i++)
	{
		bridgeInfo = (CBridgeInfo*)listBoxBridges->GetItemDataPtr(i);
		if (bridgeInfo->BridgeID == BridgeID) break;
	}
	if (i == listBoxBridges->GetCurSel())
	{
		CListBox* listBoxDevices = (CListBox*)GetDlgItem(IDC_DEVICE_LISTBOX);
		listBoxDevices->ResetContent();
//		ResetPowerSettings();
//		ResetSpeedSettings();
	}
	if ((i>=0)&&(i<=listBoxBridges->GetCount()))
	{
		delete bridgeInfo;
		listBoxBridges->DeleteString(i);
	}
}
void campaign_tree_view::drop_mission(int m, CPoint point)
{
	char name[MAX_FILENAME_LEN + 1];
	int i, item, level, pos;
	cmission *cm;
	mission a_mission;
	CListBox *listbox;

	level = query_level(point);
	pos = query_pos(point);
	Assert((level >= 0) && (pos >= 0));  // this should be impossible

	listbox = (CListBox *) &Campaign_tree_formp->m_filelist;
	item = listbox->GetCurSel();
	if (item == LB_ERR) {
		MessageBox("Select a mission from listbox to add.", "Error");
		return;
	}

	if (listbox->GetTextLen(item) > MAX_FILENAME_LEN) {
		char buf[256];

		sprintf(buf, "Filename is too long.  Must be %d or less characters.", MAX_FILENAME_LEN);
		MessageBox(buf, "Error");
		return;  // filename is too long.  Would overflow our buffer
	}

	// grab the filename selected from the listbox
	listbox->GetText(item, name);

	if (Campaign.num_missions >= MAX_CAMPAIGN_MISSIONS) {  // Can't add any more
		MessageBox("Too many missions.  Can't add more to Campaign.", "Error");
		return;
	}

	if (!level && (get_root_mission() >= 0)) {
		MessageBox("Only 1 mission may be in the top level");
		return;
	}

	// check the number of players in a multiplayer campaign against the number of players
	// in the mission that was just dropped
	if ( Campaign.type != CAMPAIGN_TYPE_SINGLE ) {
		get_mission_info(name, &a_mission);
		if ( !(a_mission.game_type & MISSION_TYPE_MULTI) ) {
			char buf[256];

			sprintf(buf, "Mission \"%s\" is not a multiplayer mission", name);
			MessageBox(buf, "Error");
			return;
		}

		if (Campaign.num_players != 0) {
			if (Campaign.num_players != a_mission.num_players) {
				char buf[512];

				sprintf(buf, "Mission \"%s\" has %d players.  Campaign has %d players.  Campaign will not play properly in FreeSpace", name, a_mission.num_players, Campaign.num_players );
				MessageBox(buf, "Warning");
			}

		} else {
			Campaign.num_players = a_mission.num_players;
		}
	}

	Elements[Campaign.num_missions].from_links = Elements[Campaign.num_missions].to_links = 0;
	cm = &(Campaign.missions[Campaign.num_missions++]);
	cm->name = strdup(name);
	cm->formula = Locked_sexp_true;
	cm->num_goals = -1;
	cm->notes = NULL;
	cm->briefing_cutscene[0] = 0;
	for (i=0; i<Campaign.num_missions - 1; i++)
		if ((Campaign.missions[i].level == level) && (Campaign.missions[i].pos + 1 == pos)) {
			pos = query_alternate_pos(point);
			break;
		}

	cm->level = level;
	cm->pos = pos - 1;
	correct_position(Campaign.num_missions - 1);
	sort_links();
	SetScrollSizes(MM_TEXT, CSize(total_width * CELL_WIDTH, total_levels * LEVEL_HEIGHT));
	Invalidate();

	// update and reinitialize dialog items
	if ( Campaign.type != CAMPAIGN_TYPE_SINGLE ) {
		Campaign_tree_formp->update();
		Campaign_tree_formp->initialize(0);
	}

	listbox->DeleteString(item);
	Campaign_modified = 1;
	return;
}
Exemple #26
0
void PSWelcomePowEditor::OnOK() 
{
	UpdateData();
	// If no power is selected and the choice was 'Modify', error.
	if (m_strSelectedPow == "" && 
		(m_nSelection == 1 || m_nSelection == 2))
	{
		MessageBox(L"Please select a power to continue.", L"DipSheet", MB_ICONEXCLAMATION);
		return;
	}

	PSPower* pCurPow = NULL;
	switch(m_nSelection)
	{
	case 0:// New
		{
		pCurPow = new PSPower;
		PSPowProp dlg;
		dlg.SetTitle(_T("New Power"));
		dlg.SetColor(::GetSysColor(COLOR_BTNFACE));
		dlg.m_strName = "";
		if (dlg.DoModal() == IDOK)
		{
			pCurPow->SetColor(dlg.GetColor());
			TG.AddPower(pCurPow);
			CListBox* pLB = (CListBox*)GetDlgItem(IDC_PROV_LIST);
			pLB->InsertString(-1, pCurPow->m_strName);
		}
		else 
			delete pCurPow;
		break;
		}
	case 1:// Modify
		{
		pCurPow = new PSPower(TG.GetPower(m_strSelectedPow));
		PSPowProp dlg;
		dlg.SetTitle(pCurPow->m_strName);
		dlg.SetColor(pCurPow->GetColor());
		dlg.m_strName = pCurPow->m_strName;
		if (dlg.DoModal() == IDOK)
		{
			pCurPow->SetColor(dlg.GetColor());
			TG.DeletePower(TG.GetPower(m_strSelectedPow));
			TG.AddPower(pCurPow);
			CListBox* pLB = (CListBox*)GetDlgItem(IDC_PROV_LIST);
			pLB->DeleteString(pLB->GetCurSel());
			pLB->InsertString(-1, pCurPow->m_strName);
		}
		else
			delete pCurPow;
		break;
		}
	case 2:// Remove
		pCurPow = TG.GetPower(m_strSelectedPow);
		ASSERT(pCurPow);
		if (MessageBox(L"Are you sure you wish to delete " + m_strSelectedPow + "?", L"DipSheet", MB_YESNO) == IDYES)
		{
			TG.DeletePower(pCurPow);
			CListBox* pLB = (CListBox*)GetDlgItem(IDC_PROV_LIST);
			pLB->DeleteString(pLB->GetCurSel());
		}
		return;
	default:
		ASSERT(0);
	}
}
/**
 * 파일을 지우는데, 지웠다는 마킹만 해 놓는 경우
 */
void CFV_Select::OnMenu_RemoveFilesB ()
{
	int *			pIndecies = NULL;	/// 선택된 파일인덱스를 여기에 저장
	CListBox *		plistSel = NULL;	/// 리스트박스에 대한 인스턴스
	int				nSelCnt = 0;		/// 선택된 갯수
	CString			strText;			/// 선택된 텍스트
	CVFS_Manager *	pVFS = ::g_pDlg_Main->GetVFS (); /// VFile Instance

	/// 선택된 갯수가 0보다 크고, 리스트박스 인스턴스가 유효하면
	if(m_list.GetSelCount () > 0 && (plistSel = GetListBox ()))
	{
		/// 선택된 갯수
		nSelCnt = m_list.GetSelCount ();
		/// 인덱스를 저장하기 위해서 메모리를 할당
		if((pIndecies = new int[ nSelCnt ]))
		{
			/// 선택된 인덱스를 가져온다
			m_list.GetSelItems (m_list.GetSelCount (), pIndecies);
			if(nSelCnt > 1 && pVFS)
			{
				/// 넘겨 주기 위해서
				char ** pFiles = new char *[ nSelCnt ];
				if(pFiles)
				{
					for(int i = 0; i < nSelCnt; i++)
					{
						/// 텍스트를 가져온다
						plistSel->GetText (pIndecies[ i ], strText);
						/// std::string에 저장한다. new로 메모리 할당하는 대신에 이 방법
						pFiles[ i ] = new char[ strText.GetLength () + 1];
						strcpy (pFiles[ i ], strText.GetString ());
					}

					if(pVFS && ::g_pDlg_Main->GetSelectedVfsName ().GetLength () > 0)
					{
						char buff [ 255 ];
						/// 삭제하기
						DWORD dwOldTime = timeGetTime ();
						bool bRemove= pVFS->RemoveFiles (::g_pDlg_Main->GetSelectedVfsName ().GetString (), 
														(const char **)pFiles, nSelCnt);
						DWORD dwNewTime = timeGetTime ();
						DWORD dwSec = (dwNewTime - dwOldTime) / 1000;
						
						if(bRemove)
						{
							/// 성공 메시지
							sprintf (buff, "%d초동안 %d개가 삭제되었습니다", dwSec, nSelCnt);
							MessageBox (buff, "파일 삭제", MB_OK | MB_ICONINFORMATION);
						}
						else
						{
							/// 실패 메시지
							sprintf (buff, "%d초동안 %d개가 삭제하는데 실패했습니다.", dwSec, nSelCnt);
							MessageBox (buff, "파일 삭제", MB_OK | MB_ICONINFORMATION);
						}
					}

					/// 메모리 해제
					delete pFiles;
				}
				else
				{
					/// 메모리 할당 실패했을때 에러 메시지 출력
					MessageBox ("메모리를 할당하는데 실패했습니다", "에러", MB_OK | MB_ICONWARNING);
				}
			}

			/// 텍스트를 지운다. 꼭 역순으로 지워야 한다
			for(int i = nSelCnt - 1; i >= 0 ; i--)
			{
				plistSel->DeleteString (pIndecies[ i ]);
			}
			delete pIndecies;
		}
	}
}
int CMessageEditorDlg::update(int num)
{
	char *ptr, buf[4096];
	int i, node, fnode;
	CListBox *list;

	UpdateData(TRUE);
	if (num >= 0)
	{
		ptr = (char *) (LPCTSTR) m_message_name;
		for (i=0; i<Num_messages; i++)
			if ((i != num) && (!stricmp(m_message_name, Messages[i].name)))
				break;

		if (i == Num_messages) {  // update name if no conflicts, otherwise keep old name
			update_sexp_references(Messages[num].name, ptr, OPF_MESSAGE);
			string_copy(Messages[num].name, m_message_name, NAME_LENGTH - 1);

			list = (CListBox *) GetDlgItem(IDC_MESSAGE_LIST);
			list->DeleteString(num);
			list->InsertString(num, m_message_name);
		}

		string_copy(Messages[num].message, m_message_text, MESSAGE_LENGTH - 1);
		if (Messages[num].avi_info.name)
			free(Messages[num].avi_info.name);

		ptr = (char *) (LPCTSTR) m_avi_filename;
		if (!ptr || !strlen(ptr))
			Messages[num].avi_info.name = NULL;
		else
			Messages[num].avi_info.name = strdup(ptr);

		if (Messages[num].wave_info.name)
			free(Messages[num].wave_info.name);

		ptr = (char *) (LPCTSTR) m_wave_filename;
		if (!ptr || !strlen(ptr))
			Messages[num].wave_info.name = NULL;
		else
			Messages[num].wave_info.name = strdup(ptr);

		// update the persona to the message.  We subtract 1 for the "None" at the beginning of the combo
		// box list.
		Messages[num].persona_index = m_persona - 1;

		if (m_tree.query_false()) {
			if (m_event_num >= 0) {  // need to delete event
				i = m_event_num;
				free_sexp2(Mission_events[i].formula);
				Assert(i < Num_mission_events);
				while (i < Num_mission_events - 1) {
					Mission_events[i] = Mission_events[i + 1];
					i++;
				}

				Num_mission_events--;
				m_event_num = -1;
			}

		} else {
			if (m_event_num >= 0)
				free_sexp2(Mission_events[m_event_num].formula);
			
			else {
				if (Num_mission_events == MAX_MISSION_EVENTS) {
					MessageBox("You have reached the limit on mission events.\n"
						"Can't add an event to send this message.");

					goto exit;
				}

				Assert(Num_mission_events < MAX_MISSION_EVENTS);
				m_event_num = Num_mission_events++;
				string_copy(Mission_events[m_event_num].name, m_message_name, NAME_LENGTH - 1);
				Mission_events[m_event_num].repeat_count = 1;
				Mission_events[m_event_num].interval = 1;
				Mission_events[m_event_num].score = 0;
				Mission_events[m_event_num].chain_delay = -1;
				Mission_events[m_event_num].objective_text = NULL;
				Mission_events[m_event_num].objective_key_text = NULL;
			}

			fnode = m_tree.save_tree();
			ptr = (char *) (LPCTSTR) m_message_name;
			node = alloc_sexp(ptr, SEXP_ATOM, SEXP_ATOM_STRING, -1, -1);
			((CComboBox *) GetDlgItem(IDC_PRIORITY))->GetLBText(m_priority, buf);
			node = alloc_sexp(buf, SEXP_ATOM, SEXP_ATOM_STRING, -1, node);
			((CComboBox *) GetDlgItem(IDC_SENDER))->GetLBText(m_sender, buf);
			node = alloc_sexp(buf, SEXP_ATOM, SEXP_ATOM_STRING, -1, node);
			node = alloc_sexp("send-message", SEXP_ATOM, SEXP_ATOM_OPERATOR, -1, node);
			node = alloc_sexp("", SEXP_LIST, SEXP_ATOM_LIST, node, -1);
			node = alloc_sexp("", SEXP_LIST, SEXP_ATOM_LIST, fnode, node);
			node = alloc_sexp("when", SEXP_ATOM, SEXP_ATOM_OPERATOR, -1, node);
			Mission_events[m_event_num].formula = node;
		}
	}

exit:
	if (query_modified())
		set_modified();

	modified = 0;
	return 0;
}
int event_editor::save_message(int num)
{
	char *ptr;
	int i, conflict = 0;
	CListBox *list;

	UpdateData(TRUE);
	if (num >= 0) {
		ptr = (char *) (LPCTSTR) m_message_name;
		for (i=0; i<Num_builtin_messages; i++){
			if (!stricmp(m_message_name, Messages[i].name)) {
				conflict = 1;
				break;
			}
		}

		for (i=0; i<m_num_messages; i++){
			if ((i != num) && (!stricmp(m_message_name, m_messages[i].name))) {
				conflict = 1;
				break;
			}
		}

		if (!conflict) {  // update name if no conflicts, otherwise keep old name
			string_copy(m_messages[num].name, m_message_name, NAME_LENGTH - 1);

			list = (CListBox *) GetDlgItem(IDC_MESSAGE_LIST);
			list->DeleteString(num);
			list->InsertString(num, m_message_name);
		}

		string_copy(m_messages[num].message, m_message_text, MESSAGE_LENGTH - 1);
		lcl_fred_replace_stuff(m_messages[num].message, MESSAGE_LENGTH);
		if (m_messages[num].avi_info.name){
			free(m_messages[num].avi_info.name);
		}

		ptr = (char *) (LPCTSTR) m_avi_filename;
		if ( !ptr || !VALID_FNAME(ptr) ) {
			m_messages[num].avi_info.name = NULL;
		} else {
			m_messages[num].avi_info.name = strdup(ptr);
		}

		if (m_messages[num].wave_info.name){
			free(m_messages[num].wave_info.name);
		}

		ptr = (char *) (LPCTSTR) m_wave_filename;
		if ( !ptr || !VALID_FNAME(ptr) ) {
			m_messages[num].wave_info.name = NULL;
		} else {
			m_messages[num].wave_info.name = strdup(ptr);
		}

		// update the persona to the message.  We subtract 1 for the "None" at the beginning of the combo
		// box list.
		m_messages[num].persona_index = m_persona - 1;

		if(m_message_team >= MAX_TVT_TEAMS){
			m_messages[num].multi_team = -1;
			m_message_team = -1;
		} else {
			m_messages[num].multi_team = m_message_team;
		}

		// possible TODO: auto-update event tree references to this message if we renamed it.
	}

	return 0;
}
Exemple #30
0
void ClearListBox(CListBox& box)
{
	while (box.GetCount() > 0)
		box.DeleteString(0);
}