11#include " MainViewer.h"
2+ #include " PartConfig.h"
23#include " PartAsset.h"
34#include " PartAsset_Body.h"
45#include " PartAsset_Nucleus.h"
56#include " GUISlider.h"
7+ #include " CellAsset.h"
68#include " World.h"
79
810void MainViewer::CellMakingViewer::PartsAssembler::PartList::init ()
@@ -25,7 +27,7 @@ Array<shared_ptr<PartAsset>> MainViewer::CellMakingViewer::PartsAssembler::PartL
2527 Array<shared_ptr<PartAsset>> assets;
2628
2729 for (const auto & m : World::GetAssets<PartAsset>().removed_if ([](const auto & pa) { return dynamic_pointer_cast<PartAsset_Body>(pa) ? true : false ; })) assets.emplace_back (m);
28-
30+
2931 return assets;
3032}
3133
@@ -37,8 +39,35 @@ void MainViewer::CellMakingViewer::PartsAssembler::PartList::drawAssets()
3739 for (auto it = assets.begin (); it != assets.end (); ++it)
3840 {
3941 const auto block = RectF (170 , m_itemHeight).stretched (-2.0 );
40- block.draw (ColorF (1.0 , block.mouseOver () ? 0.5 : 0.25 )).drawFrame (1.0 , Palette::White);
41- if (block.leftClicked ()) m_selectedPart = *it;
42+ const bool isNucleus = dynamic_pointer_cast<PartAsset_Nucleus>(*it) != nullptr ;
43+
44+ if (isNucleus)
45+ {
46+ block.draw (ColorF (Palette::Yellow, block.mouseOver () ? 0.5 : 0.25 )).drawFrame (1.0 , Palette::White);
47+
48+ if (block.leftClicked ())
49+ {
50+ auto cellAsset = getParentViewer ()->getParentViewer <CellMakingViewer>()->getCellAsset ();
51+
52+ for (const auto & pc : cellAsset->getPartConfigs ())
53+ {
54+ if (dynamic_pointer_cast<PartAsset_Nucleus>(pc->getPartAsset ()) != nullptr )
55+ {
56+ cellAsset->removePartConfig (pc);
57+
58+ break ;
59+ }
60+ }
61+
62+ cellAsset->addPartConfig ()->setPartAsset (*it);
63+ }
64+ }
65+ else
66+ {
67+ block.draw (ColorF (1.0 , block.mouseOver () ? 0.5 : 0.25 )).drawFrame (1.0 , Palette::White);
68+
69+ if (block.leftClicked ()) m_selectedPart = *it;
70+ }
4271
4372 // パーツ描画
4473 {
0 commit comments