1
1
forked from 0ad/0ad

Fixes player colors in actor viewer, based on patch by mk12. Fixes #1022.

This was SVN commit r11527.
This commit is contained in:
historic_bruno 2012-04-17 01:26:24 +00:00
parent af207e1c0a
commit 772b38e6be
5 changed files with 20 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2011 Wildfire Games.
/* Copyright (C) 2012 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -97,9 +97,11 @@ private:
struct ObjectSidebarImpl
{
ObjectSidebarImpl() :
ObjectSidebarImpl(ScenarioEditor& scenarioEditor) :
m_ObjectListBox(NULL), m_ActorViewerActive(false),
m_ActorViewerEntity(_T("actor|structures/fndn_1x1.xml")), m_ActorViewerAnimation(_T("idle")), m_ActorViewerSpeed(0.f)
m_ActorViewerEntity(_T("actor|structures/fndn_1x1.xml")),
m_ActorViewerAnimation(_T("idle")), m_ActorViewerSpeed(0.f),
m_ObjectSettings(scenarioEditor.GetObjectSettings())
{
}
@ -111,10 +113,11 @@ struct ObjectSidebarImpl
wxString m_ActorViewerEntity;
wxString m_ActorViewerAnimation;
float m_ActorViewerSpeed;
Observable<ObjectSettings>& m_ObjectSettings;
void ActorViewerPostToGame()
{
POST_MESSAGE(SetActorViewer, ((std::wstring)m_ActorViewerEntity.wc_str(), (std::wstring)m_ActorViewerAnimation.wc_str(), m_ActorViewerSpeed, false));
POST_MESSAGE(SetActorViewer, ((std::wstring)m_ActorViewerEntity.wc_str(), (std::wstring)m_ActorViewerAnimation.wc_str(), m_ObjectSettings.GetPlayerID(), m_ActorViewerSpeed, false));
}
};
@ -124,7 +127,7 @@ ObjectSidebar::ObjectSidebar(
wxWindow* bottomBarContainer
)
: Sidebar(scenarioEditor, sidebarContainer, bottomBarContainer),
p(new ObjectSidebarImpl())
p(new ObjectSidebarImpl(scenarioEditor))
{
wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(new wxStaticText(this, wxID_ANY, _("Filter")), wxSizerFlags().Align(wxALIGN_CENTER));

View File

@ -48,6 +48,7 @@
#include "renderer/WaterManager.h"
#include "scriptinterface/ScriptInterface.h"
#include "simulation2/Simulation2.h"
#include "simulation2/components/ICmpOwnership.h"
#include "simulation2/components/ICmpPosition.h"
#include "simulation2/components/ICmpRangeManager.h"
#include "simulation2/components/ICmpTerrain.h"
@ -314,7 +315,7 @@ void ActorViewer::UnloadObjects()
m.ObjectManager.UnloadObjects();
}
void ActorViewer::SetActor(const CStrW& name, const CStrW& animation)
void ActorViewer::SetActor(const CStrW& name, const CStrW& animation, player_id_t playerID)
{
bool needsAnimReload = false;
@ -350,6 +351,10 @@ void ActorViewer::SetActor(const CStrW& name, const CStrW& animation)
cmpPosition->SetYRotation(entity_angle_t::Pi());
}
CmpPtr<ICmpOwnership> cmpOwnership(m.Simulation2, m.Entity);
if (cmpOwnership)
cmpOwnership->SetOwner(playerID);
needsAnimReload = true;
}

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2009 Wildfire Games.
/* Copyright (C) 2012 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -19,6 +19,7 @@
#define INCLUDED_ACTORVIEWER
#include "simulation2/system/Entity.h"
#include "simulation2/helpers/Player.h"
struct ActorViewerImpl;
struct SColor4ub;
@ -34,7 +35,7 @@ public:
CSimulation2* GetSimulation2();
entity_id_t GetEntity();
void SetActor(const CStrW& id, const CStrW& animation);
void SetActor(const CStrW& id, const CStrW& animation, player_id_t playerID);
void UnloadObjects();
void SetBackgroundColour(const SColor4ub& colour);
void SetWalkEnabled(bool enabled);

View File

@ -148,12 +148,12 @@ MESSAGEHANDLER(SetActorViewer)
// alright.)
// Should replace this with proper actor hot-loading system, or something.
AtlasView::GetView_Actor()->GetActorViewer().SetActor(L"", L"");
AtlasView::GetView_Actor()->GetActorViewer().SetActor(L"", L"", -1);
AtlasView::GetView_Actor()->GetActorViewer().UnloadObjects();
// vfs_reload_changed_files();
}
AtlasView::GetView_Actor()->SetSpeedMultiplier(msg->speed);
AtlasView::GetView_Actor()->GetActorViewer().SetActor(*msg->id, *msg->animation);
AtlasView::GetView_Actor()->GetActorViewer().SetActor(*msg->id, *msg->animation, msg->playerID);
}
//////////////////////////////////////////////////////////////////////////

View File

@ -340,6 +340,7 @@ COMMAND(CreateObject, NOMERGE,
MESSAGE(SetActorViewer,
((std::wstring, id))
((std::wstring, animation))
((int, playerID))
((float, speed))
((bool, flushcache)) // true => unload all actor files before starting the preview (because we don't have proper hotloading yet)
);