1
0
forked from 0ad/0ad

Stops unit following when other object selected. Fixes #775

This was SVN commit r9764.
This commit is contained in:
historic_bruno 2011-07-05 21:29:11 +00:00
parent d2d631d2ed
commit 1bc2db56ea
4 changed files with 21 additions and 0 deletions

View File

@ -739,6 +739,12 @@ function handleInputAfterGui(ev)
var selectedEntity = ents[0];
var now = new Date();
// If camera following and we select different unit, stop
if (Engine.GetFollowedEntity() != selectedEntity)
{
Engine.CameraFollow(0);
}
if ((now.getTime() - doubleClickTimer < doubleClickTime) && (selectedEntity == prevClickedEntity))
{

View File

@ -958,6 +958,11 @@ void CGameView::CameraFollow(entity_id_t entity, bool firstPerson)
m->FollowFirstPerson = firstPerson;
}
entity_id_t CGameView::GetFollowedEntity()
{
return m->FollowEntity;
}
InReaction game_view_handler(const SDL_Event_* ev)
{
// put any events that must be processed even if inactive here

View File

@ -86,6 +86,7 @@ public:
void ResetCameraTarget(const CVector3D& target);
void ResetCameraAngleZoom();
void CameraFollow(entity_id_t entity, bool firstPerson);
entity_id_t GetFollowedEntity();
CCamera *GetCamera();
CCinemaManager* GetCinema();

View File

@ -346,6 +346,14 @@ void CameraFollowFPS(void* UNUSED(cbdata), entity_id_t entityid)
g_Game->GetView()->CameraFollow(entityid, true);
}
entity_id_t GetFollowedEntity(void* UNUSED(cbdata))
{
if (g_Game && g_Game->GetView())
return g_Game->GetView()->GetFollowedEntity();
return INVALID_ENTITY;
}
bool HotkeyIsPressed_(void* UNUSED(cbdata), std::string hotkeyName)
{
return HotkeyIsPressed(hotkeyName);
@ -491,6 +499,7 @@ void GuiScriptingInit(ScriptInterface& scriptInterface)
scriptInterface.RegisterFunction<CScriptVal, &GetMapSettings>("GetMapSettings");
scriptInterface.RegisterFunction<void, entity_id_t, &CameraFollow>("CameraFollow");
scriptInterface.RegisterFunction<void, entity_id_t, &CameraFollowFPS>("CameraFollowFPS");
scriptInterface.RegisterFunction<entity_id_t, &GetFollowedEntity>("GetFollowedEntity");
scriptInterface.RegisterFunction<bool, std::string, &HotkeyIsPressed_>("HotkeyIsPressed");
scriptInterface.RegisterFunction<void, std::wstring, &DisplayErrorDialog>("DisplayErrorDialog");
scriptInterface.RegisterFunction<CScriptVal, &GetProfilerState>("GetProfilerState");