⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialog.cpp

📁 凌星科技_2004-5-17_《圣剑英雄传II》的源代码scr2
💻 CPP
📖 第 1 页 / 共 3 页
字号:
					*/
					map.LoadMap(strTemp2);									//加载地图
					//_FREE(strTemp2);

					//strcpy(CurrentPath,strTemp1);							//恢复当前路径
					//SetCurrentDirectory(CurrentPath);*/
				}
				break;

			//打开文件名
			case ID_MENUITEM_Open:
				if( _LoadMap(hDlg) )
				{
					SetWindowText(hDlg, map.CurrentMapFileName);

					//显示地图信息
					SetDlgItemText( hDlg, IDC_EDIT_Name, map.Name);
					SetDlgItemInt( hDlg, IDC_EDIT_Width, map.Width-1, TRUE);
					SetDlgItemInt( hDlg, IDC_EDIT_Height, map.Height-1, TRUE);

					EndDialog(hDlg,false);
					return true;
				}
				break;

			//保存地图
			case ID_MENUITEM_Save:
				_SaveMap(hDlg);
				EndDialog(hDlg,false);
				break;

			//另存地图
			case ID_MENUITEM_SaveAs:
				if( _SaveAsMap(hDlg) )
				{
					SetWindowText(hDlg, map.CurrentMapFileName);
					GetDlgItemText(hDlg, IDC_EDIT_Name, map.Name, 32);
					EndDialog(hDlg,false);
					return true;
				}
				break;

			case ID_MENUITEM_Undo:		//反悔一步

				tmp=map.Cell;
				map.Cell=UndoMap;
				UndoMap=tmp;

				EndDialog(hDlg,false);
				return true;

			case ID_MENUITEM_RestoreLevel:	//恢复层次关系
				{
					static l=1;
					l=1-l;
					memcpy( UndoMap,map.Cell, sizeof(Cell_Struct)*map.Width*map.Height);
					map.RestoreLevel(l);
					EndDialog(hDlg,false);
					return true;
				}

			case ID_MENUITEM_RestoreBlock:	//恢复阻挡关系
				{
					static l=1;
					l=1-l;
					memcpy( UndoMap,map.Cell, sizeof(Cell_Struct)*map.Width*map.Height);
					map.RestoreBlock(l);
					EndDialog(hDlg,false);
					return true;
				}

			case ID_MENUITEM_RestoreMouseType:	//恢复鼠标状态
				{
					memcpy( UndoMap,map.Cell, sizeof(Cell_Struct)*map.Width*map.Height);
					map.RestoreMouseType(CCursor::CS_NORMAL);
					EndDialog(hDlg,false);
					return true;
				}

			//设置敌人
			case ID_MENUITEM_Enemy:
				CreateDlg(IDD_DIALOG_EnemySet, DialogEnemySetListProc);
				break;

			//格子属性
			case ID_MENUITEM_Cell:
				CreateDlg(IDD_DIALOG_Object, DialogObjectProc);
				break;

			//设置陷阱
			case ID_MENUITEM_SetHook:
				CreateDlg(IDD_DIALOG_Hook, (DLGPROC)DialogChangePointListProc);
				break;

			//删除陷阱
			case ID_MENUITEM_DelHook:
				memcpy( UndoMap,map.Cell, sizeof(Cell_Struct)*map.Width*map.Height);
				map.Cell[map.Width*cy+cx].CP=BLOCK_CP;
				break;

			//显示缩略图
			case ID_MENUITEM_FullMap:
				map.ShowFullMap();
				break;
			}
			break;

	    case WM_DESTROY:
            return TRUE;
            break;

        default:
            return false;
    }
return true;
}

/////////////////////////////////////////////////////////////////////
//
//*****************************
//陷阱点列表窗口消息
BOOL APIENTRY DialogChangePointListProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
	UINT idCommand;
	static int Sel=-1;

	HWND hListBox, hComBoxMouseType,hComBoxHookType;
	hListBox=GetDlgItem(hDlg, IDC_LIST_ChangePoint);
	hComBoxMouseType=GetDlgItem(hDlg, IDC_COMBO_CPType);
	hComBoxHookType = GetDlgItem(hDlg, IDC_COMBO_HOOKTYPE);

    switch (message)
    {
        case WM_INITDIALOG:
			{

			//定位到中心点
			RECT rect;
			GetWindowRect(hDlg, &rect);
			int w=rect.right-rect.left;
			int h=rect.bottom-rect.top;
			if( WindowMode==1 )	//窗口
				MoveWindow(hDlg, RectWindow.left+(ScreenWidth-w)/2, RectWindow.top+(ScreenHeight-h)/2, w, h, TRUE);
			else
				MoveWindow(hDlg, (ScreenWidth-w)/2, (ScreenHeight-h)/2, w, h, TRUE);
			
			//初始化列表框
			if( map.Hook_Num>0 )
			{
				for(int i=map.Hook_Num-1; i>=0; i--)
				{
					char List[128];
					sprintf(List, "(%d) %s",i,map.Hook[i]);
					SendMessage(hListBox, LB_INSERTSTRING, 0, (LPARAM)List);
				}
			}

			SetDlgItemInt(hDlg, IDC_EDIT_ox, cx, true);
			SetDlgItemInt(hDlg, IDC_EDIT_oy, cy, true);

			Sel=-1;

			//初始化陷阱类型复选框
			for(int i=0; i<CCursor::GetCursorNum(); i++)
			{
				SendMessage(hComBoxMouseType, CB_ADDSTRING, 0, (LPARAM)CCursor::GetCursor(i).strName);
			}
			SendMessage(hComBoxHookType, CB_ADDSTRING, 0, (LPARAM)"非切换点");
			SendMessage(hComBoxHookType, CB_ADDSTRING, 0, (LPARAM)"切换点");
			SendMessage(hComBoxMouseType, CB_SETCURSEL, map.Cell[map.Width*cy+cx].MouseType, 0);
			SendMessage(hComBoxHookType, CB_SETCURSEL, map.Cell[map.Width*cy+cx].CPType, 0);

			//显示当前的选项
			if( map.Cell[map.Width*cy+cx].CP != BLOCK_CP )
			{
				Sel=map.Cell[map.Width*cy+cx].CP;
				SendMessage(hListBox, LB_SETCURSEL, Sel, 0);
			}

			ShowWindow(hDlg,SW_SHOW);
			UpdateWindow(hWnd);
			
			}
            return TRUE;
            break;

		case WM_COMMAND:
			idCommand=LOWORD(wParam);
			switch( idCommand )
			{
			//确定
			case IDOK:
				map.Cell[map.Width*cy+cx].CP=Sel;
				map.Cell[map.Width*cy+cx].MouseType=SendMessage(hComBoxMouseType, CB_GETCURSEL, 0, 0);
				map.Cell[map.Width*cy+cx].CPType= SendMessage(hComBoxHookType, CB_GETCURSEL, 0, 0);
				EndDialog(hDlg,false);
				return true;

			//取消
			case IDCANCEL:
				EndDialog(hDlg,false);
				return true;


			//添加
			case IDC_BUTTON_Add:
			{
				if( map.Hook_Num >= MAX_HOOK-1 )
				{
					ShowMessage("陷阱数量已满");
					break;
				}

				char *Name=GetStringDlg("请输入陷阱的脚本文件:");
				if( Name!=NULL )
				{
					//添加
					char temp[64];
					sprintf(temp,"(%d) %s",map.Hook_Num, Name);
					SendMessage(hListBox, LB_ADDSTRING, 0, (LPARAM)temp);
					
					strcpy(map.Hook[map.Hook_Num], Name);
					Sel=map.Hook_Num;
					SendMessage(hListBox, LB_SETCURSEL, map.Hook_Num, 0);
					map.Hook_Num++;

					UpdateWindow(hDlg);
				}
			}

			break;

			//删除
			case IDC_BUTTON_Delete:
			{
				Sel=SendMessage(hListBox, LB_GETCURSEL, 0, 0 );
				int j;
				map.Hook_Num--;
				
				SendMessage(hListBox, LB_DELETESTRING, Sel, 0);
				
				//修正后面的指针
				for(j=Sel; j<map.Hook_Num; j++)		//陷阱文件名向前移动
				{
					strcpy(map.Hook[j],map.Hook[j+1]);
				}

				//修正地图上的陷阱编号
				for(j=0; j<map.Width * map.Height; j++)
				{
					if( map.Cell[j].CP==(unsigned)Sel )
						map.Cell[j].CP=BLOCK_CP;

					if( map.Cell[j].CP != BLOCK_CP && map.Cell[j].CP > (unsigned)Sel )
						map.Cell[j].CP--;
				}

				if(	map.Hook_Num==0 )
					Sel=BLOCK_CP;
				else
					SendMessage(hListBox, LB_SETCURSEL, Sel, 0);
			}
			break;

			//修改
			case IDC_BUTTON_Modify:
			{
				char *Name=GetStringDlg("请输入要改成的陷阱脚本文件:");
				if( Name!=NULL )
				{
					strcpy(map.Hook[Sel], Name);
					char temp[64];
					sprintf(temp,"(%d) %s",Sel, map.Hook[Sel]);
					SendMessage(hListBox, LB_DELETESTRING, Sel, 0);
					SendMessage(hListBox, LB_INSERTSTRING, Sel, (LPARAM)temp);
					SendMessage(hListBox, LB_SETCURSEL, Sel, 0);
					UpdateWindow(hDlg);
				}
			}
				break;

			//列表框事件
			case IDC_LIST_ChangePoint:
				switch( HIWORD(wParam) )
				{
				//改变列表选择
				case LBN_SELCHANGE:
					Sel=SendMessage(hListBox, LB_GETCURSEL, 0, 0 );
					EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_Modify),true);
					EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_Delete),true);
					break;

				//双击鼠标
				case LBN_DBLCLK:
					map.Cell[map.Width*cy+cx].CP=Sel;
					EndDialog(hDlg,false);
					return true;
				}
				break;
			}
			break;

	    case WM_DESTROY:
            return TRUE;
            break;

        default:
            return FALSE;
    }
return true;
}

/////////////////////////////////////////////////////////////////////
//
//*****************************
//地图敌人设定窗口消息
BOOL APIENTRY DialogEnemySetListProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
	UINT idCommand;
	static int Sel=-1;

	HWND hListBoxAllEnemy, hListBoxEnemy;
	
	hListBoxAllEnemy = GetDlgItem(hDlg, IDC_LIST_AllEnemy);
	hListBoxEnemy = GetDlgItem(hDlg, IDC_LIST_Enemy);

    switch (message)
    {
        case WM_INITDIALOG:
			{

			//定位到中心点
			RECT rect;
			GetWindowRect(hDlg, &rect);
			int w=rect.right-rect.left;
			int h=rect.bottom-rect.top;
			if( WindowMode==1 )	//窗口
				MoveWindow(hDlg, RectWindow.left+(ScreenWidth-w)/2, RectWindow.top+(ScreenHeight-h)/2, w, h, TRUE);
			else
				MoveWindow(hDlg, (ScreenWidth-w)/2, (ScreenHeight-h)/2, w, h, TRUE);
			
			//初始化所有敌人列表框
			int lEnemy = CFight::GetEnemyListNum();
			int lMapEnemy = map.GetEnemyNum();
			int n=0;
			for(int i=0; i<lEnemy; i++)
			{
				bool b=true;
				b = true;
				for(int j=0; j<lMapEnemy; j++)
				{
					if( map.GetEnemyList(j) == i )
					{
						b=false;
						break;
					}
				}

				if( b == true )
				{
					SendMessage(hListBoxAllEnemy, LB_INSERTSTRING, n, (LPARAM)CFight::GetEnemyName(i));
					n++;
				}
			}

			//初始化该地图敌人列表框
			for(i=0; i<lMapEnemy; i++)
			{
				SendMessage(hListBoxEnemy, LB_INSERTSTRING, i, (LPARAM)CFight::GetEnemyName(map.GetEnemyList(i)));
			}

			// 初始化遇敌频率
			SetDlgItemInt(hDlg, IDC_EDIT_Freq, map.GetEnemyFrequency(), true);

			Sel=-1;

			//显示当前的选项
			SendMessage(hListBoxAllEnemy, LB_SETCURSEL, Sel, 0);

			ShowWindow(hDlg,SW_SHOW);
			UpdateWindow(hWnd);
			
			}
            return TRUE;
            break;

		case WM_COMMAND:
			idCommand=LOWORD(wParam);
			switch( idCommand )
			{
			//确定
			case IDOK:
				{
					map.ClearEnemyList();
					int count = SendMessage(hListBoxEnemy, LB_GETCOUNT, 0, 0 );
					map.SetEnemyNum(count);
					for(int i=0; i<count; i++)
					{
						char strTemp[32];
						SendMessage(hListBoxEnemy, LB_GETTEXT, i, (LPARAM)&strTemp );
						for(int j=0; j<CFight::GetEnemyListNum(); j++)
						{
							if( strcmp( strTemp, CFight::GetEnemyName(j)) == 0 )
							{
								map.SetEnemyList(i, j);
							}
						}
					}

					// 遇敌频率
					count = GetDlgItemInt(hDlg, IDC_EDIT_Freq, NULL, true);
					if( count < 0 ) count = 0;
					if( count > 100 ) count = 100;
					map.SetEnemyFrequency( count );
				}
				memcpy(UndoMap, map.Cell, sizeof(Cell_Struct)*map.Width*map.Height);
				EndDialog(hDlg,false);
				return true;

			//取消

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -