Ticket #1163: 1163.7.diff

File 1163.7.diff, 5.4 KB (added by trompetin17, 9 years ago)
  • source/tools/atlas/AtlasUI/ScenarioEditor/Tools/TransformObject.cpp

     
    1 /* Copyright (C) 2014 Wildfire Games.
     1/* Copyright (C) 2015 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    366359        {
    367360            if (evt.LeftUp())
    368361            {
     362                POST_MESSAGE(ResetSelectionColor, ());
    369363                SET_STATE(Waiting);
    370364                return true;
    371365            }
  • source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp

     
    1 /* Copyright (C) 2014 Wildfire Games.
     1/* Copyright (C) 2015 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    3636#include "renderer/Renderer.h"
    3737#include "simulation2/Simulation2.h"
    3838#include "simulation2/components/ICmpSoundManager.h"
     39#include "ps/Filesystem.h"
    3940
    4041extern void (*Atlas_GLSwapBuffers)(void* context);
    4142
     
    225226    in_dispatch_event(&ev);
    226227}
    227228
     229MESSAGEHANDLER(VFSUpdateFile)
     230{
     231    ReloadChangedFilesFromAtlas(*msg->filePath);
    228232}
     233
     234}
  • source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp

     
    1 /* Copyright (C) 2014 Wildfire Games.
     1/* Copyright (C) 2015 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    4141#include "renderer/Renderer.h"
    4242#include "renderer/WaterManager.h"
    4343#include "simulation2/Simulation2.h"
     44#include "simulation2/components/ICmpObstruction.h"
    4445#include "simulation2/components/ICmpOwnership.h"
    4546#include "simulation2/components/ICmpPosition.h"
    4647#include "simulation2/components/ICmpPlayer.h"
     
    6162    }
    6263}
    6364
     65// Helpers for object constraints
     66bool CanPlaceObjectEntityHelper(entity_id_t ent)
     67{
     68    CmpPtr<ICmpObstruction> cmpObstruction(*g_Game->GetSimulation2(), ent);
     69    if (cmpObstruction)
     70    {
     71        ICmpObstruction::EFoundationCheck result = cmpObstruction->CheckFoundation("default");
     72        if (result != ICmpObstruction::FOUNDATION_CHECK_SUCCESS)
     73            return false;
     74    }
     75    return true;
     76}
     77
     78void CheckObstructionAndUpdateVisual(entity_id_t id)
     79{
     80    CmpPtr<ICmpVisual> cmpVisual(*g_Game->GetSimulation2(), id);
     81    if (cmpVisual)
     82    {
     83        if (!CanPlaceObjectEntityHelper(id))
     84            cmpVisual->SetShadingColour(fixed::FromDouble(1.4), fixed::FromDouble(0.4), fixed::FromDouble(0.4), fixed::FromDouble(1));
     85        else
     86            cmpVisual->SetShadingColour(fixed::FromDouble(1), fixed::FromDouble(1), fixed::FromDouble(1), fixed::FromDouble(1));
     87    }
     88}
     89
    6490QUERYHANDLER(GetObjectsList)
    6591{
    6692    std::vector<sObjectsListItem> objects;
     
    473499            posFinal = posFixed + dir;
    474500        }
    475501        cmpPosition->JumpTo(posFinal.X, posFinal.Z);
     502
     503        CheckObstructionAndUpdateVisual(id);
    476504    }
    477505}
    478506
     
    543571        CmpPtr<ICmpOwnership> cmpOwnership(*g_Game->GetSimulation2(), g_PreviewEntityID);
    544572        if (cmpOwnership)
    545573            cmpOwnership->SetOwner((player_id_t)msg->settings->player);
     574
     575        CheckObstructionAndUpdateVisual(g_PreviewEntityID);
    546576    }
    547577}
    548578
     
    680710    msg->ids = EntitySelection::PickSimilarEntities(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), templateName, owner, false, true, true, false);
    681711}
    682712
     713MESSAGEHANDLER(ResetSelectionColor)
     714{
     715    UNUSED(msg);
     716    if (g_Selection.empty())
     717        return;
    683718
     719    for (size_t i = 0; i < g_Selection.size(); ++i)
     720    {
     721        CmpPtr<ICmpVisual> cmpVisual(*g_Game->GetSimulation2(), g_Selection[i]);
     722        if (cmpVisual)
     723            cmpVisual->SetShadingColour(fixed::FromDouble(1), fixed::FromDouble(1), fixed::FromDouble(1), fixed::FromDouble(1));
     724    }
     725}
     726
    684727BEGIN_COMMAND(MoveObjects)
    685728{
    686729    // Mapping from object to position
     
    736779        ObjectPositionMap::iterator it;
    737780        for (it = map.begin(); it != map.end(); ++it)
    738781        {
    739             CmpPtr<ICmpPosition> cmpPosition(*g_Game->GetSimulation2(), (entity_id_t)it->first);
     782            entity_id_t id = (entity_id_t)it->first;
     783            CmpPtr<ICmpPosition> cmpPosition(*g_Game->GetSimulation2(), id);
    740784            if (!cmpPosition)
    741785                return;
    742786
     
    743787            // Set 2D position, ignoring height
    744788            CVector3D pos = it->second;
    745789            cmpPosition->JumpTo(entity_pos_t::FromFloat(pos.X), entity_pos_t::FromFloat(pos.Z));
     790
     791            CheckObstructionAndUpdateVisual(id);
    746792        }
    747793    }
    748794
  • source/tools/atlas/GameInterface/Messages.h

     
    1 /* Copyright (C) 2014 Wildfire Games.
     1/* Copyright (C) 2015 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    573577        ((std::vector<ObjectID>, ids))
    574578        );
    575579
     580MESSAGE(ResetSelectionColor, );
     581
    576582COMMAND(MoveObjects, MERGE,
    577583        ((std::vector<ObjectID>, ids))
    578584        ((ObjectID, pivot))