Ejemplo n.º 1
0
void UIWidgetText::UpdatePosition()
{
	MAKEHASH( m_Archetype );
	MAKEHASH( m_Name );

	STATICHASH( DisplayWidth );
	const float DisplayWidth	= ConfigManager::GetFloat( sDisplayWidth );
	const float ParentWidth		= m_OriginParent ? m_OriginParent->GetWidth() : DisplayWidth;
	const float ParentX			= m_OriginParent ? Ceiling( m_OriginParent->GetX() ) : 0.0f;

	STATICHASH( DisplayHeight );
	const float DisplayHeight	= ConfigManager::GetFloat( sDisplayHeight );
	const float ParentHeight	= m_OriginParent ? m_OriginParent->GetHeight() : DisplayHeight;
	const float ParentY			= m_OriginParent ? Ceiling( m_OriginParent->GetY() ) : 0.0f;

	STATICHASH( PixelX );
	STATICHASH( PixelOffsetX );
	STATICHASH( ScreenX );
	float X =
		ConfigManager::GetArchetypeFloat( sPixelOffsetX, sm_Archetype, 0.0f, sm_Name ) +
		Pick(
			ConfigManager::GetArchetypeFloat( sPixelX, sm_Archetype, 0.0f, sm_Name ),
			ParentWidth * ConfigManager::GetArchetypeFloat( sScreenX, sm_Archetype, 0.0f, sm_Name ) );
	
	STATICHASH( PixelY );
	STATICHASH( PixelOffsetY );
	STATICHASH( ScreenY );
	float Y =
		ConfigManager::GetArchetypeFloat( sPixelOffsetY, sm_Archetype, 0.0f, sm_Name ) +
		Pick(
			ConfigManager::GetArchetypeFloat( sPixelY, sm_Archetype, 0.0f, sm_Name ),
			ParentHeight * ConfigManager::GetArchetypeFloat( sScreenY, sm_Archetype, 0.0f, sm_Name ) );

	// Get dimensions so we can do different origins
	Array<STypesetGlyph> UnusedTypesetting;
	Vector2 Dimensions;
	Array<unicode_t> CodePoints;
	GetString().UTF8ToUnicode( CodePoints );
	m_Font->Arrange( CodePoints, SRect( 0.0f, 0.0f, m_WrapWidth, 0.0f ), UnusedTypesetting, Dimensions );

	AdjustDimensionsToParent( X, Y, Dimensions.x, Dimensions.y, ParentX, ParentY, ParentWidth, ParentHeight );
	GetPositionFromOrigin( X, Y, Dimensions.x, Dimensions.y );

	STATICHASH( ClampToPixelGrid );
	m_ClampToPixelGrid = ConfigManager::GetArchetypeBool( sClampToPixelGrid, sm_Archetype, true, sm_Name );
	if( m_ClampToPixelGrid )
	{
		// Add 0.5 to compensate for font UVs being on half pixel intervals.
		m_TopLeft.x = Round( m_TopLeft.x ) + 0.5f;
		m_TopLeft.y = Round( m_TopLeft.y ) + 0.5f;
	}

	// Offset to properly align on pixel grid.
	const float PixelGridOffset = GetPixelGridOffset();
	m_TopLeft.x -= PixelGridOffset;
	m_TopLeft.y -= PixelGridOffset;
}
Ejemplo n.º 2
0
void wam::OnMouseDown(WPARAM btnState, int x, int y)
{
	mLastMousePos.x = x;
	mLastMousePos.y = y;
	Pick(x,y);
	SetCapture(mhMainWnd);
}
void Container::ToInventory(const short lat, const short lon)
{
	if ((_myLatitude == lat) && (_myLongitude == lon) && (_state == 'g'))
	{
		_state = 's';
		printf(Pick(BAG));
	}else
		printf(Not_found(BAG));
}
Ejemplo n.º 4
0
/** Translate \p msg. If multiple messages are available it picks one at random.
Returns \p msg if no messages are available. */
std::string CMessages::Translate(const std::string& msg) const
{
	// TdfParser puts everything in lowercase.
	std::string lowerd = StringToLower(msg);
	message_map_t::const_iterator it = tr.find(lowerd);
	if (it == tr.end())
		return msg;
	return Pick(it->second);
}
Ejemplo n.º 5
0
/** Translate \p msg. If multiple messages are available it picks one at random.
Returns \p msg if no messages are available. */
std::string CMessages::Translate(const std::string& msg) const
{
	// TdfParser puts everything in lowercase.
	std::string lowerd = msg;
	std::transform(lowerd.begin(), lowerd.end(), lowerd.begin(), (int (*)(int))std::tolower);
	message_map_t::const_iterator it = tr.find(lowerd);
	if (it == tr.end())
		return msg;
	return Pick(it->second);
}
Ejemplo n.º 6
0
void aiC::Execute(bool serverHasUpdatedGameState)
{
 switch(aiStatus) {


    // just started, need to connect with server
    case 0:
	if(netConnected()) aiStatus++;
	else if(timeGet() - aiLastCommand > 2000)
	{
	    pf("ai %s, trying to connect:\n", Name);
	    cmd("name AI-%s", Name);
	    cmd("join localhost");
	    aiLastCommand = timeGet();
	}
    break;



    // waiting for other players to join
    case 1:
	if(game && game->Turn > 0) aiStatus++;
	else
	    //if(playercount() > 1)
		if(timeGet() - aiLastCommand > 2000)
		{
		    cmd("ready");
		    aiLastCommand = timeGet();
		}
    break;



    // choose picks
    case 2:
	if(self->Status == BRAIN_ACTIVE) aiStatus++;
	else if(timeGet() - aiLastCommand > 2000)
	{
	    Pick();
	    aiLastCommand = timeGet();
	}

    // play
    case 3:
	if(serverHasUpdatedGameState)
	    Think();
    break;
 }
}
Ejemplo n.º 7
0
//---------------------------------------------------------------------------
void CFabAtHomeView::OnLButtonDown(UINT nFlags, CPoint point) 
//---------------------------------------------------------------------------
{
	if (bPanning) OnLButtonUp(nFlags, point);

	CFabAtHomeApp *pApp = (CFabAtHomeApp *) AfxGetApp();

    wglMakeCurrent(m_pDC->GetSafeHdc(), hrc);
	Pick(nFlags, point);

	bPanning = TRUE;
	startPoint = point;
	SetCursor(pApp->hHandCursor);
	SetCapture();
	
	CView::OnLButtonDown(nFlags, point);
}
bool FlowDirectionHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa)
{
	if((*ppFlowDlg)->IsWindowVisible())
	{
		switch(ea.getEventType())
		{
		case (osgGA::GUIEventAdapter::DOUBLECLICK):
			{
				osg::Vec3d m_TempPoint1;
				//const osgEarth::SpatialReference* m_pGeoSRS = mapNode->getTerrain()->getSRS();

				Pick(ea.getX(),ea.getY());
			}
		}
		return true;
	}
	return false;
}
Ejemplo n.º 9
0
void DashEdit::SetData(const Value& data)
{
	RichText text;
	String d = data;
	RichPara para;
	RichPara::Format f;
	for(const char *s = d; *s; s++)
		if(*s == '\n') {
			text.Cat(para);
			para.part.Clear();
		}
		else
		if(*s == '~')
			f.dashed = !f.dashed;
		else
		if((byte)*s >= ' ')
			para.Cat(String(*s, 1).ToWString(), f);
	text.Cat(para);
	Pick(text);
}
Ejemplo n.º 10
0
LRESULT CGameProc::OnLButtonDown(WPARAM wParam, LPARAM lParam)
{
	m_pt.x = (float)LOWORD(lParam);
	m_pt.y = (float)HIWORD(lParam);
	if (m_xSkillWnd.OnLButtonDown(m_pt))
	{
	}
	else if(g_pChatPopWnd->OnLButtonDown(m_pt))
		  m_xTaskScript.CallFun(g_pPlayer->m_pTargetInfo->TaskIndex);
	else 
	{	
		if (!Pick(m_pt))
		{
            g_pPlayer->m_pTargetInfo=NULL;
		}
	}


	return true;
}
Ejemplo n.º 11
0
void QuadTree::SearchTree(D3DXVECTOR3 vPickRayDir, D3DXVECTOR3 vPickRayOrig, BoxNode box)
{
	bool result = false;

	result = Pick(vPickRayDir, vPickRayOrig, box);

	if (!result)
		return;

	if (!box.ChildNode.empty())
	{	
		for (int i=0; i<4; ++i)
			SearchTree(vPickRayDir, vPickRayOrig, box.ChildNode.at(i));
		return;
	}

	newTowerPos.x = (box.minB.x+box.maxB.x)/2;
	newTowerPos.z = (box.minB.z+box.maxB.z)/2;
	newTowerPos.y =  pLand->getHeight(newTowerPos.x, newTowerPos.z)+1;
	return;
}
Ejemplo n.º 12
0
void MouseCallback(int button, int state, int x, int y)
{
	mx = x;
	my = y;

	if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN) 
	{
		Pick(x, y);

		// this prevents from only grabbing it when the mouse moves
		MotionCallback(x, y);
	}
	else if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
	{
		bLeftMouseButtonPressed = true;
	}
	if (state == GLUT_UP) 
	{
		LetGo();
		bLeftMouseButtonPressed = false;
	}
}
Ejemplo n.º 13
0
LRESULT CGameProc::OnRButtonDown(WPARAM wParam, LPARAM lParam)
{
	m_bRCapture=true;
	m_Oldpt.x = LOWORD(lParam);
	m_Oldpt.y = HIWORD(lParam);

	if (Pick(m_Oldpt))
	{
		if (g_pPlayer->CalculateTagDistanceSquece()<50*50&&g_pPlayer->m_pTargetInfo->TaskIndex!=0)
		{
			//判断任务怪死亡没有
			if (g_pChatPopWnd->m_nTaskState==2)
			{
				m_xMonsterList.MoveCurrentToTop();
				for (int nCnt=0;nCnt<m_xMonsterList.GetCounter();nCnt++)
				{
					CMonster *pMonster;
					pMonster=m_xMonsterList.GetCurrentData();
					
					if (pMonster->m_xMonsterInfo.Id==2)
					{
						if (!pMonster->IsDead())
						{
							g_pChatPopWnd->m_nTaskState=1;
						}
					}
					m_xMonsterList.MoveNextNode();
				}
			}

			g_pChatPopWnd->Open();
			m_xTaskScript.CallFun(g_pPlayer->m_pTargetInfo->TaskIndex);
		}
	}
	return true;
}
Ejemplo n.º 14
0
void UIWidgetText::InitializeFromDefinition( const SimpleString& DefinitionName )
{
	UIWidget::InitializeFromDefinition( DefinitionName );

	MAKEHASH( m_Archetype );
	MAKEHASH( DefinitionName );

	STATICHASH( Font );
	m_Font = m_UIManager->GetRenderer()->GetFontManager()->GetFont( ConfigManager::GetArchetypeString( sFont, sm_Archetype, DEFAULT_FONT, sDefinitionName ) );

	// If LoadString is false, we're expecting to dynamically set the string in code somewhere
	STATICHASH( LoadString );
	if( ConfigManager::GetArchetypeBool( sLoadString, sm_Archetype, true, sDefinitionName ) )
	{
		STATICHASH( String );
		STATICHASH( DynamicString );

		STATICHASH( IsLiteral );
		m_IsLiteral = ConfigManager::GetArchetypeBool( sIsLiteral, sm_Archetype, false, sDefinitionName );
		if( m_IsLiteral )
		{
			m_String		= ConfigManager::GetArchetypeString( sString, sm_Archetype, "", sDefinitionName );
			m_DynamicString	= ConfigManager::GetArchetypeString( sDynamicString, sm_Archetype, "", sDefinitionName );
		}
		else
		{
			m_String		= ConfigManager::GetLocalizedString( ConfigManager::GetArchetypeHash( sString, sm_Archetype, "", sDefinitionName ), "" );
			m_DynamicString	= ConfigManager::GetLocalizedString( ConfigManager::GetArchetypeHash( sDynamicString, sm_Archetype, "", sDefinitionName ), "" );
		}
	}

	STATICHASH( IsDynamicPosition );
	m_IsDynamicPosition = ConfigManager::GetArchetypeBool( sIsDynamicPosition, sm_Archetype, false, sDefinitionName );

	STATICHASH( Alignment );
	GetFontPrintFlags( ConfigManager::GetArchetypeString( sAlignment, sm_Archetype, "", sDefinitionName ) );

	STATICHASH( HasDropShadow );
	m_HasDropShadow = ConfigManager::GetArchetypeBool( sHasDropShadow, sm_Archetype, false, sDefinitionName );

	STATICHASH( DropShadowColorR );
	m_DropShadowColor.r = ConfigManager::GetArchetypeFloat( sDropShadowColorR, sm_Archetype, 1.0f, sDefinitionName );

	STATICHASH( DropShadowColorG );
	m_DropShadowColor.g = ConfigManager::GetArchetypeFloat( sDropShadowColorG, sm_Archetype, 1.0f, sDefinitionName );

	STATICHASH( DropShadowColorB );
	m_DropShadowColor.b = ConfigManager::GetArchetypeFloat( sDropShadowColorB, sm_Archetype, 1.0f, sDefinitionName );

	STATICHASH( DropShadowColorA );
	m_DropShadowColor.a = ConfigManager::GetArchetypeFloat( sDropShadowColorA, sm_Archetype, 1.0f, sDefinitionName );

	STATICHASH( DisplayWidth );
	const float fDisplayWidth = static_cast<float>( ConfigManager::GetInt( sDisplayWidth ) );

	STATICHASH( DisplayHeight );
	const float fDisplayHeight = static_cast<float>( ConfigManager::GetInt( sDisplayHeight ) );

	STATICHASH( WrapPixelWidth );
	STATICHASH( WrapScreenWidth );
	m_WrapWidth =
		Pick(
			ConfigManager::GetArchetypeFloat( sWrapPixelWidth, sm_Archetype, 0.0f, sDefinitionName ),
			fDisplayWidth * ConfigManager::GetArchetypeFloat( sWrapScreenWidth, sm_Archetype, 0.0f, sDefinitionName ) );

	STATICHASH( DropShadowOffsetPixelX );
	STATICHASH( DropShadowOffsetScreenX );
	m_DropShadowOffset.x =
		Pick(
			ConfigManager::GetArchetypeFloat( sDropShadowOffsetPixelX, sm_Archetype, 0.0f, sDefinitionName ),
			fDisplayWidth * ConfigManager::GetArchetypeFloat( sDropShadowOffsetScreenX, sm_Archetype, 0.0f, sDefinitionName ) );

	STATICHASH( DropShadowOffsetPixelY );
	STATICHASH( DropShadowOffsetScreenY );
	m_DropShadowOffset.y =
		Pick(
			ConfigManager::GetArchetypeFloat( sDropShadowOffsetPixelY, sm_Archetype, 0.0f, sDefinitionName ),
			fDisplayHeight * ConfigManager::GetArchetypeFloat( sDropShadowOffsetScreenY, sm_Archetype, 0.0f, sDefinitionName ) );

	UpdatePosition();

	UpdateRender();
}
Ejemplo n.º 15
0
void Verb_Parser(int *tokens)

{
	switch(tokens[0])
	{
	case Action_move:
		{
			Move(tokens);
			break;
		}
	case Action_pick:
		{
			Pick(tokens);
			break;
		}
	case Action_put:
		{
			Put(tokens);
			break;
		}
	case Action_look:
		{
			Look(tokens);
			break;
		}
	case Action_inventory:
		{
			Inventory(tokens);
			break;
		}
	case Action_examine:
		{
			Examine(tokens);
			break;
		}
	case Action_talk:
		{
			Talk(tokens);
			break;
		}
	case Action_save:
		{
			Save(tokens);
			break;
		}
	case Action_restore:
		{
			Restore(tokens);
			break;
		}
	case Action_exit:
		{
			Exit(tokens);
			break;
		}
	default:
		{
			printf("You must start a sentence with an action verb.\n");
			break;
		}
	}
}
Ejemplo n.º 16
0
//______________________________________________________________________________
void KVCanvas::HandleInput(EEventType event, Int_t px, Int_t py)
{
   // Handle Input Events.
   //
   //  Handle input events, like button up/down in current canvas.

   if (fFreezed) return;

   TPad*    pad;
   TPad*    prevSelPad = (TPad*) fSelectedPad;
   TObject* prevSelObj = fSelected;

   fPadSave = (TPad*)gPad;
   cd();        // make sure this canvas is the current canvas

   fEvent  = event;
   fEventX = px;
   fEventY = py;

   Int_t sign = 0;
   Bool_t sendOrder = true;

   if (fHasDisabledClasses && fSelected) {
      if (fDisabledClasses.Contains(fSelected->ClassName())) sendOrder = false;
   }

   if (fHasDisabledObject && fSelected) {
      if (fDisabledObjects.Contains(fSelected)) sendOrder = false;
   }

   switch (event) {

      case kMouseMotion:
         // highlight object tracked over
         pad = Pick(px, py, prevSelObj);
         if (!pad) return;

         EnterLeave(prevSelPad, prevSelObj);

         gPad = pad;   // don't use cd() we will use the current
         // canvas via the GetCanvas member and not via
         // gPad->GetCanvas

         if (sendOrder) fSelected->ExecuteEvent(event, px, py);

         RunAutoExec();

         if (fAgeOfEmpire && (fSelected->InheritsFrom("TH2"))) {
            TH2* TheHisto = (TH2*) FindHisto();//fSelected;

            Double_t size = 0.4 - 0.35 * fVenerMode;

            Int_t dX = 0;
            Int_t dY = 0;

            Double_t ppx = AbsPixeltoX(px);
            Double_t ppy = AbsPixeltoY(py);

            TAxis* ax = TheHisto->GetXaxis();
            Int_t X0 = ax->GetFirst();
            Int_t X1 = ax->GetLast();
            Int_t NbinsX = ax->GetNbins();
            px = ax->FindBin(ppx);

            Double_t ddX   = (X1 + X0) * 0.5 - px;
            Double_t distX = TMath::Abs(ddX) / (X1 - X0);
            if (distX >= 0.5) return;

            TAxis* ay = TheHisto->GetYaxis();
            Int_t Y0 = ay->GetFirst();
            Int_t Y1 = ay->GetLast();
            Int_t NbinsY = ay->GetNbins();
            py = ay->FindBin(ppy);

            Double_t ddY   = (Y1 + Y0) * 0.5 - py;
            Double_t distY = TMath::Abs(ddY) / (Y1 - Y0);
            if (distY >= 0.5) return;

            if ((distX <= size) && (distY <= size)) return;
            dX = TMath::Nint(ddX * (0.05 + 0.05 * fVenerMode));
            dY = TMath::Nint(ddY * (0.05 + 0.05 * fVenerMode));

            if (TMath::Abs(dX) < 1) dX = TMath::Sign(1., ddX);
            if (TMath::Abs(dY) < 1) dY = TMath::Sign(1., ddY);


            Bool_t up = false;
            if ((X0 - dX > 0) && (X1 - dX < NbinsX)) {
               ax->SetRange(X0 - dX, X1 - dX);
               up = true;
            }
            if ((Y0 - dY > 0) && (Y1 - dY < NbinsY)) {
               ay->SetRange(Y0 - dY, Y1 - dY);
               up = true;
            }
            if (up) {
               Modified();
               Update();
            }
         }

         break;

      case kMouseEnter:
         // mouse enters canvas
         if (!fDoubleBuffer) FeedbackMode(kTRUE);
         break;

      case kMouseLeave:
         // mouse leaves canvas
         {
            // force popdown of tooltips
            TObject* sobj = fSelected;
            TPad*    spad = fSelectedPad;
            fSelected     = 0;
            fSelectedPad  = 0;
            EnterLeave(prevSelPad, prevSelObj);
            fSelected     = sobj;
            fSelectedPad  = spad;
            if (!fDoubleBuffer) FeedbackMode(kFALSE);
         }
         break;

      case kButton1Double:
      // triggered on the second button down within 350ms and within
      // 3x3 pixels of the first button down, button up finishes action

      case kButton1Down:
         // find pad in which input occured
         pad = Pick(px, py, prevSelObj);
         if (!pad) return;

         gPad = pad;   // don't use cd() because we won't draw in pad
         // we will only use its coordinate system

         if (fSelected) {
            FeedbackMode(kTRUE);   // to draw in rubberband mode
            fSelected->ExecuteEvent(event, px, py);

            RunAutoExec();

            if (fSelected->InheritsFrom("TH2")) {
               oldx = GetEventX();
               oldy = GetEventY();
               xmin = AbsPixeltoX(oldx);
               ymin = AbsPixeltoY(oldy);
               gVirtualX->DrawBox(XtoAbsPixel(xmin), YtoAbsPixel(ymin), oldx, oldy, TVirtualX::kHollow);
            }

         }

         break;

      case kButton1Motion:
         if (fSelected) {
            if (fSelected->InheritsFrom("TH2")) {
               gVirtualX->DrawBox(XtoAbsPixel(xmin), YtoAbsPixel(ymin), oldx, oldy, TVirtualX::kHollow);
               oldx = GetEventX();
               oldy = GetEventY();
               gVirtualX->DrawBox(XtoAbsPixel(xmin), YtoAbsPixel(ymin), oldx, oldy, TVirtualX::kHollow);
               moved = true;
            }
         }
      case kButton1ShiftMotion: //8 == kButton1Motion + shift modifier
         if (fSelected) {
            gPad = fSelectedPad;

            if (sendOrder) fSelected->ExecuteEvent(event, px, py);
            gVirtualX->Update();

            if (!fSelected->InheritsFrom(TAxis::Class())) {
               Bool_t resize = kFALSE;
               if (fSelected->InheritsFrom(TBox::Class()))
                  resize = ((TBox*)fSelected)->IsBeingResized();
               if (fSelected->InheritsFrom(TVirtualPad::Class()))
                  resize = ((TVirtualPad*)fSelected)->IsBeingResized();

               if ((!resize && TestBit(kMoveOpaque)) || (resize && TestBit(kResizeOpaque))) {
                  gPad = fPadSave;
                  Update();
                  FeedbackMode(kTRUE);
               }
            }

            RunAutoExec();
         }

         break;

      case kButton1Up:

         if (fSelected) {
            gPad = fSelectedPad;

            if (sendOrder) fSelected->ExecuteEvent(event, px, py);

            RunAutoExec();

            if (fPadSave)
               gPad = fPadSave;
            else {
               gPad     = this;
               fPadSave = this;
            }
            if (fSelected->InheritsFrom("TH2") && moved && !fSelected->InheritsFrom("TH3")) {
               xmax = AbsPixeltoX(GetEventX());
               ymax = AbsPixeltoY(GetEventY());
               Double_t toto = 0;
               if (xmax < xmin) {
                  toto = xmax;
                  xmax = xmin;
                  xmin = toto;
               }
               if (ymax < ymin) {
                  toto = ymax;
                  ymax = ymin;
                  ymin = toto;
               }
               ZoomSelected((TH2*)FindHisto());
//                ZoomSelected((TH2*)fSelected);
               moved = false;
            }
            Update();    // before calling update make sure gPad is reset
         }
         break;

      //*-*----------------------------------------------------------------------

      case kButton2Down:
         // find pad in which input occured
         pad = Pick(px, py, prevSelObj);
         if (!pad) return;

         gPad = pad;   // don't use cd() because we won't draw in pad
         // we will only use its coordinate system

         FeedbackMode(kTRUE);

         if (!fSelected->InheritsFrom("TH1")) fSelected->Pop();             // pop object to foreground
         pad->cd();                                 // and make its pad the current pad

         if (fSelected->InheritsFrom("TH2") && !fSelected->InheritsFrom("TH3")) {
            // implement pan & scan
            X0 = px;
            Y0 = py;  // u clikd here
            theXaxis = ((TH2*)FindHisto())->GetXaxis();
            theYaxis = ((TH2*)FindHisto())->GetYaxis();
            NXbins = theXaxis->GetNbins();  // maximum bin number in X
            NYbins = theYaxis->GetNbins();  // maximum bin number in Y
            Xf1 = Xfirst0 = theXaxis->GetFirst(); // initial displayed bin range in X
            Xl1 = Xlast0 = theXaxis->GetLast();
            Yf1 = Yfirst0 = theYaxis->GetFirst(); // initial displayed bin range in Y
            Yl1 = Ylast0 = theYaxis->GetLast();
            // size of axes in pixels
            Int_t pixelWidthX = gPad->XtoAbsPixel(gPad->GetUxmax()) - gPad->XtoAbsPixel(gPad->GetUxmin());
            Int_t pixelWidthY = gPad->YtoAbsPixel(gPad->GetUymax()) - gPad->YtoAbsPixel(gPad->GetUymin());
            // sizes of bins in pixels
            NdisXbins = Xlast0 - Xfirst0 + 1;
            NdisYbins = Ylast0 - Yfirst0 + 1;
            XbinPixel = pixelWidthX / (1.0 * NdisXbins);
            YbinPixel = pixelWidthY / (1.0 * NdisYbins);
         }




         if (gDebug)
            printf("Current Pad: %s / %s\n", pad->GetName(), pad->GetTitle());

         // loop over all canvases to make sure that only one pad is highlighted
         {
            TIter next(gROOT->GetListOfCanvases());
            TCanvas* tc;
            while ((tc = (TCanvas*)next()))
               tc->Update();
         }

         /*if (pad->GetGLDevice() != -1 && fSelected)
          fSelected->ExecuteEvent(event, px, py);*/

         break;   // don't want fPadSave->cd() to be executed at the end

      case kButton2Motion:
         //was empty!
         if (fSelected && fSelected->InheritsFrom("TH2") && !fSelected->InheritsFrom("TH3")) {
            // implement pan & scan
            Int_t dX = px - X0; // how far have i moved ?
            Int_t dY = py - Y0;
            Int_t dXbins = dX / XbinPixel;
            Int_t dYbins = dY / YbinPixel;
            Bool_t changed = kFALSE;
            Int_t newXfirst = Xfirst0 - dXbins;
            Int_t newXlast;
            if (newXfirst < 1) {
               newXfirst = 1;
               newXlast = NdisXbins;
            } else {
               newXlast = Xlast0 - dXbins;
               if (newXlast > NXbins) {
                  newXlast = NXbins;
                  newXfirst = newXlast - NdisXbins + 1;
               }
            }
            if (newXfirst != Xf1) {
               Xf1 = newXfirst;
               Xl1 = newXlast;
               theXaxis->SetRange(Xf1, Xl1);
               changed = kTRUE;
            }
            Int_t newYfirst = Yfirst0 - dYbins;
            Int_t newYlast;
            if (newYfirst < 1) {
               newYfirst = 1;
               newYlast = NdisYbins;
            } else {
               newYlast = Ylast0 - dYbins;
               if (newYlast > NYbins) {
                  newYlast = NYbins;
                  newYfirst = newYlast - NdisYbins + 1;
               }
            }
            if (newYfirst != Yf1) {
               Yf1 = newYfirst;
               Yl1 = newYlast;
               theYaxis->SetRange(Yf1, Yl1);
               changed = kTRUE;
            }
            if (changed) {
               Modified();
               Update();
            }
         }


      case kButton2Up:
         if (fSelected) {
            gPad = fSelectedPad;

            if (sendOrder) fSelected->ExecuteEvent(event, px, py);
            RunAutoExec();
         }
         break;

      case kButton2Double:
         break;

      //*-*----------------------------------------------------------------------

      case kButton3Down:
         // popup context menu
         pad = Pick(px, py, prevSelObj);
         if (!pad) return;

         if (!fDoubleBuffer) FeedbackMode(kFALSE);

         if (fContextMenu && !fSelected->TestBit(kNoContextMenu) && !pad->TestBit(kNoContextMenu) && !TestBit(kNoContextMenu)) {
            if (sendOrder) fContextMenu->Popup(px, py, fSelected, this, pad);
            else fSelected->ExecuteEvent(event, px, py);
         }

         break;

      case kButton3Motion:
         break;

      case kButton3Up:
         if (!fDoubleBuffer) FeedbackMode(kTRUE);
         break;

      case kButton3Double:
         break;

      case kKeyDown:
         //       Info("HandleInput","Key down: %d %d",px,py);
         break;

      case kKeyUp:
         //       Info("HandleInput","Key up: %d %d",px,py);
         break;

      case kKeyPress:
         if (!fSelectedPad || !fSelected) return;
         gPad = fSelectedPad;   // don't use cd() because we won't draw in pad
         // we will only use its coordinate system
         fSelected->ExecuteEvent(event, px, py);

         HandleKey(px, py);
         RunAutoExec();

         break;
      case kButton1Shift:
         // Try to select
         pad = Pick(px, py, prevSelObj);

         if (!pad) return;

         EnterLeave(prevSelPad, prevSelObj);

         gPad = pad;   // don't use cd() we will use the current
         // canvas via the GetCanvas member and not via
         // gPad->GetCanvas
         fSelected->ExecuteEvent(event, px, py);
         RunAutoExec();

         break;
      case kWheelUp:
      case kWheelDown:
         pad = Pick(px, py, prevSelObj);
         if (!pad) return;

         sign = (event == kWheelUp ? 1 : -1);

         gPad = pad;
         if (fSelected->InheritsFrom("TAxis")) fSelected->ExecuteEvent(event, px, py);
         else if (fSelected->InheritsFrom("TH2")) DynamicZoom(sign, px, py);

         RunAutoExec();

         break;
      default:
         break;
   }

   if (fPadSave && event != kButton2Down)
      fPadSave->cd();

   if (event != kMouseLeave) { // signal was already emitted for this event
      ProcessedEvent(event, px, py, fSelected);  // emit signal
      DrawEventStatus(event, px, py, fSelected);
   }
}
Ejemplo n.º 17
0
Pick Batch::getPick(const Ray3f& ray,Mat4f global_matrix)
{
	//first test if the box hits the ray
	#if 1
	{
		Box3f box=this->getBox();

		if (!box.isValid())
			return Pick();//invalid pick

		//if a transformation is applyied to this batch...
		Box3f transformed_box;
		for (int i=0;i<8;i++)
			transformed_box.add(global_matrix * box.getPoint(i));
		box=transformed_box;

		float tmin,tmax;
		if (!box.isValid() || !ray.intersectBox(tmin,tmax,box))
			return Pick(); //invalid pick
	}
	#endif

	//invalud pick
	Pick pick;

	if (!this->vertices)
		return pick;

	//invalid pick
	if (!this->vertices)
		return pick;

	int tot=this->vertices->size();
	const float* pv=this->vertices->mem();

	//TRIANGLES
	if (this->primitive==Batch::TRIANGLES)
	{
		for (int i=0;i<tot;i+=9,pv+=9)
		{
			Vec3f v0(pv+0); 
			Vec3f v1(pv+3); 
			Vec3f v2(pv+6);

			v0=global_matrix * (this->matrix * v0);
			v1=global_matrix * (this->matrix * v1);
			v2=global_matrix * (this->matrix * v2);
			

			float distance=ray.intersectTriangle(v0,v1,v2);

			if (distance>=0 && (!pick.valid || pick.distance>distance))
			{
				//fill up useful information
				pick.valid=true;
				pick.distance=distance;
				pick.position=ray.getPoint(distance);
				pick.normal=(v1-v0).cross(v2-v0).normalize();
				pick.path.clear();
				pick.path.push_back(i);
			}
		}
	}

	//QUADS
	if (this->primitive==Batch::QUADS)
	{
		for (int i=0;i<tot;i+=12,pv+=12)
		{
			Vec3f v0(pv+0); 
			Vec3f v1(pv+3); 
			Vec3f v2(pv+6);
			Vec3f v3(pv+9);

			v0=global_matrix * (this->matrix * v0);
			v1=global_matrix * (this->matrix * v1);
			v2=global_matrix * (this->matrix * v2);
			v3=global_matrix * (this->matrix * v3);

			float distance=ray.intersectTriangle(v0,v1,v2);

			//first triangle
			if (distance>=0 && (!pick.valid || pick.distance>distance))
			{
				pick.valid=true;
				pick.distance=distance;
				pick.position=ray.getPoint(distance);
				pick.normal=(v1-v0).cross(v2-v0).normalize();
				pick.path.clear();
				pick.path.push_back(i);
			}

			distance=ray.intersectTriangle(v0,v2,v3);

			//second triangle
			if (distance>=0 && (!pick.valid || pick.distance>distance))
			{
				pick.valid=true;
				pick.distance=distance;
				pick.position=ray.getPoint(distance);
				pick.normal=(v1-v0).cross(v2-v0).normalize();
				pick.path.clear();
				pick.path.push_back(i);
			}
		}
	}

	return pick;
}
Ejemplo n.º 18
0
UINT GjThreadProc(LPVOID lpParamter)
{ 
    DWORD isSelectGw = 0;
	DWORD gwPoint,one;
	int gwId =0;
	int hp = 0;
	int jnID;
	float rwgwjl;//人物与怪物的距离
	BYTE isUsejn;//技能是否能使用
	
	float gwx,gwy;
	while (isGjFlag)
    {
		ReadProcessMemory(PID, (LPCVOID)(rwBaseAddr + 0x254), &hp, 4, 0);
		if(hp == 0){
			dead();
		}else{
			addHpMp(false);
			ReadProcessMemory(PID, (LPCVOID)(rwBaseAddr + 0x7b8), &isSelectGw, 4, 0);
			if (isSelectGw == 0)
			{
				if(dlxiaoDllDlg->IsDlgButtonChecked(IDC_CHECK_ISSELL)){
					bagfull();
				}
				Pick();
				addHpMp(true);
				addfz();
				dingdian();
				gwPoint = getGwPoint();
				if(gwPoint != 0){
					ReadProcessMemory(PID,(LPCVOID)(gwPoint+8),&gwId,4,0);
					if (gwId != 0 )
					{
						CallSelectGw(gwId);
					}
				}
				
			}
			else
			{
				CallNormal();
				readRwXY();
				ReadProcessMemory(PID, (LPCVOID)(gwPoint + 0x4), &one, 4, 0);
                ReadProcessMemory(PID, (LPCVOID)(one + 0x3C), &gwx, sizeof(FLOAT), 0);
                ReadProcessMemory(PID, (LPCVOID)(one + 0x44), &gwy, sizeof(FLOAT), 0);
				rwgwjl = sqrtf(powf((rwX - gwx), 2) + powf((rwY - gwy), 2));
				if(dlxiaoDllDlg->IsDlgButtonChecked(IDC_CHECK_ISUSERJN) && (rwgwjl <= 3) &&  usejnidx > -1){
					ReadProcessMemory(PID, (LPCVOID)(jnPointerArray.GetAt(usejnidx) + 0x8), &jnID, 4, 0);
					if(jnID){
						ReadProcessMemory(PID, (LPCVOID)(jnPointerArray.GetAt(usejnidx) + 0xC), &isUsejn, 1, 0);
						if(isUsejn == 0){	
							CallUserSkill(jnID,gwId);
						}
					}
				}
				Sleep(500);
			}
		}
	}
 
return (0);
}
Ejemplo n.º 19
0
void  RichTextView::Pick(pick_ RichText& txt, Zoom z) {
	if(z.m != z.d)
		const_cast<RichText&>(txt).ApplyZoom(z);
	Pick(txt);
	sb.SetLine(z * 100);
}
Ejemplo n.º 20
0
void  RichTextView::SetQTF(const char *qtf, Zoom z)
{
	Pick(ParseQTF(qtf), z);
}
Ejemplo n.º 21
0
void UIWidgetFrame::InitializeFromDefinition( const SimpleString& DefinitionName )
{
	UIWidget::InitializeFromDefinition( DefinitionName );

	MAKEHASH( DefinitionName );
	MAKEHASH( m_Archetype );

	STATICHASH( DisplayWidth );
	const float DisplayWidth	= ConfigManager::GetFloat( sDisplayWidth );
	const float ParentWidth		= m_OriginParent ? m_OriginParent->GetWidth() : DisplayWidth;
	const float ParentX			= m_OriginParent ? Ceiling( m_OriginParent->GetX() ) : 0.0f;

	STATICHASH( DisplayHeight );
	const float DisplayHeight	= ConfigManager::GetFloat( sDisplayHeight );
	const float ParentHeight	= m_OriginParent ? m_OriginParent->GetHeight() : DisplayHeight;
	const float ParentY			= m_OriginParent ? Ceiling( m_OriginParent->GetY() ) : 0.0f;

	// "Screen" values are now relative to parent, which may or may not be screen dimensions.

	STATICHASH( PixelX );
	STATICHASH( ScreenX );
	float X = Pick(
		ConfigManager::GetArchetypeFloat( sPixelX, sm_Archetype, 0.0f, sDefinitionName ),
		ParentWidth * ConfigManager::GetArchetypeFloat( sScreenX, sm_Archetype, 0.0f, sDefinitionName ) );

	STATICHASH( PixelY );
	STATICHASH( ScreenY );
	float Y = Pick(
		ConfigManager::GetArchetypeFloat( sPixelY, sm_Archetype, 0.0f, sDefinitionName ),
		ParentHeight * ConfigManager::GetArchetypeFloat( sScreenY, sm_Archetype, 0.0f, sDefinitionName ) );
	
	STATICHASH( PixelWidth );
	STATICHASH( ScreenWidth );
	float Width = Pick(
		ConfigManager::GetArchetypeFloat( sPixelWidth, sm_Archetype, 0.0f, sDefinitionName ),
		ParentWidth * ConfigManager::GetArchetypeFloat( sScreenWidth, sm_Archetype, 0.0f, sDefinitionName ) );
	
	STATICHASH( PixelHeight );
	STATICHASH( ScreenHeight );
	float Height = Pick(
		ConfigManager::GetArchetypeFloat( sPixelHeight, sm_Archetype, 0.0f, sDefinitionName ),
		ParentHeight * ConfigManager::GetArchetypeFloat( sScreenHeight, sm_Archetype, 0.0f, sDefinitionName ) );

	STATICHASH( PixelBorder );
	m_Border = ConfigManager::GetArchetypeFloat( sPixelBorder, sm_Archetype, 0.0f, sDefinitionName );

	// Adjust for desired aspect ratio if one dimension is not given
	// (This is used to size images using ScreenWidth or ScreenHeight
	// properly regardless of screen aspect ratio.
	STATICHASH( AspectRatio );
	const float AspectRatio = ConfigManager::GetArchetypeFloat( sAspectRatio, sm_Archetype, 1.0f, sDefinitionName );
	if( Width == 0.0f )
	{
		Width = Height * AspectRatio;
	}
	else if( Height == 0.0f )
	{
		Height = Width / AspectRatio;
	}

	AdjustDimensionsToParent( X, Y, Width, Height, ParentX, ParentY, ParentWidth, ParentHeight );
	GetPositionFromOrigin( X, Y, Width, Height );

	ASSERT( Width > m_Border * 2.0f );
	ASSERT( Height > m_Border * 2.0f );

	STATICHASH( ClampToPixelGrid );
	if( ConfigManager::GetArchetypeBool( sClampToPixelGrid, sm_Archetype, true, sDefinitionName ) )
	{
		m_TopLeft.x = Round( m_TopLeft.x );
		m_TopLeft.y = Round( m_TopLeft.y );
	}

	// Offset to properly align on pixel grid.
	const float PixelGridOffset = GetPixelGridOffset();
	m_TopLeft.x -= PixelGridOffset;
	m_TopLeft.y -= PixelGridOffset;

	STATICHASH( Image );
	const char* const Filename = ConfigManager::GetArchetypeString( sImage, sm_Archetype, DEFAULT_TEXTURE, sDefinitionName );
	m_Texture = m_UIManager->GetRenderer()->GetTextureManager()->GetTexture( Filename, TextureManager::ETL_Permanent );

	m_Dimensions = Vector2( Width, Height );

	STATICHASH( MaterialOverride );
	const SimpleString DefaultMaterial( "Material_HUD" );
	m_Material = ConfigManager::GetArchetypeString( sMaterialOverride, sm_Archetype, DefaultMaterial.CStr(), sDefinitionName );

	UpdateRender();
}
Ejemplo n.º 22
0
void ik_foot_collider::collide( SIKCollideData &cld, const ik_foot_geom &foot_geom, CGameObject *O, bool foot_step )
{
	VERIFY( foot_geom.is_valid() ); 
	cld.collided = false;
	
	
	float pick_dist = collide_dist;
	//if( foot_step )
	pick_dist += reach_dist ;

//////////////////////////////////////////////////////////////////////////////////////
	const Fvector& toe_pick_v	= cld.m_pick_dir; 
	const Fvector pos_toe		= Fvector().sub( foot_geom.pos_toe(), Fvector( ).mul( toe_pick_v, collide_dist ) );
	ik_pick_query  q_toe( ik_foot_geom::toe, pos_toe, toe_pick_v, pick_dist );

////////////////////////////////////////////////////////////////////////////////////////
	const	Fvector hill_pick_v = cld.m_pick_dir;
	const	Fvector pos_heel	= Fvector().sub( foot_geom.pos_heel(), Fvector( ).mul( hill_pick_v, collide_dist ) );
	ik_pick_query  q_heel( ik_foot_geom::heel, pos_heel, hill_pick_v, pick_dist );

//////////////////////////////////////////////////////////////////////////////////////////
	const	Fvector side_pick_v = cld.m_pick_dir;
	const	Fvector pos_side	= Fvector().sub( foot_geom.pos_side(), Fvector( ).mul( side_pick_v, collide_dist ) );
	ik_pick_query  q_side( ik_foot_geom::side, pos_side, side_pick_v, pick_dist );
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	if( previous_toe_query.is_equal		( q_toe  )	&& 
		previous_heel_query.is_equal( q_heel )	&& 
		previous_side_query.is_equal( q_side ) 
	){
		cld = previous_data;
		return;
	}

	const float foot_length = Fvector().sub( pos_toe, pos_heel ).magnitude() * 1.5f;

	previous_heel_query = q_heel;
	previous_side_query = q_side;
	previous_toe_query	= q_toe;

	ik_pick_result r_toe(ik_foot_geom::toe);
	cld.collided = Pick( r_toe, q_toe, O );
	cld.m_plane = r_toe.p;
	cld.m_collide_point = ik_foot_geom::toe;
//////////////////////////////////////////////////////////////////////////////////////
	

#ifdef DEBUG
	if( ph_dbg_draw_mask1.test( phDbgDrawIKCollision ) )
	{
		DBG_DrawPoint( pos_toe, 0.01, D3DCOLOR_XRGB( 255, 0, 0));
		if(cld.collided)
			DBG_DrawPoint( r_toe.position, 0.01, D3DCOLOR_XRGB( 0, 0, 255));
	}
#endif

	ik_pick_result r_heel(ik_foot_geom::heel); 
	bool heel_collided = Pick( r_heel, q_heel, O ) ;

	ik_pick_result r_side(ik_foot_geom::side); 
	bool side_collided = Pick( r_side, q_side, O ) ;

	bool toe_heel_compatible = cld.collided && heel_collided && Fvector().sub( r_heel.position, r_toe.position ).magnitude() < foot_length;
	bool toe_side_compatible = cld.collided && side_collided && Fvector().sub( r_side.position, r_toe.position ).magnitude() < foot_length;


/*
	if( hill_collided )
	{
		if( !cld.collided || (r_hill.position.y - r_toe.position.y) > EPS )
		{
			cld.m_plane = r_heel.p;
			cld.m_collide_point = ik_foot_geom::heel;
			cld.collided = true;
			cld.m_pick_dir = heel_pick_v;
			
		} 
	}
*/


	if( toe_heel_compatible && toe_side_compatible )
	{
		
			Fplane plane;
			tri_plane( r_toe.position, r_heel.position , r_side.position, plane );
			if( plane.n.dotproduct( r_toe.p.n ) < 0.f )
			{
							
				plane.n.invert();
				plane.d = -plane.d;
			}

			 cld.m_plane  = plane;
#ifdef DEBUG
			if( ph_dbg_draw_mask1.test( phDbgDrawIKCollision ) )
			{
				DBG_DrawPoint( pos_toe, 0.01, D3DCOLOR_XRGB( 255, 0, 0));
				if(cld.collided)
				{
					 DBG_DrawTri( r_toe.position, r_heel.position, r_side.position, D3DCOLOR_XRGB( 0, 0, 255), false );
				}
			}
#endif
			previous_data = cld;
			return;
	}

	float hight = -FLT_MAX;
	ik_pick_result r = r_toe;

	
	if( cld.collided )
	{
		hight = r_toe.position.y;
	}

	if( heel_collided && r_heel.position.y > hight )
	{
		r = r_heel;
		hight = r_heel.position.y;
		cld.collided = true;
	}

	if( side_collided && r_side.position.y > hight )
	{
		r = r_side;
		hight = r_side.position.y;
		cld.collided = true;
	}

	if( cld.collided )
	{
		cld.m_plane = r.p;
		cld.m_collide_point =r.point;
		previous_data = cld;
		return;
	}


	//chose_best_plane( cld.m_plane, pick_v, plane, r_hill.p, r_toe.p   );


	previous_data = cld;

/*
	float u,v,d;
	if( ( !cld.collided ||
		  !( CDB::TestRayTri(pos_hill, pick_v, r_toe.triangle, u, v, d, true ) && d > 0.f ) ) &&
		    Pick( r_hill, pos_hill, pick_v, pick_dist, O ) )
	{

		if( !cld.collided || r_hill.position.y > r_toe.position.y )
		{
			cld.m_plane = r_hill.p;
			cld.m_collide_point = SIKCollideData::heel;
		} 
		
		//else
		//{
		//		ik_pick_result r_foot;
		//		Fvector pos_foot = Fvector().sub( foot.c, Fvector( ).mul( pick_v, collide_dist ) );
		//		if( cld.collided && Pick( r_foot, pos_foot, pick_v, pick_dist, O ) )
		//		{
		//			Fplane plane;
		//			tri_plane( r_toe.position, r_hill.position , r_foot.position, plane );

		//			DBG_DrawTri(r_toe.position, r_hill.position, r_foot.position , D3DCOLOR_XRGB( 255, 255, 255 ), false  );
		//		
		//			if( plane.n.dotproduct( r_hill.p.n ) < 0.f )
		//			{
		//				plane.n.invert();
		//				plane.d = -cld.m_plane.d;
		//			
		//			}
		//			chose_best_plane( cld.m_plane, pick_v, plane, r_hill.p, r_toe.p   );
		//		}
		//}
		
		cld.collided = true;
	}
*/
}
Ejemplo n.º 23
0
void UIWidgetImage::InitializeFromDefinition( const SimpleString& DefinitionName )
{
	UIWidget::InitializeFromDefinition( DefinitionName );

	MAKEHASH( DefinitionName );
	MAKEHASH( m_Archetype );

	STATICHASH( DisplayWidth );
	const float DisplayWidth	= ConfigManager::GetFloat( sDisplayWidth );
	const float ParentWidth		= m_OriginParent ? m_OriginParent->GetWidth() : DisplayWidth;
	const float ParentX			= m_OriginParent ? Ceiling( m_OriginParent->GetX() ) : 0.0f;

	STATICHASH( DisplayHeight );
	const float DisplayHeight	= ConfigManager::GetFloat( sDisplayHeight );
	const float ParentHeight	= m_OriginParent ? m_OriginParent->GetHeight() : DisplayHeight;
	const float ParentY			= m_OriginParent ? Ceiling( m_OriginParent->GetY() ) : 0.0f;

	STATICHASH( PixelX );
	STATICHASH( ScreenX );
	float X = Pick(
		ConfigManager::GetArchetypeFloat( sPixelX, sm_Archetype, 0.0f, sDefinitionName ),
		ParentWidth * ConfigManager::GetArchetypeFloat( sScreenX, sm_Archetype, 0.0f, sDefinitionName ) );

	STATICHASH( PixelY );
	STATICHASH( ScreenY );
	float Y = Pick(
		ConfigManager::GetArchetypeFloat( sPixelY, sm_Archetype, 0.0f, sDefinitionName ),
		ParentHeight * ConfigManager::GetArchetypeFloat( sScreenY, sm_Archetype, 0.0f, sDefinitionName ) );
	
	STATICHASH( PixelWidth );
	STATICHASH( ScreenWidth );
	float Width = Pick(
		ConfigManager::GetArchetypeFloat( sPixelWidth, sm_Archetype, 0.0f, sDefinitionName ),
		ParentWidth * ConfigManager::GetArchetypeFloat( sScreenWidth, sm_Archetype, 0.0f, sDefinitionName ) );

	STATICHASH( PixelHeight );
	STATICHASH( ScreenHeight );
	float Height = Pick(
		ConfigManager::GetArchetypeFloat( sPixelHeight, sm_Archetype, 0.0f, sDefinitionName ),
		ParentHeight * ConfigManager::GetArchetypeFloat( sScreenHeight, sm_Archetype, 0.0f, sDefinitionName ) );

	// Adjust for desired aspect ratio if one dimension is not given
	// (This is used to size images using ScreenWidth or ScreenHeight
	// properly regardless of screen aspect ratio.
	STATICHASH( AspectRatio );
	const float AspectRatio = ConfigManager::GetArchetypeFloat( sAspectRatio, sm_Archetype, 1.0f, sDefinitionName );
	if( Width == 0.0f )
	{
		Width = Height * AspectRatio;
	}
	else if( Height == 0.0f )
	{
		Height = Width / AspectRatio;
	}

	// Offset relative to resolved image dimensions if specified
	STATICHASH( ImageX );
	X = Pick( X, ConfigManager::GetArchetypeFloat( sImageX, sm_Archetype, 0.0f, sDefinitionName ) * Width );

	STATICHASH( ImageY );
	Y = Pick( Y, ConfigManager::GetArchetypeFloat( sImageY, sm_Archetype, 0.0f, sDefinitionName ) * Height );

	AdjustDimensionsToParent( X, Y, Width, Height, ParentX, ParentY, ParentWidth, ParentHeight );
	GetPositionFromOrigin( X, Y, Width, Height );

	STATICHASH( ClampToPixelGrid );
	if( ConfigManager::GetArchetypeBool( sClampToPixelGrid, sm_Archetype, true, sDefinitionName ) )
	{
		m_TopLeft.x = Round( m_TopLeft.x );
		m_TopLeft.y = Round( m_TopLeft.y );
	}

	// Offset to properly align on pixel grid.
	const float PixelGridOffset = GetPixelGridOffset();
	m_TopLeft.x -= PixelGridOffset;
	m_TopLeft.y -= PixelGridOffset;

	// If LoadImage is false, we're expecting to dynamically set the texture in code somewhere
	STATICHASH( LoadImage );
	if( ConfigManager::GetArchetypeBool( sLoadImage, sm_Archetype, true, sDefinitionName ) )
	{
		STATICHASH( Image );
		SetTexture( ConfigManager::GetArchetypeString( sImage, sm_Archetype, DEFAULT_TEXTURE, sDefinitionName ) );
	}

	m_Dimensions = Vector2( Width, Height );

	STATICHASH( Calibration );
	m_Calibration = ConfigManager::GetArchetypeBool( sCalibration, sm_Archetype, false, sDefinitionName );

	STATICHASH( MaterialOverride );
	const SimpleString DefaultMaterial( "Material_HUD" );
	m_Material = ConfigManager::GetArchetypeString( sMaterialOverride, sm_Archetype, DefaultMaterial.CStr(), sDefinitionName );

	UpdateRender();
}
Ejemplo n.º 24
0
int main(int argc, char *argv[]) {


    if (argc < 3) {
        printf("Usage: %s <SAC_file> <pick_file>\n", argv[0]);
        printf("  Picks are appended to end of <pick_file> in NLLOC_OBS format. \n");
        return 0;
    }



    BOOLEAN_INT useMemory = FALSE_INT; // set to TRUE_INT (=1) if function is called for packets of data in sequence, FALSE_INT (=0) otherwise



    // open and read SAC file
    FILE *fp;
    if ((fp = fopen(argv[1], "r")) == 0) {
        perror(argv[1]);
        return -1;
    }
    // read header
    struct HDR sachdr;
///    fread(&sachdr, sizeof (sachdr), 1, fp);
    // allocate array for data
    sachdr.NPTS = 329;
    printf("sachdr.NPTS: %d\n", sachdr.NPTS);
    float* sample = calloc(sachdr.NPTS, sizeof (float));
    // read data
    int k1;
    int seq;
    float value;
    for(k1=0;k1<sachdr.NPTS;k1++)
    {
      fscanf(fp,"%d %f",&seq,&value);
      printf("%3d %8.3f\n",seq,value);
      sample[k1]=value;
//      fscanf(fp,"%d %f",seq,&sample[k1]);
    }
//    fread(sample, sizeof (float), sachdr.NPTS, fp);
    fclose(fp);
printf("%8.3f\n",sample[325]);


    // set picker paramters (TODO: make program arguments?)
    // SEE: _DOC_ in FilterPicker5.c for more details on the picker parameters
    // defaults
    // filp_test filtw 4.0 ltw 10.0 thres1 8.0 thres2 8.0 tupevt 0.2 res PICKS...
    double filterWindow = 4.0; // NOTE: auto set below
    double longTermWindow = 10.0; // NOTE: auto set below
    double threshold1 = 10.0;
    double threshold2 = 10.0;
    double tUpEvent = 0.5; // NOTE: auto set below
    //
    // auto set values
    // get dt
    sachdr.DELTA = 0.020;
    double dt = sachdr.DELTA;
    printf("sachdr.DELTA: %f\n", sachdr.DELTA);
    //dt = dt < 0.02 ? 0.02 : dt;     // aviod too-small values for high sample rate data
    //
    filterWindow = 300.0 * dt;
    printf("filterWindow: %8.3f\n",filterWindow);
    long iFilterWindow = (long) (0.5 + filterWindow * 1000.0);
    printf("iFilterWindow: %8.3f\n",iFilterWindow);
    if (iFilterWindow > 1)
        filterWindow = (double) iFilterWindow / 1000.0;
    printf("iFilterWindow: %8.3f\n",iFilterWindow);
    //
    longTermWindow = 500.0 * dt; // seconds
    long ilongTermWindow = (long) (0.5 + longTermWindow * 1000.0);
    if (ilongTermWindow > 1)
        longTermWindow = (double) ilongTermWindow / 1000.0;
    //
    tUpEvent = 20.0 * dt; // time window to take integral of charFunct version
    long itUpEvent = (long) (0.5 + tUpEvent * 1000.0);
    if (itUpEvent > 1)
        tUpEvent = (double) itUpEvent / 1000.0;
    //
    printf("picker_func_test: filp_test filtw %f ltw %f thres1 %f thres2 %f tupevt %f res PICKS\n",
            filterWindow, longTermWindow, threshold1, threshold2, tUpEvent);



    // do picker function test
    PickData** pick_list = NULL; // array of num_picks ptrs to PickData structures/objects containing returned picks
    int num_picks = 0;
    FilterPicker5_Memory* mem = NULL;

    Pick(
            sachdr.DELTA,
            sample,
            sachdr.NPTS,
            filterWindow,
            longTermWindow,
            threshold1,
            threshold2,
            tUpEvent,
            &mem,
            useMemory,
            &pick_list,
            &num_picks,
            "TEST"
            );
    printf("picker_func_test: num_picks: %d\n", num_picks);

    // create NLLOC_OBS picks
    // open pick file
    if ((fp = fopen(argv[2], "a")) == 0) {
        perror(argv[2]);
        return -1;
    }
    // date
    int month, day;
    MonthDay(sachdr.NZYEAR, sachdr.NZJDAY, &month, &day);
    double sec = (double) sachdr.B + (double) sachdr.NZSEC + (double) sachdr.NZMSEC / 1000.0;
    // id fields
    char onset[] = "?";
    char* kstnm;
    kstnm = calloc(1, 16 * sizeof (char));
    strncpy(kstnm, sachdr.KSTNM, 6);
    char* kinst;
    kinst = calloc(1, 16 * sizeof (char));
    strncpy(kinst, sachdr.KINST, 6);
    if (strstr(kinst, "(count") != NULL)
        strcpy(kinst, "(counts)");
    char* kcmpnm;
    kcmpnm = calloc(1, 16 * sizeof (char));
    strncpy(kcmpnm, sachdr.KCMPNM, 6);
    char phase[16];
    // create NLL picks
    char* pick_str;
    pick_str = calloc(1, 1024 * sizeof (char));
    int n;
    for (n = 0; n < num_picks; n++) {
        sprintf(phase, "P%d_", n);
        pick_str = printNlloc(pick_str,
                *(pick_list + n), sachdr.DELTA, kstnm, kinst, kcmpnm, onset, phase,
                sachdr.NZYEAR, month, day, sachdr.NZHOUR, sachdr.NZMIN, sec);
        // write pick to <pick_file> in NLLOC_OBS format
        fprintf(fp, "%s\n", pick_str);
    }


    // clean up
    fclose(fp);
    free(pick_str);
    free(kcmpnm);
    free(kinst);
    free(kstnm);
    free_FilterPicker5_Memory(&mem);
    free_PickList(pick_list, num_picks);
    free(sample);

    return (0);

}
void ShowCommands()
{
	//acciones de palabras simples
	std::string action = stackCommands.Consult().c_str();
	int i = 0;
	char result = 's';
	switch (Hashit(Upcase(action)))
	{
	case	ayuda:

			printf(HELP_LIST);
			colortext(WHITE); printf(LEAVE); colortext(LIGHTGREY); printf(HELP_LEAVE);
			colortext(WHITE); printf(OPEN_DOOR); colortext(LIGHTGREY); printf(HELP_OPEN_DOOR);
			colortext(WHITE); printf(CLEAR_SCREEN); colortext(LIGHTGREY); printf(HELP_CLEAR_SCREEN);
			colortext(WHITE); printf(PICKUP); colortext(LIGHTGREY); printf(HELP_PICKUP);
			colortext(WHITE); printf(EAST); colortext(LIGHTGREY); printf(HELP_EAST);
			colortext(WHITE); printf(PUT_IN_BAG); colortext(LIGHTGREY); printf(HELP_PUT_IN_BAG);
			colortext(WHITE); printf(INV); colortext(LIGHTGREY); printf(HELP_INV);
			colortext(WHITE); printf(LOOK); colortext(LIGHTGREY); printf(HELP_LOOK);
			colortext(WHITE); printf(NORTH); colortext(LIGHTGREY); printf(HELP_NORTH);
			colortext(WHITE); printf(WEST); colortext(LIGHTGREY); printf(HELP_WEST);
			colortext(WHITE); printf(EXITS); colortext(LIGHTGREY); printf(HELP_EXITS);
			colortext(WHITE); printf(DROP); colortext(LIGHTGREY); printf(HELP_DROP);
			colortext(WHITE); printf(GET_FROM_BAG); colortext(LIGHTGREY); printf(GET_FROM_BAG);
			colortext(WHITE); printf(SOUTH); colortext(LIGHTGREY); printf(HELP_SOUTH);
			
			break;
	case	mirar:
		NewRoom();
		break;
	case	norte:
		if (myMap.CheckN(myPlayer.GetLatitude(), myPlayer.GetLongitude()) > 0 && myMap.CheckN(myPlayer.GetLatitude(), myPlayer.GetLongitude()) < 100)
		{
			myPlayer.SetLatitude(myPlayer.GetLatitude() - 1);
			NewRoom();
		}
		else printf(NO_EXITS);
		break;
	case	sur:
		if (myMap.CheckS(myPlayer.GetLatitude(), myPlayer.GetLongitude())> 0 && myMap.CheckS(myPlayer.GetLatitude(), myPlayer.GetLongitude()) < 100)
		{
			myPlayer.SetLatitude(myPlayer.GetLatitude() + 1);
			NewRoom();
		}
		else printf(NO_EXITS);
		break;
	case	este:
		if (myMap.CheckE(myPlayer.GetLatitude(), myPlayer.GetLongitude())> 0 && myMap.CheckE(myPlayer.GetLatitude(), myPlayer.GetLongitude()) < 100)
		{
			myPlayer.SetLongitude(myPlayer.GetLongitude() + 1);
			NewRoom();
		}
		else printf(NO_EXITS);
		break;
	case	oeste:

		if (myMap.CheckW(myPlayer.GetLatitude(), myPlayer.GetLongitude())> 0 && myMap.CheckW(myPlayer.GetLatitude(), myPlayer.GetLongitude()) < 100)
		{
			myPlayer.SetLongitude(myPlayer.GetLongitude() - 1);
			NewRoom();
		}
		else printf(NO_EXITS);
		break;
	case	salidas:
		myMap.ShowExits(myPlayer.GetLatitude(), myPlayer.GetLongitude());
		break;
	case	cls:
		system("cls");
		break;
	case	inventario:
		printf(INVENTORY);
		if (bag.GetState() == 's')
			printf(Show_Item(bag.GetDescription().c_str()));

		if (myPlayer.inventory.Size() > 0)
		{
				for (int i = 0; i < myPlayer.inventory.Size(); ++i)
					printf(Show_Item(myPlayer.inventory.GetDescPosN(i).c_str()));
		}
			else
				if ( bag.GetState() != 's' ) printf( NOTHING_TO_SHOW );
		break;
	default:
		result = 'n';
		break;
	}
	//acciones de 2 palabras
	action = GetWord(stackCommands.Consult().c_str());
	Item::Node *tmp;
	switch (Hashit(Upcase(action)))
	{
	case	coger:
		action = CutFirstWord(stackCommands.Consult().c_str());
		action = GetWord(action.c_str());
	
		if (action == BAG)
		{
			bag.ToInventory(myPlayer.GetLatitude(), myPlayer.GetLongitude());
		}
		else
		{
			tmp = myMap.GetFromMap(myPlayer.GetLatitude(), myPlayer.GetLongitude(), action);
			if (tmp != nullptr)
			{
				printf(Pick(action.c_str()));
				myPlayer.inventory.Push(tmp->name, tmp->description);
				if (tmp->name == "espada") // habitacion - El burladero de la esquina sur este.
				{
					colortext(YELLOW);
					printf(GAME_OVER);
					gameState = endLoop;
					return;
				}
				delete tmp;
			}
			else
			{
				printf(Not_found(action.c_str()));
			}
		}
		break;
	case	tirar:
		action = CutFirstWord(stackCommands.Consult().c_str());
		action = GetWord(action.c_str());

		if (action == BAG)
		{
			bag.DropItem(myPlayer.GetLatitude(), myPlayer.GetLongitude());
	
		}
		else
		{
			tmp = myPlayer.GetInventory(action);
			if (tmp != nullptr)
			{
				printf(Drop_Item(action.c_str()));
				myMap.DropToMap(myPlayer.GetLatitude(), myPlayer.GetLongitude(), tmp);
				delete tmp;
			}
			else
			{
				printf(Inventory_void(action.c_str()));
			}
		}
		break;
	case guardar:

		if (bag.GetState() != 's')
			printf(NO_BAG);
		else
		{
			action = CutFirstWord(stackCommands.Consult().c_str());
			action = GetWord(action.c_str());

			tmp = myPlayer.GetInventory(action);
			if (tmp != nullptr)
			{
				printf(Put_in_bag(action.c_str()));
				bag.ilist.Push(tmp->name, tmp->description);
				delete tmp;
			}
			else
			{
				if (action == BAG) printf(BAG_IN_BAG);
				else printf(Inventory_void(action.c_str()));
			}
		}
		break; case sacar:

			if (bag.GetState() != 's')
				printf(NO_BAG);
			else
			{
				action = CutFirstWord(stackCommands.Consult().c_str());
				action = GetWord(action.c_str());
				tmp = bag.GetFromContainer(action);
				if (tmp != nullptr)
				{
					printf(Pick(action.c_str()));
					myPlayer.inventory.Push(tmp->name, tmp->description);
					delete tmp;
				}
				else
				{
					printf(Not_In_bag(action.c_str()));
				}
			}
			break;
		case abrir:
			if (myPlayer.inventory.Size() > 0)
				if (myPlayer.inventory.HaveItem("llave"))
				{
					action = CutFirstWord(stackCommands.Consult().c_str());
					action = GetWord(action.c_str());
					switch ((Hashit(Upcase(action))))
					{
					case sur:
						myMap.OpenDoor(myPlayer.GetLatitude() + 1 , myPlayer.GetLongitude());
						break;
					case norte:
						myMap.OpenDoor(myPlayer.GetLatitude() - 1, myPlayer.GetLongitude());
						break;
					case este:
						myMap.OpenDoor(myPlayer.GetLatitude(), myPlayer.GetLongitude() + 1);
						break;
					case oeste:
						myMap.OpenDoor(myPlayer.GetLatitude(), myPlayer.GetLongitude() - 1);
						break;
					default:
						break;
					}
				}
				else
					printf(Inventory_void("llave"));
			else
					printf(Inventory_void("llave"));
				break;
		default:
			if (result == 'n')
				printf(NO_ACTION);
		break;
	}

	Prompt();
	stackCommands.Pop();
}