Пример #1
0
///////////////////////////////////////////////////////////////////////////////
//    UPDATE
//    The purpose of update is basically to check if any suspended scripts need
//    to be turned back on again!
//
//    Returns the next script in the list.  This assists in linked list traversal
//    where this script may delete it's next sibling.
///////////////////////////////////////////////////////////////////////////////
void CLuaScript::Update(float elapsedSec)
{
    m_fTime += elapsedSec;

	SINGLETONINSTANCE(CLuaManager)->SetScriptObjectName(GetName());
	SINGLETONINSTANCE(CLuaManager)->SetScriptObjectParentName(GetParentName());
    
    switch(m_State)
	{
	case LSS_WAITTIME:
		if (m_fTime >= m_fWaitTimestamp)
		{
			ResumeScript(0.0f);
		}
        break;
	case LSS_WAITFRAME:
		m_iWaitFrame--;
		if (m_iWaitFrame <= 0)
		{
			ResumeScript(0.0f);
		}
        break;
	case LSS_NOTLOADED:
		break;
//  case LSS_DONE:
    default :
		break;
	}

	SINGLETONINSTANCE(CLuaManager)->SetScriptObjectName(NULL);
	SINGLETONINSTANCE(CLuaManager)->SetScriptObjectParentName(NULL);
}
Пример #2
0
CToolBox::CToolBox()
{
	m_CurMsgID = MSG_ID_FIRST;
	m_CurHashStringUnique = HASHSTRING_ID_FIRST;

	m_Timer = SINGLETONINSTANCE( CTimer );
}
Пример #3
0
//---------------------------------------------------------------------
// Function:	CGUIEditor
// Description:	Standard Constructor
// Parameters:	pi = programs information structure
// Returns:		.
//---------------------------------------------------------------------
CGUIEditor::CGUIEditor()
{
	SINGLETONINSTANCE(CGUIEditorComponent)->SetParent(this);
	m_ToolBox = EngineGetToolBox();	
	m_bDocOpen = false;
	m_bCreated = false;
}
Пример #4
0
//---------------------------------------------------------------------
// Function:	GetPriority
// Description:	DLL's priority
// Parameters:	.
// Returns:		DWORD = priority of DLL loaded
//---------------------------------------------------------------------
CTimeOfDayEditor::CTimeOfDayEditor( )
{
	SINGLETONINSTANCE(CTimeOfDayComponent)->SetParent(this);
	m_ToolBox = EngineGetToolBox();
	m_bWeatherDlg = false;

}
void CStateMachineEditor::StateMachineEditorCreationCallback(void *userData)
{
	CStateMachineEditor *instance = SINGLETONINSTANCE(CStateMachineEditor);
	if( instance )
	{
		instance->CreateStateMachine();
	}
}
Пример #6
0
//---------------------------------------------------------------------
// Function:	CModelViewEditor
// Description:	Create a new ModelView  for editing 
// Parameters:	userData = void pointer, we don't use at the moment
// Returns:		void
//---------------------------------------------------------------------
void CModelViewEditor::ModelViewEditorCreationCallback(void *userData)
{
	CModelViewEditor * pModelViewEditorInstance = SINGLETONINSTANCE(CModelViewEditor);
	if( pModelViewEditorInstance )
	{
		pModelViewEditorInstance->EditDocument(NULL);
	}
}
Пример #7
0
CModelViewToolBar *CModelViewRender::GetToolBar()
{
    CModelViewEditor *pEditor = SINGLETONINSTANCE(CModelViewEditor);
    ASSERT(pEditor != NULL);
    CModelViewToolBar *pToolbar = pEditor->GetToolBar();
    ASSERT(pToolbar != NULL);
    return pToolbar;
}
Пример #8
0
//---------------------------------------------------------------------
// Function:	ParticleCreationCallback
// Description:	Create a new Particle chart for editing 
// Parameters:	userData = void pointer, we don't use at the moment
// Returns:		void
//---------------------------------------------------------------------
void CParticleEditor::ParticleEditorCreationCallback(void *userData)
{
	CParticleEditor * pParticleEditorInstance = SINGLETONINSTANCE(CParticleEditor);
	if( pParticleEditorInstance )
	{
		pParticleEditorInstance->EditDocument(NULL);
	}
}
Пример #9
0
CParticleEditor::CParticleEditor( )
	: m_ParticlePropertyDock(_T("ParticleDocBarConfig.xgf"), _T("\\ParticleEditorProperties\\"))
	, m_ParticleTreeDock()
{
	SINGLETONINSTANCE(CParticleEditorComponent)->SetParent(this);
	m_ToolBox = EngineGetToolBox();
	m_AppInst = NULL;
}
Пример #10
0
CModelViewDlg* CModelViewRender::GetDockDlg()
{
    CModelViewEditor *pEditor = SINGLETONINSTANCE(CModelViewEditor);
    ASSERT(pEditor != NULL);
    CModelViewDlg *pDlg = pEditor->GetDockDlg();
    ASSERT(pDlg != NULL);
    return pDlg;
}
Пример #11
0
void CLuaScript::Init()
{
	int status;
	SCRIPTPARAMS sp;
	CHashString name(m_ScriptName.c_str());

	sp.fileName = &name;

	if (m_ScriptBody == NULL)
	{
		// get script based on the file name
		static DWORD msgHash_GetScript = CHashString(_T("GetScript")).GetUniqueID();
		if (m_EngineToolBox->SendMessage(msgHash_GetScript, sizeof(SCRIPTPARAMS), &sp) == MSG_HANDLED)
		{
			// extract script body
			m_ScriptBody = sp.scriptData;

			assert(m_pThreadState);
			assert(m_ScriptBody);

			status = luaL_loadbuffer(m_pThreadState, m_ScriptBody, strlen(m_ScriptBody), "Console");

			if (status)
			{
				// log error!
				FormatError();
				return;
			}
		}
	}		
	if (m_bAutoStart && m_ScriptBody != NULL)
	{
		SINGLETONINSTANCE(CLuaManager)->SetScriptObjectName(GetName());
		SINGLETONINSTANCE(CLuaManager)->SetScriptObjectParentName(GetParentName());
		status = lua_pcall(m_pThreadState, lua_gettop(m_pThreadState)-1, 0, 0);
		SINGLETONINSTANCE(CLuaManager)->SetScriptObjectName(NULL);
		SINGLETONINSTANCE(CLuaManager)->SetScriptObjectParentName(NULL);
		
		if (status)
		{
			// log error!
			FormatError();
			return;
		}
	}
}
Пример #12
0
void CGUIEditor::GUIEditorCreationCallback(void *userData)
{
	CGUIEditor * pGUIEditorInstance = SINGLETONINSTANCE(CGUIEditor);
	if( pGUIEditorInstance )
	{
		pGUIEditorInstance->EditDocument();
	}	
}
Пример #13
0
	void SetTargetPosition(Point *target)
	{
		if(m_Path != NULL)
		{
			delete m_Path;
		}
		int x = SINGLETONINSTANCE(PathPlanner)->ConvertToPlanningMapCoordinate(target->X);
		int y = SINGLETONINSTANCE(PathPlanner)->ConvertToPlanningMapCoordinate(target->Y);

		if(!SINGLETONINSTANCE(PathPlanner)->evaluateCoordinate(&x, &y))
		{
			m_Path = new std::vector<Point>();
			target->X = GetPosition()->X;
			target->Y = GetPosition()->Y;
			m_Path->push_back(Point(*target));
		}
		else
		{
			target->X = SINGLETONINSTANCE(PathPlanner)->ConvertToPhysicsMapCoordinates((float)x);
			target->Y = SINGLETONINSTANCE(PathPlanner)->ConvertToPhysicsMapCoordinates((float)y);
			m_Path = SINGLETONINSTANCE(PathPlanner)->aStar(target->X, target->Y, GetPosition()->X, GetPosition()->Y);
		}
		

		delete m_TargetPosition;
		m_TargetPosition = target;

		calcDirection();
	}
Пример #14
0
//FOR DEBUGGING PURPOSES, ONLY
void PhysicsSystem::SetDynamicPathMap()
{
    std::vector<std::vector<int>> *map = new std::vector<std::vector<int>>(MAP_SIZE, std::vector<int>(MAP_SIZE, 0));

    std::vector<MovingObjectModel*>::iterator dynamicObjectIterator;
    for(dynamicObjectIterator = m_MovingObjects->begin();
            dynamicObjectIterator != m_MovingObjects->end();
            dynamicObjectIterator++)
    {
        float posx = (*dynamicObjectIterator)->GetPosition()->X;
        float posy = (*dynamicObjectIterator)->GetPosition()->Y;

        float targetPosX = (*dynamicObjectIterator)->GetTargetPosition()->X;
        float targetPosY = (*dynamicObjectIterator)->GetTargetPosition()->Y;

        int x = SINGLETONINSTANCE(PathPlanner)->ConvertToPlanningMapCoordinate(posx);
        int y = SINGLETONINSTANCE(PathPlanner)->ConvertToPlanningMapCoordinate(posy);

        int targetX = SINGLETONINSTANCE(PathPlanner)->ConvertToPlanningMapCoordinate(targetPosX);
        int targetY = SINGLETONINSTANCE(PathPlanner)->ConvertToPlanningMapCoordinate(targetPosY);

        if((*dynamicObjectIterator)->GetShape() == CIRCULARSHAPE)
        {
            //NOTE: Right now a player is always 1 node large in the Path Finding algorithm.
            map->at(targetX)[targetY] = TARGET;
            if(0 < x && x < MAP_SIZE-1 && 0 < y && y < MAP_SIZE-1)
            {
                map->at(x)[y] = PLAYER;
            }
        }
        else if((*dynamicObjectIterator)->GetShape() == RECTANGULARSHAPE)
        {
            //NOT IMPLEMENTED
        }
    }

    SINGLETONINSTANCE(PathPlanner)->UpdateDynamicMap(map);

    delete map;
}
Пример #15
0
void Engine::ShutDown()
{
	m_Running = false;
	SINGLETONINSTANCE(Profiler)->Begin("ShutDown");

	delete m_SingleFrameAllocator;

	m_FPSCalculator->ShutDown();

	m_Physics->ShutDown();

	m_Graphics->ShutDown();

	m_EventManager->ShutDown();

	m_SettingsManager->ShutDown();

	m_Window->ShutDown();

	SINGLETONINSTANCE(Profiler)->End("ShutDown");
	SINGLETONINSTANCE(Profiler)->ShutDown();
}
Пример #16
0
void CGraphView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
	CView::OnActivateView(bActivate, pActivateView, pDeactiveView);

	if (m_bActive != (bActivate != FALSE))
	{
		m_bActive = (bActivate != FALSE);

		CGuiMDIFrame *mainWnd = DYNAMIC_DOWNCAST(CGuiMDIFrame, AfxGetMainWnd());

		if (bActivate)
		{
			mainWnd->LoadDocumentBars(_T("ParticleEditor"));
			SINGLETONINSTANCE(CParticleEditor)->RefreshList(GetDocument());
			GetDocument()->SetActiveScene();
		}
		else
		{
			mainWnd->SaveDocumentBars(_T("ParticleEditor"));
			SINGLETONINSTANCE(CParticleEditor)->RefreshList(NULL);
		}
	}
}
Пример #17
0
IToolBox *EngineGetToolBox()
{
	// dummy to force linking of all other objects?
	#ifdef _DEBUG
	if( !g_bFirstTimeInit )
	{
		g_bFirstTimeInit = true;
		//_CrtDumpMemoryLeaks();
		//_CrtSetBreakAlloc(5059);
		
	}
	#endif
	
	return SINGLETONINSTANCE(CToolBox);
}
Пример #18
0
void Engine::StartUp()
{
	SINGLETONINSTANCE(Profiler)->StartUp();
	SINGLETONINSTANCE(Profiler)->Begin("StartUp");

	lastTime = Time::GetCurrentMS();
	m_Window = new Window();
	m_Window->StartUp();

	m_SettingsManager = new SettingsManager();
	m_SettingsManager->StartUp();

	m_EventManager = new EventManager();
	m_EventManager->StartUp("Global event manager", true);

	//Register useful event types.
	m_EventManager->AddRegisteredEventType( EventType ("keydownEvent") );	
	m_EventManager->AddRegisteredEventType( EventType ("mouseClickPositionEvent") );
	m_EventManager->AddRegisteredEventType( EventType ("mouseClickHUDEvent") );

	//IMPORTANT: Call this before m_Graphics->StartUp()
	m_Physics = SINGLETONINSTANCE(PhysicsSystem);
	m_Physics->StartUp();

	m_Graphics = new GraphicsSystem();
	m_Graphics->StartUp();

	m_FPSCalculator = new FPSCalculator();
	m_FPSCalculator->StartUp();

	m_SingleFrameAllocator = new StackAllocator(MB(100));

	m_Running = false;

	SINGLETONINSTANCE(Profiler)->End("StartUp");
}
Пример #19
0
CObjectToolPal::CObjectToolPal()
{
	m_fSnapToGrid = 20.0f;

	m_iLockPosIndex = 0;
	m_iLockRotIndex = 0;
	m_fLockValue = 0.0f;
	m_bButtonRotateClicked = false;
	m_bButtonMoveClicked = false;
	m_iLockIndex = m_iLockPosIndex;
	m_iHugIndex = 0;
	m_ObjectManipulateState = MANIPULATE_SELECT;

	m_pEditor = SINGLETONINSTANCE(CObjectEditor);
}
Пример #20
0
void CModelViewRender::PlaySequence(const ANIMATIONSEQUENCE &sequence)
{
    // make a copy of the requested sequence
    m_PlayingAnimationSequence.clear();
    std::copy(sequence.begin(), sequence.end(), std::back_inserter(m_PlayingAnimationSequence));
    m_itCurrentAnimationID = m_PlayingAnimationSequence.begin();

    // create all the callbacks at once for the sequence
    set<int> uniqueCallbackSet;
    for (ANIMATIONSEQUENCE::iterator itrAnim = m_PlayingAnimationSequence.begin(); itrAnim != m_PlayingAnimationSequence.end(); itrAnim++)
    {
        // skip duplicate animations (only need to make one callback per animation)
        if (uniqueCallbackSet.find( *itrAnim ) != uniqueCallbackSet.end())
            continue;

        IArchive* pArchive = CreateMemoryArchive();
        pArchive->Write(m_hszEntityName.GetString(), _T("EntityName"));
        pArchive->Write(*itrAnim);
        pArchive->SetIsWriting(false);
        m_AnimationCallbackArchives.push_back( pArchive );

        static CHashString hszCal3DRenderObject = _T("Cal3DRenderObject");
        static CHashString hszCModelViewComponent(_T("CModelViewComponent"));
        static CHashString hszPlayAnimationSequenceStep(_T("PlayAnimationSequenceStep"));

        REGISTERCAL3DANIMATIONCALLBACK ac;
        ac.AnimationId = *itrAnim;
        ac.bTriggerOnComplete = true;
        ac.bTriggerOnStop = false;
        ac.StateObjectName = &hszCModelViewComponent;
        ac.EventName = &hszPlayAnimationSequenceStep;
        ac.EventParamsArchive = pArchive;

        static DWORD msgHash_RegisterAnimationCallback = CHashString(_T("RegisterAnimationCallback")).GetUniqueID();
        DWORD res = m_ToolBox->SendMessage(msgHash_RegisterAnimationCallback, sizeof(ac), &ac, &m_hszEntityName, &hszCal3DRenderObject);
        if (MSG_HANDLED != res)
        {
            m_ToolBox->Log(LOGERROR, _T("%s(%i): Cannot register animation callback. \n"), __FILE__, __LINE__);
        }
        uniqueCallbackSet.insert( *itrAnim );
    }

    if (HasAnimation())
    {
        SINGLETONINSTANCE(CModelViewComponent)->PlayAnimation(this);
    }
}
Пример #21
0
void CModelViewRender::PlayNextAnimation()
{
    static CHashString hszCal3DRenderObject(_T("Cal3DRenderObject"));
    static DWORD msgStopAllAnimationActions = CHashString(_T("StopAllAnimationActions")).GetUniqueID();
    m_ToolBox->SendMessage( msgStopAllAnimationActions, 0, NULL, &m_hszEntityName, &hszCal3DRenderObject );

    if (m_itCurrentAnimationID != m_PlayingAnimationSequence.end())
        m_itCurrentAnimationID++;

    if (m_bLoop && m_itCurrentAnimationID == m_PlayingAnimationSequence.end())
    {
        m_itCurrentAnimationID = m_PlayingAnimationSequence.begin();
    }

    if (HasAnimation())
    {
        SINGLETONINSTANCE(CModelViewComponent)->PlayAnimation(this);
    }
}
Пример #22
0
CGUIInstance::CGUIInstance(IHashString *parentName, IHashString *name) :
	CGUIElement(parentName, name)
{
	m_ItemRef = NULL;

	m_fPosX = m_fPosY = 0.f;
	m_fSizeX = m_fSizeY = 0.f;

	m_szItemCopyName = _T("");
	m_szItemCopyType = _T("");

	m_fWidthRatio = 1.f;
	m_fHeightRatio = 1.f;
	m_fZoomFactor = 1.f;
	m_iPageOffsetX = 0;
	m_iPageOffsetY = 0;

	m_iColor = -1;
	m_bColorChanged = false;
	m_fAngle = 0.f;

	m_VertexBuffer = NULL;
	m_VBOffset = 0;

	m_fSaveVersion = 1.0f;

	m_State = 0;

	GETRENDERERINTERFACEPARAMS renderInterface;

	static DWORD msgHash_GetRendererInterface = CHashString(_T("GetRendererInterface")).GetUniqueID();
	EngineGetToolBox()->SendMessage(msgHash_GetRendererInterface, 
					sizeof(GETRENDERERINTERFACEPARAMS), 
					&renderInterface, 
					NULL, 
					NULL);

	m_Renderer = renderInterface.m_RendererInterface;

	m_Manager = SINGLETONINSTANCE(CGUIManager);
}
Пример #23
0
// create function for this world loader
IComponent *CSoundLoader::Create(int nArgs, va_list argptr)
{
	return SINGLETONINSTANCE( CSoundLoader );
}
Пример #24
0
// create function for this Particle loader
IComponent *CCal3dMeshLoader::Create(int nArgs, va_list argptr)
{
	return SINGLETONINSTANCE( CCal3dMeshLoader );
}
Пример #25
0
// create function for this Particle loader
IComponent *CParticleLoader::Create(int nArgs, va_list argptr)
{
	return SINGLETONINSTANCE( CParticleLoader );
}
IComponent *COctreeSceneManager::Create( int nArgs, va_list argptr )
{
  	return SINGLETONINSTANCE( COctreeSceneManager );
}
Пример #27
0
//---------------------------------------------------------------------
// Function:	Create
// Description:	Returns the only instance of the class (singleton)
// Parameters:	nArgs - Number of arguments - not in use 
//				argptr - The argument list - not in use
// Returns:		the instance
//---------------------------------------------------------------------
IComponent *CProjectSettings::Create( int nArgs, va_list argptr )
{
	return SINGLETONINSTANCE(CProjectSettings);
}
Пример #28
0
// We only have a singleton, so return that
IComponent *CInputManager::Create(int nArgs, va_list argptr)
{
	return SINGLETONINSTANCE(CInputManager);
}
Пример #29
0
void Engine::Run()
{
	m_Running = true;

	SDL_Event event;
	const EventType keydown("keydownEvent");

	while (m_Running)
	{
		SINGLETONINSTANCE(Profiler)->Begin("ClearSingleFrameAllocator");
		m_SingleFrameAllocator->Clear();
		SINGLETONINSTANCE(Profiler)->End("ClearSingleFrameAllocator");

		SINGLETONINSTANCE(Profiler)->Begin("EventHandling");
		while (SDL_PollEvent(&event))
		{
			switch(event.type)
			{
			case SDL_QUIT:
				m_Running = false;
				break;

			case SDL_VIDEORESIZE:
				GetWindow()->Resize(event.resize.w, event.resize.h);

				break;
			
			case SDL_KEYDOWN:
				threadSafeQueEvent( IEventDataPointer( new EventData<SDL_KeyboardEvent>(event.key, keydown)) );
				handleKeyPress(&event.key, event.type);
				break;

			case SDL_MOUSEBUTTONDOWN:
			case SDL_MOUSEBUTTONUP:
				handleMouseButtonPress(&event.button, event.type);
				break;
				
			case SDL_MOUSEMOTION:				
				handleMouseMove(&event.motion, event.type);
				break;
			
			default:
				break;
			}
		}
		
		//Process eventQueue
		//10ms event handling
		safeProcessEventQueue(10);
		SINGLETONINSTANCE(Profiler)->End("EventHandling");

		int currentTime = Time::GetCurrentMS();
		int deltaT = (currentTime - lastTime);

		SINGLETONINSTANCE(Profiler)->Begin("StepPhysics");
		//Step the physics system
		m_Physics->Step(deltaT);
		SINGLETONINSTANCE(Profiler)->End("StepPhysics");

		SINGLETONINSTANCE(Profiler)->Begin("CameraUpdate");
		m_Graphics->m_SceneGraph->m_CameraObject->Update(deltaT);
		SINGLETONINSTANCE(Profiler)->End("CameraUpdate");

		// Display the graphics
		SINGLETONINSTANCE(Profiler)->Begin("Rendering");
		m_Graphics->Render();
		SINGLETONINSTANCE(Profiler)->End("Rendering");

		// Calculate and show FPS in title bar
		m_FPSCalculator->SetCurrentTime(currentTime);

		//char *title = new char[sizeof(char) * 50];
		char *title = (char *)m_SingleFrameAllocator->Allocate(sizeof(char) * 50);
		sprintf_s(title, (sizeof(char) * 50), "FPS: %d, Memory: %d bytes", m_FPSCalculator->GetFPS(), m_SingleFrameAllocator->GetMemoryUsage());
		m_Window->SetWindowTitle(title);

		lastTime = currentTime;

	} // while(m_Running)
}
Пример #30
0
IComponent* CDatabaseManager::Create(int nArgs, va_list argptr)
{
	// Return the singleton instance of this class
	return SINGLETONINSTANCE( CDatabaseManager );
}