Ticket #1022: Atlas-ActorViewer-PlayerColour(1022)-v2.patch

File Atlas-ActorViewer-PlayerColour(1022)-v2.patch, 4.6 KB (added by Mitchell K, 12 years ago)

entity ownership code moved to ​ActorViewer::SetActor?() and fixes assuming default is gaia

  • source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Object/Object.cpp

     
    9797
    9898struct ObjectSidebarImpl
    9999{
    100     ObjectSidebarImpl() :
     100    ObjectSidebarImpl(ScenarioEditor& scenarioEditor) :
    101101        m_ObjectListBox(NULL), m_ActorViewerActive(false),
    102         m_ActorViewerEntity(_T("actor|structures/fndn_1x1.xml")), m_ActorViewerAnimation(_T("idle")), m_ActorViewerSpeed(0.f)
     102        m_ActorViewerEntity(_T("actor|structures/fndn_1x1.xml")),
     103        m_ActorViewerAnimation(_T("idle")), m_ActorViewerSpeed(0.f),
     104        m_ObjectSettings(scenarioEditor.GetObjectSettings())
    103105    {
    104106    }
    105107
     
    111113    wxString m_ActorViewerEntity;
    112114    wxString m_ActorViewerAnimation;
    113115    float m_ActorViewerSpeed;
     116    ObjectSettings& m_ObjectSettings;
    114117
    115118    void ActorViewerPostToGame()
    116119    {
    117         POST_MESSAGE(SetActorViewer, ((std::wstring)m_ActorViewerEntity.wc_str(), (std::wstring)m_ActorViewerAnimation.wc_str(), m_ActorViewerSpeed, false));
     120        POST_MESSAGE(SetActorViewer, ((std::wstring)m_ActorViewerEntity.wc_str(), (std::wstring)m_ActorViewerAnimation.wc_str(), m_ObjectSettings.GetPlayerID(), m_ActorViewerSpeed, false));
    118121    }
    119122};
    120123
     
    124127    wxWindow* bottomBarContainer
    125128)
    126129    : Sidebar(scenarioEditor, sidebarContainer, bottomBarContainer),
    127       p(new ObjectSidebarImpl())
     130      p(new ObjectSidebarImpl(scenarioEditor))
    128131{
    129132    wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
    130133    sizer->Add(new wxStaticText(this, wxID_ANY, _("Filter")), wxSizerFlags().Align(wxALIGN_CENTER));
  • source/tools/atlas/GameInterface/Messages.h

     
    340340MESSAGE(SetActorViewer,
    341341        ((std::wstring, id))
    342342        ((std::wstring, animation))
     343        ((int, playerId))
    343344        ((float, speed))
    344345        ((bool, flushcache)) // true => unload all actor files before starting the preview (because we don't have proper hotloading yet)
    345346        );
  • source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp

     
    153153//      vfs_reload_changed_files();
    154154    }
    155155    AtlasView::GetView_Actor()->SetSpeedMultiplier(msg->speed);
    156     AtlasView::GetView_Actor()->GetActorViewer().SetActor(*msg->id, *msg->animation);
     156    AtlasView::GetView_Actor()->GetActorViewer().SetActor(*msg->id, *msg->animation, msg->playerId);
    157157}
    158158
    159159//////////////////////////////////////////////////////////////////////////
  • source/tools/atlas/GameInterface/ActorViewer.cpp

     
    4848#include "renderer/WaterManager.h"
    4949#include "scriptinterface/ScriptInterface.h"
    5050#include "simulation2/Simulation2.h"
     51#include "simulation2/components/ICmpOwnership.h"
    5152#include "simulation2/components/ICmpPosition.h"
    5253#include "simulation2/components/ICmpRangeManager.h"
    5354#include "simulation2/components/ICmpTerrain.h"
     
    314315    m.ObjectManager.UnloadObjects();
    315316}
    316317
    317 void ActorViewer::SetActor(const CStrW& name, const CStrW& animation)
     318void ActorViewer::SetActor(const CStrW& name, const CStrW& animation, int playerId)
    318319{
    319320    bool needsAnimReload = false;
    320321
     
    428429        m.UpdatePropList();
    429430    }
    430431
     432    // Unit ownership (sets to the correct player colour)
     433    CmpPtr<ICmpOwnership> cmpOwnership(m.Simulation2, m.Entity);
     434    if (cmpOwnership)
     435        cmpOwnership->SetOwner(playerId);
     436
    431437    m.CurrentUnitID = id;
    432438    m.CurrentUnitAnim = animation;
    433439}
  • source/tools/atlas/GameInterface/ActorViewer.h

     
    3434
    3535    CSimulation2* GetSimulation2();
    3636    entity_id_t GetEntity();
    37     void SetActor(const CStrW& id, const CStrW& animation);
     37    void SetActor(const CStrW& id, const CStrW& animation, int playerId=0);
    3838    void UnloadObjects();
    3939    void SetBackgroundColour(const SColor4ub& colour);
    4040    void SetWalkEnabled(bool enabled);