Ejemplo n.º 1
0
    int FindNearestNewIndex(int nOldIndex)
    {
        if (nOldIndex == -1 || m_vectItemsOld.GetCount() == 0)
            return -1;
        
        ZAssert(nOldIndex >= 0 && nOldIndex < m_vectItemsOld.GetCount());

        int nNewIndex;

        // check to see if the old item exists in the new list
        nNewIndex = m_plist->GetIndex(m_vectItemsOld[nOldIndex]);

        // if we haven't found a new index yet, try searching the items around it
        int iDelta = 1;
        while (nNewIndex == -1 
            && (nOldIndex - iDelta >= 0 
                || nOldIndex + iDelta < m_vectItemsOld.GetCount()))
        {
            if (nOldIndex - iDelta >= 0)
                nNewIndex = m_plist->GetIndex(m_vectItemsOld[nOldIndex - iDelta]);

            if (nNewIndex != -1 && nOldIndex + iDelta < m_vectItemsOld.GetCount())
                nNewIndex = m_plist->GetIndex(m_vectItemsOld[nOldIndex - iDelta]);

            ++iDelta;
        }

        // if we still haven't found a new index, default to the first item
        if (nNewIndex == -1)
        {
            nNewIndex = 0;
        }

        return nNewIndex;
    }
Ejemplo n.º 2
0
	void SetColorKey(const Color& color)
	{
		ZAssert(m_datas.GetCount() == 0);
		ZAssert(m_datasConverted.GetCount()	== 0);

		m_bColorKey	= true;
		m_colorKey = color;

		// Update the ddraw	surface
		SetSurfaceMode(SurfaceModeDD);
		DDCOLORKEY key;
		key.dwColorSpaceLowValue  =
		key.dwColorSpaceHighValue =	m_data.m_ppf->MakePixel(m_colorKey).Value();

//		DDCall(m_data.m_pdds->SetColorKey(DDCKEY_SRCBLT, &key));

		// Update the converted	ddraw surface
		if( m_dataConverted.m_pd3dtexture )	
		{
			_ASSERT( false );
//			DDCall(m_dataConverted.m_pdds->SetColorKey(DDCKEY_SRCBLT, &key));
		}

		SurfaceChanged();
	}
Ejemplo n.º 3
0
    void ScrollToItemByIdx(int iItem)
    {        
        if (m_vItems.GetCount() == 0)
            {
            // nothing to do
            return;
            }

        ZAssert((iItem == 0) || ((iItem > 0) && (iItem < m_vItems.GetCount())));

        // find the first and last matching item
        int iTop, iBottom;
        iTop = iBottom = iItem;
        while (iTop > 0 && m_vItems[iTop-1] == m_vItems[iTop])
            iTop--;
        while (iBottom < m_vItems.GetCount()-1 && m_vItems[iBottom+1] == m_vItems[iBottom])
            iBottom++;

        if (iBottom > LastVisibleItem())
            m_iTopItem = max(iBottom - (m_cVisibleItems - 1), 0);
        if (iTop < m_iTopItem)
            m_iTopItem = iTop;

        if (m_pScrollPane)
            m_pScrollPane->SetPos(m_iTopItem);            

        NeedPaint();
    }
Ejemplo n.º 4
0
    void Paint( Surface * pSurface )
	{
        if (m_pImageBkgnd)
		{	
			// TBD: See original function below.
			_ASSERT( false );
		}

        // calc num Items to draw
        int iLastVisibleItem = LastVisibleItem();
        int iLastItem = m_vItems.GetCount() - 1;
        if (iLastVisibleItem > iLastItem)
            iLastVisibleItem = iLastItem;

        // draw each Item
        WinRect rectPaint = WinRect(0, 0, m_nItemWidth, YSize());
        WinRect rectItem = rectPaint;
        rectItem.bottom = rectItem.top;
        ZAssert(m_iTopItem >= 0);

        // count the number of slots for the first item which we are not drawing
        int nNumHiddenSlots = 0;
        
        if (m_vItems.GetCount() > 0)
        {
            while (m_iTopItem - nNumHiddenSlots > 0 
                && m_vItems[m_iTopItem - (nNumHiddenSlots + 1)] == m_vItems[m_iTopItem])
                nNumHiddenSlots++;

			for (int iItem = m_iTopItem;
						iItem <= iLastVisibleItem; 
						iItem += m_vItems[iItem]->GetItemHeight() - nNumHiddenSlots, nNumHiddenSlots = 0 )
			{
				rectItem.top = rectItem.bottom;
				int nLinesLeft = (iLastVisibleItem - iItem) + 1;
				int nLines = m_vItems[iItem]->GetItemHeight() - nNumHiddenSlots;
				rectItem.bottom += m_nItemHeight * (nLines > nLinesLeft ? nLinesLeft : nLines);

				// draw highlight if selected
				bool bItemSel = (m_iSelItem == iItem);
				if (bItemSel && m_pImageBkgndSel)
				{
					// TBD: See original function below.
					_ASSERT( false );
				}

				// draw item
				m_vItems[iItem]->DrawItem(pSurface, rectItem, bItemSel, nNumHiddenSlots);
			}
		}
	}
Ejemplo n.º 5
0
    ZString GetString(int indent)
    {
        // KeyFramedTranslate([ time, x, y, z ], frame)

        ZString str = "KeyFramedTranslate(\n" + Indent(indent + 1) + "[\n";

        int count = m_keys.GetCount();
        for (int index = 0; index < count; index++) {
            str +=
                  Indent(indent + 2)
                + ZString(m_keys[index].m_frame) + ", "
                + ZString(m_keys[index].m_vec.X()) + ", "
                + ZString(m_keys[index].m_vec.Y()) + ", "
                + ZString(m_keys[index].m_vec.Z());

            if (index < count - 1) {
                str += ",\n";
            } else {
                str += "\n";
            }
        }

        return
              str
            + Indent(indent + 1) + "],\n"
            + Indent(indent + 1) + GetFrame()->GetChildString(indent + 1) + "\n"
            + Indent(indent) + ")";
    }
Ejemplo n.º 6
0
    void Evaluate()
    {
        float frame = GetFrame()->GetValue();

        int count = m_keys.GetCount();

        if (frame <= m_keys[0].m_frame) {
            //
            // Before first key
            //

            GetValueInternal().SetTranslate(m_keys[0].m_vec);
        } else if (frame >= m_keys[count - 1].m_frame) {
            //
            // After last key
            //

            GetValueInternal().SetTranslate(m_keys[count - 1].m_vec);
        } else {
            //
            // Between two keys
            //

            int index = 0;

            while (frame > m_keys[index + 1].m_frame) {
                index++;
            }

            Vector vecDelta    = m_keys[index + 1].m_vec - m_keys[index].m_vec;
            float  interpolant = (frame - m_keys[index].m_frame) / (m_keys[index + 1].m_frame - m_keys[index].m_frame);

            GetValueInternal().SetTranslate(m_keys[index].m_vec + vecDelta * interpolant);
        }
    }
Ejemplo n.º 7
0
    void CalcBounds()
    {
        int rows    = m_vvstr.GetCount();
        int columns = m_vvstr[0].GetCount();

        float xsize = 0;

        for (int column = 0; column < columns; column++) {
            m_vColumn.Set(column, xsize);

            float xsizeColumn = 0;
            for (int row = 0; row < rows; row++) {
                WinPoint size = m_pfont->GetTextExtent(m_vvstr[row][column]);
                if ((float)size.X() > xsizeColumn) {
                    xsizeColumn = (float)size.X();
                }
            }

            xsize += xsizeColumn + 4;
        }    

        m_bounds.SetRect(
            Rect(
                0, 
                (float)(-(rows * m_ysizeRow)), 
                (float)xsize, 
                0
            )
        );
    }
Ejemplo n.º 8
0
 TRef<ListItem>  GetItemByIdx(long iItem)
 {
     if ((-1 >= iItem) || (iItem >= m_vItems.GetCount()))
         return NULL;
     else
         return m_vItems[iItem];
 }
Ejemplo n.º 9
0
	// TE: Added PartialInvest method to trigger right-clicking
    void PartialInvestItemByIdx(int iItem)
    {
        if (iItem < 0)
            iItem = -1;
        if (iItem >= m_vItems.GetCount())
            iItem = m_vItems.GetCount() - 1;

        // find the first matching item
        while (iItem >= 1 && m_vItems[iItem-1] == m_vItems[iItem])
            iItem--;

        m_iSelItem = iItem;
 
        NeedPaint();
        m_pRightClickEventSource->Trigger(m_iSelItem);
    }
 Number* GetValue(int id)
 {
     if (id < m_vvalueObject.GetCount()) {
         return m_vvalueObject[id]->GetValue();
     } else {
         return NULL;
     }
 }
 Boolean* IsDown(int id)
 {
     if (id < m_vbuttonObject.GetCount()) {
         return m_vbuttonObject[id]->GetValue();
     } else {
         return NULL;
     }
 }
Ejemplo n.º 12
0
	//Imago #133 7/10
    void NextItem()
    {
        if (GetSelItemIdx() < m_vItems.GetCount() - 1) {
			SetSelItemByIdx(GetSelItemIdx()+1);
			if ((GetScrollPosition() + m_cVisibleItems) <= GetSelItemIdx())
				ScrollPageDown();
		}
    }
Ejemplo n.º 13
0
    void SetScrollPosition(int iPosition)
    {
        m_iTopItem = iPosition;

        if (m_iTopItem > (m_vItems.GetCount() - m_cVisibleItems)) {
            m_iTopItem = max(0, m_vItems.GetCount() - m_cVisibleItems);
        }

        if (m_iTopItem < 0) {
            m_iTopItem = 0;
        }
                
        if (m_pScrollPane) {
            m_pScrollPane->SetPos(m_iTopItem);
        }

        NeedPaint();
    }
Ejemplo n.º 14
0
 void RemoveAll()
 {
     m_vItems.SetEmpty();
     if (m_pScrollPane) {
         m_pScrollPane->SetSize(m_vItems.GetCount());
         m_pScrollPane->SetPos(0);
     }
     SetSelItemByIdx(-1);
     NeedPaint();
 }
Ejemplo n.º 15
0
 int GetItemIdx(ListItem* pListItem)
 {
     int cItems = m_vItems.GetCount();
     for (int iItem = 0; iItem < cItems; iItem++)
         {
         if (m_vItems[iItem] == pListItem)
             return iItem;
         }
     return -1;
 }
Ejemplo n.º 16
0
 int GetItemIdxByData(long lItemData)
 {
     int cItems = m_vItems.GetCount();
     for (int iItem = 0; iItem < cItems; iItem++)
         {
         if (m_vItems[iItem]->GetItemData() == lItemData)
             return iItem;
         }
     return -1;
 }
Ejemplo n.º 17
0
    void AddKey(float frame, const Vector& vec)
    {
        int count = m_keys.GetCount();

        ZAssert(count == 0 || frame > m_keys.GetEnd().m_frame);

        m_keys.PushEnd();
        m_keys.GetEnd().m_frame = frame;
        m_keys.GetEnd().m_vec   = vec;
    }
Ejemplo n.º 18
0
    void AddKey(float frame, const Quaternion& quat)
    {
        int count = m_keys.GetCount();

        ZAssert(count == 0 || frame > m_keys.GetEnd().m_frame);

        m_keys.PushEnd();
        m_keys.GetEnd().m_frame = frame;
        m_keys.GetEnd().m_quat  = quat;
    }
Ejemplo n.º 19
0
    void AddExplosion(
        const Vector&                 position,
        const Vector&                 forward,
        const Vector&                 right,
        const Vector&                 dposition,
		float                         radiusExplosion,
        float                         radiusShockWave,
        const Color&                  color,
        int                           countDecals,
        TVector<TRef<AnimatedImage> > vpimage,
        Image*                        pimageShockwave
    ) {
        //
        // Add the shockwave
        //

		if (pimageShockwave != NULL) {
			m_listShockwave.PushFront();
			ShockwaveData& sdata = m_listShockwave.GetFront();

			sdata.m_timeStart       = GetTime()->GetValue();
			sdata.m_pimageShockwave = pimageShockwave;
			sdata.m_color           = color;
			sdata.m_position        = position;
			sdata.m_dposition       = dposition;
			sdata.m_scale           = radiusShockWave;
			sdata.m_forward         = forward;
			sdata.m_right           = right;
		}

        //
        // Add the little explosions
        //

        int countImage = vpimage.GetCount();
        int indexImage = 0;

        for (int index = 0; index < countDecals; index++) {
            ExplosionDataList& list  = m_vlistExplosion.Get(index);
            list.PushFront();
            ExplosionData&     edata = list.GetFront();

            edata.m_timeStart = GetTime()->GetValue() + index * 0.25f;
            edata.m_pimage    = vpimage[indexImage];
            edata.m_position  = position + Vector::RandomPosition(radiusExplosion * 0.5f);
            edata.m_dposition = dposition;
            edata.m_angle     = random(0, 2 * pi);
            edata.m_scale     = radiusExplosion;

            indexImage++;
            if (indexImage >= countImage) {
                indexImage = 0;
            }
        }
    }
    void DeltaWheel(int dz)
    {
        if (dz != 0 ) {
            //ZDebugOutput("MouseDZ: " + ZString(dz) + "\n");
            m_z += float(dz);

            if (m_vvalueObject.GetCount() >= 3) {
                m_vvalueObject[0]->GetValue()->SetValue(m_z);
            }
        }
    }
 JoystickInputStream* GetJoystick(int index)
 {
     if (
            index >= 0
         && index < m_vjoystickInputStream.GetCount()
     ) {
         return m_vjoystickInputStream[index];
     } else {
         return NULL;
     }
 }
Ejemplo n.º 22
0
    float GetRadius(const Matrix& mat)
    {
        float radius = 0;
        int count = m_vvertex.GetCount();
        for(int index = 0; index < count; index++) {
            Vector vec = mat.Transform(m_vvertex[index].GetPosition());
            radius = max(radius, vec.Length());
        }

        return radius;
    }
Ejemplo n.º 23
0
    void RemoveItemByIdx(int iItem)
    {
        int numRemoved = 0;

        if (iItem != -1) {
            // find the first matching item

            while (iItem > 1 && m_vItems[iItem-1] == m_vItems[iItem]) {
                iItem--;
            }

            // now remove all the matching items

            TRef<ListItem> pListItem = m_vItems[iItem];
            while (iItem < m_vItems.GetCount() && m_vItems[iItem] == pListItem) {
                m_vItems.Remove(iItem);
                numRemoved++;
            }
                
            if (iItem <= m_iSelItem) {
                SetSelItemByIdx(m_iSelItem - numRemoved);
            } else {
                SetSelItemByIdx(m_iSelItem);
            }

            if (m_pScrollPane) {
                // save the old top item, because shrinking the scroll pane could change it
                int iOldTopItem = m_iTopItem;

                m_pScrollPane->SetSize(m_vItems.GetCount());
                
                if (iItem < iOldTopItem) {
                    SetScrollPosition(max(iOldTopItem - numRemoved, 0));
                } else {
                    SetScrollPosition(min(iOldTopItem, 
                        max(m_vItems.GetCount() - m_cVisibleItems, 0)));
                }
            }
            NeedPaint();
        }
    }
    void Update()
    {
        if (m_bFocus) {
            m_pmouseInputStream->Update();

            int count = m_vjoystickInputStream.GetCount();

            for(int index = 0; index < count; index++) {
                m_vjoystickInputStream[index]->Update();
            }
        }
    }
    void SetFocus(bool bFocus)
    {
        if (m_bFocus != bFocus) {
            m_bFocus = bFocus;

            int count = m_vjoystickInputStream.GetCount();

            for(int index = 0; index < count; index++) {
                m_vjoystickInputStream[index]->SetFocus(m_bFocus);
            }
        }
    }
Ejemplo n.º 26
0
 void UpdateAll()
 {
     bool bNeedPaint = false;
     for (int iItem = 0; iItem < m_vItems.GetCount(); 
                 iItem += m_vItems[iItem]->GetItemHeight())
         {
         if (m_vItems[iItem]->Update())
             bNeedPaint = true;
         }
     if (bNeedPaint)
         NeedPaint();
 }
Ejemplo n.º 27
0
 void DrawItem(Surface* pSurface, const WinRect& rect, bool fSelected, int iFirstSlot)
 {
     IEngineFont* pfont = m_pchatInfo->IsFromLeader() ? TrekResources::SmallBoldFont() : TrekResources::SmallFont();
     WinPoint pt(rect.Min() + WinPoint(3,3));
     for (
         int i = iFirstSlot; 
         i < m_vMsgLines.GetCount() && pt.Y() < rect.YMax(); 
         i++
     ) {
         pSurface->DrawString(pfont, m_pchatInfo->GetColor(), pt, m_vMsgLines[i]);
         pt += WinPoint(0, m_ptLineSize.Y());
     }
 }
Ejemplo n.º 28
0
    void EliminateModes(const WinPoint& size)
    {
        int count = m_modes.GetCount();

        for(int index = 0; index < count; index++) {
            if (
                   m_modes[index].X() >= size.X() 
                && m_modes[index].Y() >= size.Y() 
            ) {
                m_modes.SetCount(index);
                return;
            }
        }
    }
Ejemplo n.º 29
0
    WinPoint NextMode(const WinPoint& size)
    {
        int count = m_modes.GetCount();

        for(int index = 0; index < count; index++) {
            if (
                   m_modes[index].X() > size.X() 
                || m_modes[index].Y() > size.Y() 
            ) {
                return m_modes[index];
            }
        }

        return m_modes[count - 1];
    }
Ejemplo n.º 30
0
    WinPoint PreviousMode(const WinPoint& size)
    {
        int count = m_modes.GetCount();

        for(int index = count - 1 ; index > 0; index--) {
            if (
                   m_modes[index].X() < size.X() 
                || m_modes[index].Y() < size.Y() 
            ) {
                return m_modes[index];
            }
        }

        return m_modes[0];
    }