void CUIDesignerView::Notify(TNotifyUI& msg)
{
	CControlUI* pControl=msg.pSender;

	if(msg.sType == _T("PropertyBeginChanged"))
	{
		UIAttribute* pAttrib = (UIAttribute*)msg.lParam;
		m_UICommandHistory.Begin(pControl, pAttrib->pstrName, pAttrib->pstrValue);
	}
	else if(msg.sType == _T("PropertyEndChanged"))
	{
		UIAttribute* pAttrib = (UIAttribute*)msg.lParam;
		m_UICommandHistory.End(pControl, pAttrib->pstrName, pAttrib->pstrValue);
	}
	else if(msg.sType == _T("PosBeginChanged"))
		m_UICommandHistory.Begin(*(CArray<CControlUI*,CControlUI*>*)msg.lParam, actionModify);
	else if(msg.sType == _T("PosEndChanged"))
		m_UICommandHistory.End();
	else if(msg.sType==_T("setpos"))
	{
		if(GetControlType(pControl)==typeForm)
		{
			CWindowUI* pForm=m_LayoutManager.GetForm();
			SIZE size;
			size.cx=pForm->GetFixedWidth();
			size.cy=pForm->GetFixedHeight();
			pForm->SetInitSize(size.cx,size.cy);

			g_pPropertiesWnd->SetPropValue(pControl,tagWindowSize);
			SetScrollSizes(MM_TEXT,CSize(size.cx+FORM_OFFSET_X+80,
				size.cy+FORM_OFFSET_Y+80));
			m_MultiTracker.SetFormSize(size);
		}
		else
		{
			CControlUI* pParent=pControl->GetParent();
			if(pParent)
				pParent->SetPos(pParent->GetPos());

			g_pPropertiesWnd->SetPropValue(pControl,tagPos);
			g_pPropertiesWnd->SetPropValue(pControl,tagSize);
		}
	}
	else if(msg.sType==_T("formsize"))
	{
		if(GetControlType(pControl)!=typeForm)
			return;
		CWindowUI* pForm=m_LayoutManager.GetForm();
		SIZE size=pForm->GetInitSize();

		pForm->SetFixedWidth(size.cx);
		pForm->SetFixedHeight(size.cy);

		SetScrollSizes(MM_TEXT,CSize(size.cx+FORM_OFFSET_X+80,
			size.cy+FORM_OFFSET_Y+80));
		m_MultiTracker.SetFormSize(size);
	}

	this->GetDocument()->SetModifiedFlag();
}
Beispiel #2
0
void UnitWrap::RunGuardPost()
{
  if ( GetOrderTimer() != 0 )
    return;
  SetOrderTimer(15);

  if ( TaskSpellcaster(false) )
    return;

  if ( TaskAggression() )
    return;

  if ( pUnit->getType() == UnitTypes::Protoss_Observer )
    return;

  if ( GetControlType() == ControlTypes::Guard && pUnit->getPosition() != GetGuardReturnPosition() )
  {
    if ( pUnit->getType() == UnitTypes::Terran_Siege_Tank_Siege_Mode )
      pUnit->unsiege();
    SetVirtualUnitOrder(Orders::Enum::ComputerReturn, GetGuardReturnPosition() );
  }
  else
  {
    SetVirtualUnitOrder(Orders::Enum::ComputerAI);
  }
}
Beispiel #3
0
void UnitWrap::RunComputerReturn()
{
  if ( TaskAggression() )
    return;

  if ( pUnit->getType() == UnitTypes::Terran_Medic /*&& MedicOrders()*/ )
    return;

  // order state is 0
  if ( !GetOrderState() )
  {
    pUnit->move( GetOrderTargetPosition() );  // temporary
    
    //if ( MoveToTarget() and not getting AI Transport Assist )
      SetOrderState(1);
  }

  if ( GetOrderState() )
  {
    if ( GetControlType() == ControlTypes::Guard )
    {
      if ( GetOrderTargetPosition() == pUnit->getPosition() ) // Reached destination
      {
        SetGuardReturnPosition(pUnit->getPosition());
        SetVirtualUnitOrder(Orders::Enum::Guard);
      }
    }
    else
    {
      SetVirtualUnitOrder(Orders::Enum::ComputerAI);
    }
  }

}
Beispiel #4
0
void UnitWrap::RunGuard()
{
  SetOrderTimer( rand()%16 ); // 0-15

  if ( GetControlType() == ControlTypes::Guard )
    SetVirtualUnitOrder(Orders::Enum::GuardPost);
  else
    SetVirtualUnitOrder(Orders::Enum::ComputerAI);
}
void CUIDesignerView::Notify(TNotifyUI& msg)
{
	CControlUI* pControl=msg.pSender;

	if(msg.sType==_T("setpos"))
	{
		if(GetControlType(pControl)==typeForm)
		{
			CFormUI* pForm=m_LayoutManager.GetForm();
			SIZE size;
			size.cx=pForm->GetFixedWidth();
			size.cy=pForm->GetFixedHeight();
			pForm->SetInitSize(size.cx,size.cy);

			g_pPropertiesWnd->SetPropValue(pControl,tagFormSize);
			SetScrollSizes(MM_TEXT,CSize(size.cx+FORM_OFFSET_X+80,
				size.cy+FORM_OFFSET_Y+80));
			m_MultiTracker.SetFormSize(size);
		}
		else
		{
			CControlUI* pParent=pControl->GetParent();
			if(pParent)
				pParent->SetPos(pParent->GetPos());

			g_pPropertiesWnd->SetPropValue(pControl,tagPos);
			g_pPropertiesWnd->SetPropValue(pControl,tagSize);
		}
	}
	else if(msg.sType==_T("formsize"))
	{
		if(GetControlType(pControl)!=typeForm)
			return;
		CFormUI* pForm=m_LayoutManager.GetForm();
		SIZE size=pForm->GetInitSize();

		pForm->SetFixedWidth(size.cx);
		pForm->SetFixedHeight(size.cy);

		SetScrollSizes(MM_TEXT,CSize(size.cx+FORM_OFFSET_X+80,
			size.cy+FORM_OFFSET_Y+80));
		m_MultiTracker.SetFormSize(size);
	}
}
CTrackerElement* CUIDesignerView::CreateTracker(CControlUI* pControl)
{
	CTrackerElement* pTracker=NULL;
	int nType=GetControlType(pControl);
	if(nType==typeForm)
		pTracker=new CTrackerElement(pControl,typeForm,this);
	else if(nType==typeContainer)
		pTracker=new CTrackerElement(pControl,typeContainer,this);
	else
		pTracker=new CTrackerElement(pControl,typeControl,this);

	return pTracker;
}
Beispiel #7
0
/// WM_GETDLGCODE message handler, indicate to the system whether we want to handle default state
UINT COddButton::OnGetDlgCode()
{
    UINT nCode = CButton::OnGetDlgCode();

    // handle standard control types
    switch (GetControlType())
    {
    case BS_RADIOBUTTON:
    case BS_AUTORADIOBUTTON:
        nCode |= DLGC_RADIOBUTTON;
        break;

    case BS_GROUPBOX:
        nCode = DLGC_STATIC;
        break;
    }

    // tell the system if we want default state handling
    // (losing default state always allowed)
    if (m_bCanBeDefault || m_bDefault)
        nCode |= (m_bDefault ? DLGC_DEFPUSHBUTTON : DLGC_UNDEFPUSHBUTTON);

    return nCode;
}
Beispiel #8
0
static LRESULT CALLBACK DialogBoxSubclassProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	int i;

	EnterCriticalSection(&csDlgBoxSubclass);
	for (i = 0; i<dlgBoxSubclassCount; i++)
		if (dlgBoxSubclass[i].hwndDlg == hwndDlg)
			break;
	if (i == dlgBoxSubclassCount) {
		LeaveCriticalSection(&csDlgBoxSubclass);
		return 0;
	}
	WNDPROC pfnWndProc = dlgBoxSubclass[i].pfnOldWndProc;
	DWORD flags = dlgBoxSubclass[i].flags;
	if (msg == WM_NCDESTROY) {
		struct DlgBoxSubclassData *buf;
		MoveMemory(dlgBoxSubclass + i, dlgBoxSubclass + i + 1, sizeof(struct DlgBoxSubclassData)*(dlgBoxSubclassCount - i - 1));
		dlgBoxSubclassCount--;
		buf = (struct DlgBoxSubclassData*)mir_realloc(dlgBoxSubclass, sizeof(struct DlgBoxSubclassData)*dlgBoxSubclassCount);
		if (buf != NULL)
			dlgBoxSubclass = buf;
		else if (!dlgBoxSubclassCount)
			dlgBoxSubclass = NULL;
	}
	LeaveCriticalSection(&csDlgBoxSubclass);

	switch (msg) {
	case WM_INITMENUPOPUP:
		if (flags&DBSDF_MINIMIZABLE || flags&DBSDF_MAXIMIZABLE) {
			HMENU hMenu = GetSystemMenu(hwndDlg, FALSE);
			if ((HMENU)wParam != hMenu)
				break;
			int isMin = IsIconic(hwndDlg);
			int isMax = IsZoomed(hwndDlg);
			EnableMenuItem(hMenu, SC_RESTORE, MF_BYCOMMAND | (isMin || isMax) ? MF_ENABLED : MF_GRAYED);
			EnableMenuItem(hMenu, SC_MINIMIZE, MF_BYCOMMAND | (flags&DBSDF_MINIMIZABLE && !isMin) ? MF_ENABLED : MF_GRAYED);
			EnableMenuItem(hMenu, SC_MAXIMIZE, MF_BYCOMMAND | (flags&DBSDF_MAXIMIZABLE && !isMax) ? MF_ENABLED : MF_GRAYED);
			EnableMenuItem(hMenu, SC_SIZE, MF_BYCOMMAND | (GetWindowLongPtr(hwndDlg, GWL_STYLE)&WS_THICKFRAME && !isMin && !isMax) ? MF_ENABLED : MF_GRAYED);
		}
		break;
	case WM_MOUSEMOVE: // TrackMouseEvent() would disturb too much
		if (!settingAutoTipDelay)
			break;
		if (cursorPos == lParam)
			break;
		cursorPos = lParam;
	case WM_LBUTTONDOWN:
	case WM_LBUTTONUP:
	case WM_MOUSEWHEEL:
		if (!settingAutoTipDelay)
			break;
		if (msg != WM_MOUSEMOVE && !idMouseMoveTimer)
			break;
		if (openedAutoTip && IsWindow(hwndHelpDlg))
			DestroyWindow(hwndHelpDlg);
		openedAutoTip = 0;
		hwndMouseMoveDlg = hwndDlg;
		if (hwndHelpDlg == NULL)
			idMouseMoveTimer = SetTimer(NULL, idMouseMoveTimer, settingAutoTipDelay, NoMouseMoveForDelayTimerProc);
		break;
	case WM_CAPTURECHANGED:
		if ((HWND)lParam == hwndDlg)
			break;
	case WM_SHOWWINDOW:
	case WM_WINDOWPOSCHANGING:
	case WM_MOVING:
	case WM_SIZING:
	case WM_CANCELMODE:
	case WM_CHILDACTIVATE:
	case WM_MOUSEACTIVATE:
	case WM_ACTIVATEAPP:
	case WM_ACTIVATE:
		if (idMouseMoveTimer)
			KillTimer(NULL, idMouseMoveTimer);
		idMouseMoveTimer = 0;
		break;
	case WM_SYSCOMMAND:
		if ((UINT)wParam == SC_CONTEXTHELP_DIALOG) { // alt. "What's this dialog?"
			if (idMouseMoveTimer)
				KillTimer(NULL, idMouseMoveTimer);
			idMouseMoveTimer = 0;
			if (hwndHelpDlg == NULL) {
				hwndHelpDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_HELP), NULL, HelpDlgProc);
				if (hwndHelpDlg == NULL)
					break;
			}
			SendMessage(hwndHelpDlg, M_CHANGEHELPCONTROL, 0, (LPARAM)hwndDlg);
			return 0;
		}
		break;
	case WM_CONTEXTMENU:
		{
			POINT pt;
			struct FindChildAtPointData fcap;

			// workaround for badly coded plugins that do display a context menu
			// and pass the message to DefWindowProc afterwards (doing a "break;").
			if (GetTickCount() - GetMessageTime()>10)
				return 0;

			if (idMouseMoveTimer)
				KillTimer(NULL, idMouseMoveTimer);
			idMouseMoveTimer = 0;

			ZeroMemory(&fcap, sizeof(fcap));
			POINTSTOPOINT(pt, MAKEPOINTS(lParam));
			// ChildWindowFromPoint() messes up with group boxes
			fcap.hwnd = NULL;
			fcap.pt = pt;
			EnumChildWindows(hwndDlg, FindChildAtPointEnumProc, (LPARAM)&fcap);
			HWND hwndCtl = fcap.hwnd;
			if (hwndCtl == NULL) {
				ScreenToClient(hwndDlg, &pt);
				hwndCtl = ChildWindowFromPointEx(hwndDlg, pt, CWP_SKIPINVISIBLE);
				if (hwndCtl == NULL)
					break;
				POINTSTOPOINT(pt, MAKEPOINTS(lParam));
			}
			{
				LONG_PTR flags = (LONG_PTR)GetProp(hwndCtl, PROP_CONTEXTSTATE);
				if (flags&PROPF_MENUDISABLED)
					break;
				else if (!(flags&PROPF_MENUFORCED)) {
					int type = GetControlType(hwndCtl);
					// showing a context menu on these looks silly (multi components)
					if (type == CTLTYPE_TOOLBAR || type == CTLTYPE_LISTVIEW || type == CTLTYPE_TREEVIEW || type == CTLTYPE_STATUSBAR || type == CTLTYPE_CLC)
						break;
				}
			}
			if (IsRealChild(hwndDlg, hwndCtl)) {
				HMENU hMenu = CreatePopupMenu();
				AppendMenu(hMenu, MF_STRING, SC_CONTEXTHELP, (hwndCtl == hwndDlg) ? TranslateT("&What's this dialog?") : TranslateT("&What's this?"));
				if (TrackPopupMenuEx(hMenu, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_HORPOSANIMATION | TPM_VERPOSANIMATION | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY, pt.x, pt.y, hwndDlg, NULL)) {
					if (hwndHelpDlg == NULL) {
						hwndHelpDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_HELP), NULL, HelpDlgProc);
						if (hwndHelpDlg == NULL) {
							DestroyMenu(hMenu);
							break;
						}
					}
					SendMessage(hwndHelpDlg, M_CHANGEHELPCONTROL, 0, (LPARAM)hwndCtl);
				}
				DestroyMenu(hMenu);
			}
			return 0;
		}
	case WM_HELP:
		{
			HELPINFO *hi = (HELPINFO*)lParam;
			if (hi->iContextType != HELPINFO_WINDOW) break;
			// fix for SHBrowseForFolder() dialog, which sends unhandled help to parent
			if (!IsRealChild(hwndDlg, (HWND)hi->hItemHandle))
				break;

			if (idMouseMoveTimer)
				KillTimer(NULL, idMouseMoveTimer);
			idMouseMoveTimer = 0;

			if (!IsWindow(hwndHelpDlg)) {
				hwndHelpDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_HELP), NULL, HelpDlgProc);
				if (hwndHelpDlg == NULL)
					break;
			}
			SendMessage(hwndHelpDlg, M_CHANGEHELPCONTROL, 0, (LPARAM)hi->hItemHandle);
			// we need to eat the next WM_LBUTTONDOWN (if invoked by mouse)
			if (GetKeyState(GetSystemMetrics(SM_SWAPBUTTON) ? VK_RBUTTON : VK_LBUTTON) & 0x8000 && hEatNextMouseHook == NULL)
				hEatNextMouseHook = SetWindowsHookEx(WH_MOUSE, EatNextMouseButtonUpHookProc, NULL, GetCurrentThreadId());
			return TRUE;
		}
	case WM_NCDESTROY:
		if (idMouseMoveTimer)
			KillTimer(NULL, idMouseMoveTimer);
		idMouseMoveTimer = 0;
		EnumChildWindows(hwndDlg, RemovePropForAllChildsEnumProc, (LPARAM)PROP_CONTEXTSTATE);
		{
			TCHAR text[64];
			mir_sntprintf(text, _countof(text), _T("unhooked window 0x%X for context help\n"), hwndDlg);
			OutputDebugString(text);
		}
		SetWindowLongPtr(hwndDlg, GWLP_WNDPROC, (LONG_PTR)pfnWndProc);
		break;
	}
	return CallWindowProc(pfnWndProc, hwndDlg, msg, wParam, lParam);
}
int CObject::Create (ubyte nType, ubyte nId, short nCreator, short nSegment,
							const CFixVector& vPos, const CFixMatrix& mOrient,
							fix xSize, ubyte cType, ubyte mType, ubyte rType)
{
#if DBG
if (nType == OBJ_WEAPON) {
	nType = nType;
	if ((nCreator >= 0) && (OBJECTS [nCreator].info.nType == OBJ_ROBOT))
		nType = nType;
	if (nId == FLARE_ID)
		nType = nType;
	if (gameData.objs.bIsMissile [(int) nId])
		nType = nType;
	}
else if (nType == OBJ_ROBOT) {
#if 0
	if (ROBOTINFO ((int) nId).bossFlag && (BOSS_COUNT >= MAX_BOSS_COUNT))
		return -1;
#endif
	}
else if (nType == OBJ_HOSTAGE)
	nType = nType;
else if (nType == OBJ_FIREBALL)
	nType = nType;
else if (nType == OBJ_REACTOR)
	nType = nType;
else if (nType == OBJ_DEBRIS)
	nType = nType;
else if (nType == OBJ_MARKER)
	nType = nType;
else if (nType == OBJ_PLAYER)
	nType = nType;
else if (nType == OBJ_POWERUP)
	nType = nType;
#endif

SetSegment (FindSegByPos (vPos, nSegment, 1, 0));
if ((Segment () < 0) || (Segment () > gameData.segs.nLastSegment))
	return -1;

if (nType == OBJ_DEBRIS) {
	if (gameData.objs.nDebris >= gameStates.render.detail.nMaxDebrisObjects)
		return -1;
	}

// Zero out object structure to keep weird bugs from happening in uninitialized fields.
m_nId = OBJ_IDX (this);
SetSignature (gameData.objs.nNextSignature++);
SetType (nType);
SetId (nId);
SetLastPos (vPos);
SetPos (&vPos);
SetSize (xSize);
SetCreator ((sbyte) nCreator);
SetOrient (&mOrient);
SetControlType (cType);
SetMovementType (mType);
SetRenderType (rType);
SetContainsType (-1);
SetLifeLeft (
	((gameData.app.nGameMode & GM_ENTROPY) && (nType == OBJ_POWERUP) && (nId == POW_HOARD_ORB) && (extraGameInfo [1].entropy.nVirusLifespan > 0)) ?
	I2X (extraGameInfo [1].entropy.nVirusLifespan) : IMMORTAL_TIME);
SetAttachedObj (-1);
m_xCreationTime = gameData.time.xGame;
#if 0
if (GetControlType () == CT_POWERUP)
	CPowerupInfo::SetCount (1);
// Init physics info for this CObject
if (GetMovementType () == MT_PHYSICS)
	m_vStartVel.SetZero ();
if (GetRenderType () == RT_POLYOBJ)
	CPolyObjInfo::SetTexOverride (-1);

if (GetType () == OBJ_WEAPON) {
	CPhysicsInfo::SetFlags (CPhysInfo.GetFlags () | WI_persistent (m_info.nId) * PF_PERSISTENT);
	CLaserInfo::SetCreationTime (gameData.time.xGame);
	CLaserInfo::SetLastHitObj (0);
	CLaserInfo::SetScale (I2X (1));
	}
else if (GetType () == OBJ_DEBRIS)
	gameData.objs.nDebris++;
if (GetControlType () == CT_POWERUP)
	CPowerupInfo::SetCreationTime (gameData.time.xGame);
else if (GetControlType () == CT_EXPLOSION) {
	CAttachedInfo::SetPrev (-1);
	CAttachedInfo::SetNext (-1);
	CAttachedInfo::SetParent (-1);
	}
#endif
Link ();
LinkToSeg (nSegment);
return m_nId;
}
void CUIDesignerView::OnLButtonDown(UINT nFlags, CPoint point)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	CClientDC dc(this);
	OnPrepareDC(&dc);//Device coordinates to Logical coordinates
	dc.SetWindowOrg(-FORM_OFFSET_X,-FORM_OFFSET_Y);//Logical coordinates to Form coordinates

	CPoint ptLogical=point-m_ptDPtoLP;//Device coordinates to Logical coordinates
	ptLogical.Offset(-FORM_OFFSET_X,-FORM_OFFSET_Y);//Logical coordinates to Form coordinates

	CControlUI* pControl=m_LayoutManager.FindControl(ptLogical);
	CTrackerElement* pTracker=NULL;
	if(pControl==NULL)
		pControl=m_LayoutManager.GetForm();

	int nHit=m_MultiTracker.HitTest(ptLogical);
	int nType=GetControlType(pControl);
	if((nFlags&MK_CONTROL)==0&&nHit==hitNothing)
		m_MultiTracker.RemoveAll();
	if(nHit==hitNothing)
		m_MultiTracker.Add(CreateTracker(pControl));
	else
		m_MultiTracker.SetFocus(ptLogical);

	if(nHit>=0||nType==typeControl)
	{
		m_MultiTracker.Track(this, ptLogical, FALSE,&dc);
	}
	else
	{
		CUITracker tracker;
		int nClass=g_pToolBoxWnd->GetCurSel()->GetClass();
		CRect rect;
		if (tracker.TrackRubberBand(this, point, TRUE))
		{
			rect=tracker.GetRect();
			rect.NormalizeRect();
			rect.OffsetRect(-FORM_OFFSET_X,-FORM_OFFSET_Y);
			if(rect.Width()<10&&rect.Height()<10)
				rect.SetRect(ptLogical.x,ptLogical.y,ptLogical.x+UI_DEFAULT_WIDTH,ptLogical.y+UI_DEFAULT_HEIGHT);
		}
		else
		{
			rect.SetRect(ptLogical.x,ptLogical.y,ptLogical.x+UI_DEFAULT_WIDTH,ptLogical.y+UI_DEFAULT_HEIGHT);
		}

		if(nClass>classPointer)
		{
			CControlUI* pNewControl=m_LayoutManager.NewUI(nClass,rect,pControl);

		
			CArray<CControlUI*,CControlUI*> arrSelected;
			arrSelected.Add(pNewControl);
			m_UICommandHistory.Begin(arrSelected, actionAdd);
			m_UICommandHistory.End();
			g_pClassView->InsertUITreeItem(pNewControl);

			CContainerUI *pContainer = (CContainerUI *)pNewControl->GetInterface(_T("Container"));
			if (pContainer != NULL)
			{
				for (int it = 0; it < pContainer->GetRowCount(); it++)
				{
					g_pClassView->InsertUITreeItem(pContainer->GetItemAt(it));
				}
			}

			g_pToolBoxWnd->SetCurSel(classPointer);

			m_MultiTracker.RemoveAll();
			m_MultiTracker.Add(CreateTracker(pNewControl));
		}
	}

	g_pClassView->SelectUITreeItem(m_MultiTracker.GetFocused());
	if(m_MultiTracker.GetSize()==1)
		g_pPropertiesWnd->ShowProperty(m_MultiTracker.GetFocused());
	else
		g_pPropertiesWnd->HideAllProperties(TRUE,TRUE);
	
	this->Invalidate(FALSE);

// 	__super::OnLButtonDown(nFlags, point);
}