Ejemplo n.º 1
0
TRef<INameSpace> EffectApp::OptimizeThingGeo(const ZString& str, Geo* pgeo, Number* pnumber)
{
    //
    // Get the time value
    //

    TRef<INameSpace> pnsModel = GetModeler()->GetNameSpace("model");
    TRef<Number>     pnumberTime; CastTo(pnumberTime, pnsModel->FindMember("time"));

    //
    // we are going to create a namespace with all the stuff needed by a ThingGeo
    //

    TRef<INameSpace> pns = GetModeler()->CreateNameSpace(str, m_pns);

    if (pnumber != NULL) {
        pns->AddMember("frame", pnumber);
    }

    //
    // Wrap the Geo up so we don't lose the pointer as we do optimizations
    //

    TRef<WrapGeo> pwrap = new WrapGeo(pgeo);
    pwrap->Update();

    //
    // Add a LightsGeo to the Group
    //

    TRef<LightsGeo> plights = new LightsGeo(GetModeler(), pnumberTime);

    //
    // Add a list of frames
    //

    TRef<FrameDataListValue> pframes = new FrameDataListValue();

    //
    // Extract the lights and frames
    //

    ZDebugOutput("Before Callback: " + ZString(pwrap->GetGeo()->GetNodeCount()) + "\n");

    TRef<GroupGeoCallbackImpl> pcallback = new GroupGeoCallbackImpl(pframes, plights);
    pwrap->GetGeo()->CallGroupGeoCallback(Matrix::GetIdentity(), pcallback);

    //
    // If there are any lights or frames add them to the namespace
    //

    if (plights->GetCount() > 0) {
        pns->AddMember("lights", plights);
    }

    if (pframes->GetList().GetCount() > 0) {
        pns->AddMember("frames", pframes);
    }

    //
    // Optimize the geo
    //

    bool bAnyFold;
    TRef<Geo> pgeoFold;
    do {
        bAnyFold = false;
        ZDebugOutput("Before RemoveMaterial: " + ZString(pwrap->GetGeo()->GetNodeCount()) + "\n");

        pgeoFold = pwrap->GetGeo()->RemoveMaterial();

        if (pgeoFold) {
            bAnyFold = true;
            pwrap->SetGeo(pgeoFold);
            ZDebugOutput("Before           Fold: " + ZString(pwrap->GetGeo()->GetNodeCount()) + "\n");
            pwrap->GetGeo()->DoFold();
        }

        ZDebugOutput("Before    FoldTexture: " + ZString(pwrap->GetGeo()->GetNodeCount()) + "\n");
        pgeoFold = pwrap->GetGeo()->FoldTexture();

        if (pgeoFold) {
            bAnyFold = true;
            pwrap->SetGeo(pgeoFold);
            ZDebugOutput("Before           Fold: " + ZString(pwrap->GetGeo()->GetNodeCount()) + "\n");
            pwrap->GetGeo()->DoFold();
        }
        if (!bAnyFold) {
            ZDebugOutput("Before           Fold: " + ZString(pwrap->GetGeo()->GetNodeCount()) + "\n");
            bAnyFold = pwrap->GetGeo()->DoFold();
        }
    } while (bAnyFold);

    ZDebugOutput("After Optimization: " + ZString(pwrap->GetGeo()->GetNodeCount()) + "\n");

    //
    // We're done
    //

    pns->AddMember("object", pwrap->GetGeo());

    return pns;
}
Ejemplo n.º 2
0
    TrainingScreen(Modeler* pmodeler)
    {
        // terminate existing training game if there was one
        KillStandaloneGame ();  //no more standalone training game Imago 6/22/09

        //
        // exports
        //

        TRef<INameSpace> pnsTrainingData = pmodeler->CreateNameSpace("trainingdata", pmodeler->GetNameSpace("gamepanes"));

        pnsTrainingData->AddMember("missionNumber", g_pnumberMissionNumber = new ModifiableNumber(m_iMissionNext));

        // Load the members from MDL

        TRef<INameSpace> pns = pmodeler->GetNameSpace("TrainingScreen");

        CastTo(m_ppane,                     pns->FindMember("screen"                    ));
        CastTo(m_pbuttonBack,               pns->FindMember("backButtonPane"            ));
        CastTo(m_pbuttonTrainMission1,      pns->FindMember("trainMission1ButtonPane"   ));
        CastTo(m_pbuttonTrainMission2,      pns->FindMember("trainMission2ButtonPane"   ));
        CastTo(m_pbuttonTrainMission3,      pns->FindMember("trainMission3ButtonPane"   ));
        CastTo(m_pbuttonTrainMission4,      pns->FindMember("trainMission4ButtonPane"   ));
        CastTo(m_pbuttonTrainMission5,      pns->FindMember("trainMission5ButtonPane"   ));
        CastTo(m_pbuttonTrainMission6,      pns->FindMember("trainMission6ButtonPane"   ));
        CastTo(m_pbuttonTrainMission7,      pns->FindMember("trainMission7ButtonPane"   ));
		CastTo(m_pbuttonTrainMission8,      pns->FindMember("trainMission8ButtonPane"   )); //TheBored 06-JUL-07: nanite mission
        CastTo(m_pbuttonTrain,              pns->FindMember("trainButtonPane"           ));

        m_pTrainLivePopup = new TrainLiveDialogPopup(pns, this); //imago 6/22/09

        pmodeler->UnloadNameSpace("TrainingScreen");

        //
        // buttons
        //

		// mdvalley: Pointers, Classes, and bears, oh my!
        AddEventTarget(&TrainingScreen::OnButtonBack, m_pbuttonBack->GetEventSource());
        AddEventTarget(&TrainingScreen::OnButtonTrain, m_pbuttonTrain->GetEventSource());
        AddEventTarget(&TrainingScreen::OnButtonTrainMission1, m_pbuttonTrainMission1->GetEventSource());
        AddEventTarget(&TrainingScreen::OnButtonTrainMission2, m_pbuttonTrainMission2->GetEventSource());
        AddEventTarget(&TrainingScreen::OnButtonTrainMission3, m_pbuttonTrainMission3->GetEventSource());
        AddEventTarget(&TrainingScreen::OnButtonTrainMission4, m_pbuttonTrainMission4->GetEventSource());
        AddEventTarget(&TrainingScreen::OnButtonTrainMission5, m_pbuttonTrainMission5->GetEventSource());
        AddEventTarget(&TrainingScreen::OnButtonTrainMission6, m_pbuttonTrainMission6->GetEventSource());
        AddEventTarget(&TrainingScreen::OnButtonTrainMission7, m_pbuttonTrainMission7->GetEventSource());
		AddEventTarget(&TrainingScreen::OnButtonTrainMission8, m_pbuttonTrainMission8->GetEventSource()); //TheBored 06-JUL-07: nanite mission

        //
        // buttons
        //

        AddEventTarget(&TrainingScreen::OnButtonTrain, m_pbuttonTrainMission1->GetDoubleClickEventSource());
        AddEventTarget(&TrainingScreen::OnButtonTrain, m_pbuttonTrainMission2->GetDoubleClickEventSource());
        AddEventTarget(&TrainingScreen::OnButtonTrain, m_pbuttonTrainMission3->GetDoubleClickEventSource());
        AddEventTarget(&TrainingScreen::OnButtonTrain, m_pbuttonTrainMission4->GetDoubleClickEventSource());
        AddEventTarget(&TrainingScreen::OnButtonTrain, m_pbuttonTrainMission5->GetDoubleClickEventSource());
        AddEventTarget(&TrainingScreen::OnButtonTrain, m_pbuttonTrainMission6->GetDoubleClickEventSource());
        AddEventTarget(&TrainingScreen::OnButtonTrain, m_pbuttonTrainMission7->GetDoubleClickEventSource());
		AddEventTarget(&TrainingScreen::OnButtonTrain, m_pbuttonTrainMission8->GetDoubleClickEventSource()); //TheBored 06-JUL-07: nanite mission

        // hilite the current mission
        switch (m_iMissionNext)
        {
            // here we will determine which button to hilight
            case Training::c_TM_1_Introduction:
                m_pbuttonTrainMission1->SetChecked (true);
                break;
            case Training::c_TM_2_Basic_Flight:
                m_pbuttonTrainMission2->SetChecked (true);
                break;
            case Training::c_TM_3_Basic_Weaponry:
                m_pbuttonTrainMission3->SetChecked (true);
                break;
            case Training::c_TM_4_Enemy_Engagement:
                m_pbuttonTrainMission4->SetChecked (true);
                break;
            case Training::c_TM_5_Command_View:
                m_pbuttonTrainMission5->SetChecked (true);
                break;
            case Training::c_TM_6_Practice_Arena:
                m_pbuttonTrainMission6->SetChecked (true);
                break;
			//TheBored 06-JUL-07: nanite mission
			case Training::c_TM_8_Nanite:
                m_pbuttonTrainMission8->SetChecked (true);
                break;
			//End TB
            case Training::c_TM_7_Live:
            default:
                m_pbuttonTrainMission7->SetChecked (true);
                break;
        }
        m_pbuttonTrain->SetChecked (true);
#ifdef _DEBUG
		if (bStartTraining) {
			g_pnumberMissionNumber->SetValue(6);
			OnButtonTrain();
		}
#endif
    }
Ejemplo n.º 3
0
    TRef<IObject> Apply(ObjectStack& stack)
    {
        TRef<GameStateContainer> pgsc; CastTo(pgsc, (IObject*)stack.Pop());

        return (Value*)pgsc->GetImage();
    }
Ejemplo n.º 4
0
    TRef<Geo> Execute(const Matrix& mat, GroupGeo* pgroup)
    {
        ZString strName = pgroup->GetName();

        if (!strName.IsEmpty()) {
            if (   strName.Find("frm-") == 0
                && (!pgroup->AnyChildGroups())
            ) {
                Vector vecPosition = mat.Transform(Vector(0, 0, 0));
                Vector vecForward  = mat.TransformDirection(Vector(0, 0, -1));
                Vector vecUp       = mat.TransformDirection(Vector(0, 1,  0));

                strName = strName.RightOf(4);

                if (strName.Find("SS") != -1) {
                    //
                    // a strobe light
                    //

                    ValueList* plist = pgroup->GetList();

                    if (plist->GetCount() == 1) {
                        MaterialGeo* pmatGeo; CastTo(pmatGeo, plist->GetFirst());
                        Material* pmaterial = pmatGeo->GetMaterial();

                        AddLight(strName, pmaterial->GetDiffuse(), vecPosition);
                    } else {
                        AddLight(strName, Color(1, 1, 1), vecPosition);
                    }

                    return Geo::GetEmpty();
                } else if (
                       strName.Find("thrust") != -1
                    || strName.Find("smoke") != -1
                    || strName.Find("rocket") != -1
                ) {
                    //
                    // this is an engine
                    //

                    m_pframes->GetList().PushFront(
                        FrameData(strName, vecPosition, vecForward, vecUp)
                    );

                    return Geo::GetEmpty();
                } else if (
                       (strName.Find("weapon") != -1)
                    || (strName.Find("wepatt") != -1)
                    || (strName.Find("wepemt") != -1)
                    || (strName.Find("wepmnt") != -1)
                    || (strName.Find("trail")  != -1)
                ) {
                    //
                    // This is an attachment point
                    //

                    m_pframes->GetList().PushFront(
                        FrameData(strName, vecPosition, vecForward, vecUp)
                    );
                    return Geo::GetEmpty();
                } else if (
                       (strName.Find("garage") != -1)
                ) {
                    //
                    // This is a garage we need to leave the frame in the graph
                    //

                    m_pframes->GetList().PushFront(
                        FrameData(strName, vecPosition, vecForward, vecUp)
                    );
                }
            }
        }

        return NULL;
    }
Ejemplo n.º 5
0
TRef<IObject> SelectionPaneFactory::Apply(ObjectStack& stack)
{
    TRef<IEventSource> peventSourceOnSelChange; CastTo(peventSourceOnSelChange, (IObject*)stack.Pop());
    return (Pane*) new SelectionPane(peventSourceOnSelChange);
}
Ejemplo n.º 6
0
        void Paint(ItemID pitemArg, Surface* psurface, bool bSelected, bool bFocus)
        {
            ImodelIGC* pDestination = (ImodelIGC*)pitemArg;
            IshipIGC* pship = NULL;
            IstationIGC* pstation = NULL;

            if (pDestination == NULL || trekClient.MyMission() == NULL)
                return;

            if (pDestination->GetObjectType() == OT_ship)
            {
                CastTo(pship, pDestination);
            }
            else
            {
                assert(pDestination->GetObjectType() == OT_station);
                CastTo(pstation, pDestination);
            }



            // draw the selection bar

            if (bSelected) {
                psurface->FillRect(
                    WinRect(0, 0, GetXSize(), GetYSize()),
                    Color::Red()
                );
            }

            TRef<IEngineFont> pfont;

            // show the place we currently are in bold
            if (pship && pship == trekClient.GetShip()->GetParentShip()
                || pstation && pstation == trekClient.GetShip()->GetStation())
            {
                pfont = TrekResources::SmallBoldFont();
            }
            else
            {
                pfont = TrekResources::SmallFont();
            }
         
            Color color;

            if (CanKeepCurrentShip(pDestination))
            {
                color = Color::White();
            }
            else
            {
                color = 0.75f * Color::White();
            }

            // draw the name

            psurface->DrawString(
                pfont, 
                color,
                WinPoint(0, 0),
                pship ? pship->GetName() : pstation->GetName()
            );


            // draw the ship type (if any)
            if (pship)
            {
                psurface->DrawString(
                    pfont, 
                    color,
                    WinPoint(m_viColumns[0], 0),
                    HullName(pDestination)
                );
            }
            
            // draw the cluster
            psurface->DrawString(
                pfont, 
                color,
                WinPoint(m_viColumns[1] + 2, 0),
                SectorName(pDestination)
            );

            // draw the total number of turrets (if appropriate)
            if (pship && NumTurrets(pship))
            {
                int nNumTurrets = NumTurrets(pship);

                if (nNumTurrets != 0)
                {
                    psurface->DrawString(
                        pfont,
                        color,
                        WinPoint(m_viColumns[2] + 2, 0), 
                        ZString((int)MannedTurrets(pship)) + ZString("/") + ZString(nNumTurrets)
                    );
                }
            }
        }
Ejemplo n.º 7
0
    bool OnButtonTeleport()
    {
        ImodelIGC* pDestination = (ImodelIGC*)(m_plistPaneDestinations->GetSelection());
        IstationIGC* pstation = NULL;

        if (pDestination == NULL || trekClient.MyMission() == NULL 
            || trekClient.GetShip()->GetCluster() != NULL)
            return true;


        if (pDestination->GetObjectType() == OT_ship)
        {
            // if this is a ship, try boarding it.
            IshipIGC* pship;
            CastTo(pship, pDestination);

            if (trekClient.GetShip()->GetParentShip() != NULL)
            {
                trekClient.DisembarkAndBoard(pship);
            }
            else
            {
                trekClient.BoardShip(pship);
            }
            trekClient.PlaySoundEffect(personalJumpSound);
        }
        else
        {
            // try teleporting to that station
            IstationIGC* pstation;
            CastTo(pstation, pDestination);

            if (trekClient.GetShip()->GetParentShip() != NULL)
            {
                // if they are already there, just get off of the ship
                if (pstation == trekClient.GetShip()->GetParentShip()->GetStation())
                {
                    trekClient.BoardShip(NULL);
                }
                else
                {
                    trekClient.DisembarkAndTeleport(pstation);
                }
            }
            else
            {
                if (pstation != trekClient.GetShip()->GetStation())
                {
                    trekClient.SetMessageType(BaseClient::c_mtGuaranteed);
                    BEGIN_PFM_CREATE(trekClient.m_fm, pfmDocked, C, DOCKED)
                    END_PFM_CREATE

                    pfmDocked->stationID = pstation->GetObjectID();

                    trekClient.StartLockDown(
                        "Teleporting to " + ZString(pstation->GetName()) + "....", 
                        BaseClient::lockdownTeleporting);
                }
            }
        }

        // dismiss the teleport pane.
        GetWindow()->TurnOffOverlayFlags(ofTeleportPane);

        return true;
    }
Ejemplo n.º 8
0
    HelpPaneImpl(Modeler* pmodeler, const ZString& strTopic, PagePaneIncluder* ppagePageIncluder) :
        m_pmodeler(pmodeler)
    {
        //
        // Exports
        //

		m_pmodeler->SetColorKeyHint( true );

        m_pnsData = pmodeler->CreateNameSpace("helpdata");

        //
        // Exports
        //

        m_pns = pmodeler->GetNameSpace("helppane");

        //
        // The Help pane
        //

        TRef<Pane> ppane;
        CastTo(ppane, m_pns->FindMember("helpPane"));
        InsertAtBottom(ppane);

        //
        // Buttons
        //

        CastTo(m_pbuttonBack, m_pns->FindMember("backButton"   ));
		// mdvalley: OnButtonBack now pointered and with class named.
		AddEventTarget(&HelpPaneImpl::OnButtonBack, m_pbuttonBack->GetEventSource());

        CastTo(m_pbuttonClose, m_pns->FindMember("closeButton"));

        //
        // Default attributes
        //

        TRef<FontValue>  pfont;
        TRef<ColorValue> pcolor;
        TRef<ColorValue> pcolorMain;
        TRef<ColorValue> pcolorSecondary;
        TRef<ColorValue> pcolorHighlight;

        CastTo(pfont,           m_pns->FindMember("helpFont"          ));
        CastTo(pcolor,          m_pns->FindMember("helpColor"         ));
        CastTo(pcolorMain,      m_pns->FindMember("mainLinkColor"     ));
        CastTo(pcolorSecondary, m_pns->FindMember("secondaryLinkColor"));
        CastTo(pcolorHighlight, m_pns->FindMember("highlightColor"    ));

        //
        // The Nav pane
        //

        CastTo(m_pnavPane,       m_pns->FindMember("navPane"      ));

        //
        // PagePanes
        //

        CastTo(m_ppageMain,      m_pns->FindMember("mainPage"     ));
        CastTo(m_ppageSecondary, m_pns->FindMember("secondaryPage"));

        m_ppageMain->SetAttributes(
            pfont->GetValue(),
            pcolor->GetValue(),
            pcolorMain->GetValue(),
            pcolorSecondary->GetValue(),
            pcolorHighlight->GetValue()
        );

        m_ppageSecondary->SetAttributes(
            pfont->GetValue(),
            pcolor->GetValue(),
            pcolorMain->GetValue(),
            pcolorSecondary->GetValue(),
            pcolorHighlight->GetValue()
        );

        //
        // Includer
        //

        m_ppageMain     ->SetPagePaneIncluder(ppagePageIncluder);
        m_ppageSecondary->SetPagePaneIncluder(ppagePageIncluder);

        //
        // Scroll Bars
        //

        CastTo(m_pscrollMain,      (Pane*)m_pns->FindMember("mainPageScrollBar"));
        CastTo(m_pscrollSecondary, (Pane*)m_pns->FindMember("secondaryPageScrollBar"));
        
        //
        // Sink topic event
        //

        TRef<MainSink> psinkMain = new MainSink(this);

        m_ppageMain     ->GetMainLinkEventSource()->AddSink(psinkMain);
        m_ppageSecondary->GetMainLinkEventSource()->AddSink(psinkMain);
        m_pnavPane      ->GetEventSource()        ->AddSink(psinkMain);

        TRef<SecondarySink> psinkSecondary = new SecondarySink(this);

        m_ppageMain     ->GetSecondaryLinkEventSource()->AddSink(psinkSecondary);
        m_ppageSecondary->GetSecondaryLinkEventSource()->AddSink(psinkSecondary);

        //
        // Set the initial page
        //

        SetTopic(strTopic);
    }
Ejemplo n.º 9
0
void TopPane::UpdateBits()
{
/* ORIGINAL ALLEGIANCE VERSION.
	ZEnter("TopPane::UpdateBits()");
    if (m_bNeedPaint) {
        ZTrace("m_bNeedPaint == true");
        if (CalcPaint()) {
            m_bNeedPaint = true;
            m_bPaintAll = true;
        }

        ZTrace("after CalcPaint() m_bNeedPaint ==" + ZString(m_bNeedPaint));
        ZTrace("after CalcPaint() m_bPaintAll  ==" + ZString(m_bPaintAll ));
        m_bPaintAll |= g_bPaintAll;
        InternalPaint(m_psurface);
        m_bNeedPaint = false;
    }
    ZExit("TopPane::UpdateBits()");*/


    ZEnter("TopPane::UpdateBits()");
	{
		HRESULT hr;
		bool bRenderTargetRequired;
		PrivateSurface* pprivateSurface; CastTo(pprivateSurface, m_psurface);
		bRenderTargetRequired = pprivateSurface->GetSurfaceType().Test(SurfaceTypeRenderTarget() ) == true;

		if( bRenderTargetRequired == true )
		{
			TEXHANDLE hTexture = pprivateSurface->GetTexHandle( );
			_ASSERT( hTexture != INVALID_TEX_HANDLE );
			hr = CVRAMManager::Get()->PushRenderTarget( hTexture );
		}

		ZTrace("m_bNeedPaint == true");
        CalcPaint(); 
        m_bNeedPaint = true;
        m_bPaintAll = true;

        ZTrace("after CalcPaint() m_bPaintAll  ==" + ZString(m_bPaintAll ));

		WinPoint offset( 0, 0 );

		// Call InternalPaint() with the child offset and parent size as params and create initial clipping rect.
		WinRect rectClip(	0, 
							0, 
							(int) m_psurface->GetSize().X(),
							(int) m_psurface->GetSize().Y() );

		m_bPaintAll |= g_bPaintAll;
        InternalPaint( m_psurface );
        m_bNeedPaint = false;

		if( bRenderTargetRequired == true )
		{
			CVRAMManager::Get()->PopRenderTarget( );
		}
    }
    ZExit("TopPane::UpdateBits()");

/*	{
        ZTrace("m_bNeedPaint == true");
		CalcPaint();
		m_bNeedPaint = true;
		m_bPaintAll = true;

        ZTrace("after CalcPaint() m_bNeedPaint ==" + ZString(m_bNeedPaint));
        ZTrace("after CalcPaint() m_bPaintAll  ==" + ZString(m_bPaintAll ));
        m_bPaintAll |= g_bPaintAll;

//		localOffset.SetY( localOffset.Y() - (int)m_psurface->GetSize().Y() );
//		localOffset += globalOffset;
		WinPoint offset( localOffset );

		// Remove offset now.
		offset.SetY( offset.Y() - (int)m_psurface->GetSize().Y() );

		// Call InternalPaint() with the child offset and parent size as params and create initial clipping rect.
		WinRect rectClip(	offset.X(), 
							offset.Y(), 
							offset.X() + (int) m_psurface->GetSize().X(),
							offset.Y() + (int) m_psurface->GetSize().Y() );
   
		// m_psurface is a dummy surface. Store the context.
		InternalPaint( m_psurface, offset, rectClip );
        m_bNeedPaint = false;
    }

    ZExit("TopPane::UpdateBits()");*/
}