Peoplemon  0.1.0
Peoplemon 3 game source documentation
StorageSystem.cpp
Go to the documentation of this file.
2 
4 #include <Core/Items/Item.hpp>
5 #include <Core/Properties.hpp>
6 #include <Core/Resources.hpp>
8 
9 namespace game
10 {
11 namespace state
12 {
13 namespace
14 {
15 constexpr glm::vec2 BoxTitlePosition(365.f, 70.f);
16 constexpr glm::vec2 BoxTitleSize(701.f - BoxTitlePosition.x, 130.f - BoxTitlePosition.y);
17 constexpr glm::vec2 ThumbnailPosition(68.f, 284.f);
18 constexpr glm::vec2 ThumbnailSize(218.f - ThumbnailPosition.x, 434.f - ThumbnailPosition.y);
19 constexpr glm::vec2 NamePosition(ThumbnailPosition.x + ThumbnailSize.x * 0.5f,
20  ThumbnailPosition.y + ThumbnailSize.y + 4.f);
21 constexpr glm::vec2 LevelPosition(ThumbnailPosition.x + 4.f, 475.f);
22 constexpr glm::vec2 ItemLabelPosition(LevelPosition.x, LevelPosition.y + 36.f);
23 constexpr glm::vec2 ItemPosition(ItemLabelPosition.x, ItemLabelPosition.y + 25.f);
24 constexpr float SlideTime = 0.5f;
25 constexpr float SlideVel = menu::StorageGrid::BoxSize.x / SlideTime;
26 } // namespace
27 
28 bl::engine::State::Ptr StorageSystem::create(core::system::Systems& s) {
29  return bl::engine::State::Ptr(new StorageSystem(s));
30 }
31 
32 StorageSystem::StorageSystem(core::system::Systems& s)
33 : State(s, bl::engine::StateMask::Menu)
34 , state(MenuState::ChooseAction)
35 , currentBox(0)
36 , overlay(nullptr)
37 , grids{{s.engine()}, {s.engine()}}
38 , activeGrid(&grids[0])
39 , slidingOutGrid(&grids[1])
40 , hovered(nullptr)
41 , cursor(s.engine())
42 , depositedPeoplemon(-1) {
43  auto joinPath = bl::util::FileUtil::joinPath;
44  using bl::menu::Item;
45  using bl::menu::TextItem;
46  using core::Properties;
47 
48  actionMenu.create(s.engine(),
49  s.engine().renderer().getObserver(),
50  bl::menu::ArrowSelector::create(12.f, sf::Color::Black));
51  contextMenu.create(s.engine(),
52  s.engine().renderer().getObserver(),
53  bl::menu::ArrowSelector::create(12.f, sf::Color::Black));
54 
55  backgroundTxtr = s.engine().renderer().texturePool().getOrLoadTexture(
56  joinPath(Properties::MenuImagePath(), "StorageSystem/storageBGND.png"));
57  background.create(s.engine(), backgroundTxtr);
58  grids[0].activate(background.entity());
59  grids[1].activate(background.entity());
60 
61  leftArrowTxtr = s.engine().renderer().texturePool().getOrLoadTexture(
62  joinPath(Properties::MenuImagePath(), "StorageSystem/storageArrowLeft.png"));
63  leftArrow.create(s.engine(), leftArrowTxtr);
64  leftArrow.getTransform().setPosition(BoxTitlePosition.x - leftArrowTxtr->size().x - 3.f,
65  BoxTitlePosition.y + BoxTitleSize.y * 0.5f -
66  leftArrowTxtr->size().y * 0.5f);
67  leftArrow.setParent(background);
68 
69  rightArrowTxtr = s.engine().renderer().texturePool().getOrLoadTexture(
70  joinPath(Properties::MenuImagePath(), "StorageSystem/storageArrowRight.png"));
71  rightArrow.create(s.engine(), rightArrowTxtr);
72  rightArrow.getTransform().setPosition(BoxTitlePosition.x + BoxTitleSize.x + 3.f,
73  BoxTitlePosition.y + BoxTitleSize.y * 0.5f -
74  rightArrowTxtr->size().y * 0.5f);
75  rightArrow.setParent(background);
76 
77  boxTitle.create(s.engine(), core::Properties::MenuFont(), "", 42, sf::Color::Black);
78  boxTitle.getTransform().setPosition(BoxTitlePosition + BoxTitleSize * 0.5f);
79  boxTitle.setParent(background);
80 
81  nickname.create(s.engine(), core::Properties::MenuFont(), "", 26, sf::Color(240, 40, 50));
82  nickname.getTransform().setPosition(NamePosition);
83  nickname.setParent(background);
84 
85  level.create(s.engine(), core::Properties::MenuFont(), "", 22, sf::Color(35, 160, 245));
86  level.getTransform().setPosition(LevelPosition);
87  level.setParent(background);
88 
89  itemLabel.create(
90  s.engine(), core::Properties::MenuFont(), "Hold item:", 16, sf::Color(200, 255, 255));
91  itemLabel.addSection("", 16, sf::Color(165, 255, 255));
92  itemLabel.getTransform().setPosition(ItemLabelPosition);
93  itemLabel.setParent(background);
94 
95  TextItem::Ptr depositItem =
96  TextItem::create("Deposit", Properties::MenuFont(), sf::Color::Black, 34);
97  depositItem->getSignal(Item::Activated)
98  .willAlwaysCall(std::bind(&StorageSystem::startDeposit, this));
99  withdrawActionItem = TextItem::create("Browse", Properties::MenuFont(), sf::Color::Black, 34);
100  withdrawActionItem->getSignal(Item::Activated)
101  .willAlwaysCall(std::bind(&StorageSystem::startBrowse, this));
102  TextItem::Ptr closeItem =
103  TextItem::create("Close", Properties::MenuFont(), sf::Color::Black, 34);
104  closeItem->getSignal(Item::Activated).willAlwaysCall(std::bind(&StorageSystem::close, this));
105  actionMenu.setRootItem(withdrawActionItem);
106  actionMenu.addItem(depositItem, withdrawActionItem.get(), Item::Bottom);
107  actionMenu.addItem(closeItem, depositItem.get(), Item::Bottom);
108  actionMenu.setPosition({30.f, 25.f});
109  actionMenu.configureBackground(sf::Color::White, sf::Color::Black, 3.f, {20.f, 2.f, 4.f, 4.f});
110 
111  TextItem::Ptr withdrawItem = TextItem::create("Withdraw", Properties::MenuFont());
112  withdrawItem->getSignal(Item::Activated)
113  .willAlwaysCall(std::bind(&StorageSystem::onWithdraw, this));
114  TextItem::Ptr moveItem = TextItem::create("Move", Properties::MenuFont());
115  moveItem->getSignal(Item::Activated)
116  .willAlwaysCall(std::bind(&StorageSystem::onStartMove, this));
117  TextItem::Ptr itemItem = TextItem::create("Take Item", Properties::MenuFont());
118  itemItem->getSignal(Item::Activated)
119  .willAlwaysCall(std::bind(&StorageSystem::onTakeItem, this));
120  TextItem::Ptr releaseItem = TextItem::create("Release", Properties::MenuFont());
121  releaseItem->getSignal(Item::Activated)
122  .willAlwaysCall(std::bind(&StorageSystem::onRelease, this));
123  TextItem::Ptr backItem = TextItem::create("Back", Properties::MenuFont());
124  backItem->getSignal(Item::Activated)
125  .willAlwaysCall(std::bind(&StorageSystem::onCloseContextMenu, this));
126  contextMenu.setRootItem(withdrawItem);
127  contextMenu.addItem(moveItem, withdrawItem.get(), Item::Bottom);
128  contextMenu.addItem(itemItem, moveItem.get(), Item::Bottom);
129  contextMenu.addItem(releaseItem, itemItem.get(), Item::Bottom);
130  contextMenu.addItem(backItem, releaseItem.get(), Item::Bottom);
131  contextMenu.configureBackground(sf::Color::White, sf::Color::Black, 2.f, {20.f, 2.f, 4.f, 4.f});
132 
133  pageSlideFailSound = core::Properties::MenuMoveFailSound();
134  pageSlideSound = bl::audio::AudioSystem::getOrLoadSound(
135  joinPath(Properties::SoundPath(), "Menu/storageBoxChange.mp3"));
136  cursorMoveSound = bl::audio::AudioSystem::getOrLoadSound(
137  joinPath(Properties::SoundPath(), "Menu/storageCursorMove.mp3"));
138 }
139 
140 const char* StorageSystem::name() const { return "StorageSystem"; }
141 
142 void StorageSystem::activate(bl::engine::Engine& engine) {
143  systems.engine().inputSystem().getActor().addListener(*this);
144 
145  overlay = engine.renderer().getObserver().pushScene<bl::rc::Overlay>();
146  background.addToScene(overlay, bl::rc::UpdateSpeed::Static);
147  leftArrow.addToScene(overlay, bl::rc::UpdateSpeed::Static);
148  rightArrow.addToScene(overlay, bl::rc::UpdateSpeed::Static);
149  boxTitle.addToScene(overlay, bl::rc::UpdateSpeed::Static);
150  nickname.addToScene(overlay, bl::rc::UpdateSpeed::Static);
151  level.addToScene(overlay, bl::rc::UpdateSpeed::Static);
152  itemLabel.addToScene(overlay, bl::rc::UpdateSpeed::Static);
153  if (thumbnail.entity() != bl::ecs::InvalidEntity) {
154  thumbnail.addToScene(overlay, bl::rc::UpdateSpeed::Static);
155  }
156  actionMenu.addToOverlay(background.entity());
157  contextMenu.addToOverlay(background.entity());
158  cursor.activate(background.entity());
159  activeGrid->activate(background.entity());
160  slidingOutGrid->activate(background.entity());
161 
162  hovered = systems.player().state().storage.get(currentBox, cursor.getPosition());
163  if (state == MenuState::WaitingDeposit) {
164  if (depositedPeoplemon >= 0) {
165  actionMenu.setSelectedItem(withdrawActionItem.get());
166  const auto& ppl = systems.player().state().peoplemon[depositedPeoplemon];
167  hovered = nullptr;
168  updatePeoplemonInfo(ppl);
169  cursor.setHolding(ppl.id());
170  enterState(MenuState::PlacingPeoplemon);
171  showPeoplemonInfo(true);
172  }
173  else {
174  showPeoplemonInfo(false);
175  enterState(MenuState::ChooseAction);
176  }
177  }
178  else {
179  showPeoplemonInfo(false);
180  enterState(MenuState::ChooseAction);
181  }
182 
183  finishBoxChange();
184  if (hovered != nullptr) { updatePeoplemonInfo(hovered->peoplemon); }
185 
186  contextMenu.setHidden(true);
187 }
188 
189 void StorageSystem::deactivate(bl::engine::Engine& engine) {
190  systems.engine().inputSystem().getActor().removeListener(*this);
191  bl::event::Dispatcher::dispatch<core::event::StorageSystemClosed>({});
192  cursor.deactivate();
193  activeGrid->deactivate();
194  engine.renderer().getObserver().popScene();
195  overlay = nullptr;
196 }
197 
198 void StorageSystem::update(bl::engine::Engine&, float dt, float) {
199  cursor.update(dt);
200 
201  switch (state) {
202  case MenuState::BoxSliding:
203  slideOffset += slideVel * dt;
204  activeGrid->notifyOffset(slideOffset + menu::StorageGrid::BoxSize.x * slideVel /
205  std::abs(slideVel) * -1.f);
206  slidingOutGrid->notifyOffset(slideOffset);
207  if (std::abs(slideOffset) >= menu::StorageGrid::BoxSize.x) {
208  slidingOutGrid->deactivate();
209  activeGrid->notifyOffset(0.f);
210  enterState(prevState);
211  }
212  break;
213 
214  case MenuState::WaitingContextMessage:
215  case MenuState::WaitingReleaseConfirm:
216  break;
217 
218  case MenuState::CursorMoving:
219  if (!cursor.moving()) { enterState(prevState); }
220  break;
221 
222  default:
223  break;
224  }
225 }
226 
227 void StorageSystem::startDeposit() {
228  if (systems.player().state().peoplemon.size() > 1) {
229  systems.engine().pushState(PeoplemonMenu::create(
230  systems, PeoplemonMenu::Context::StorageSelect, -1, &depositedPeoplemon));
231  enterState(MenuState::WaitingDeposit);
232  }
233  else {
234  systems.hud().displayMessage("You cannot deposit your last Peoplemon!",
235  std::bind(&StorageSystem::onMessageDone, this));
236  enterState(MenuState::WaitingHudMessage);
237  }
238 }
239 
240 void StorageSystem::startBrowse() { enterState(MenuState::BrowsingBox); }
241 
242 void StorageSystem::close() { systems.engine().popState(); }
243 
244 void StorageSystem::onCursor(const sf::Vector2i& pos) {
245  if (state == MenuState::PlacingPeoplemon || state == MenuState::MovingPeoplemon) return;
246  onHover(systems.player().state().storage.get(currentBox, pos));
247 }
248 
249 void StorageSystem::onHover(core::pplmn::StoredPeoplemon* ppl) {
250  hovered = ppl;
251  if (ppl != nullptr) {
252  updatePeoplemonInfo(ppl->peoplemon);
253  showPeoplemonInfo(true);
254  }
255  else { showPeoplemonInfo(false); }
256 }
257 
258 void StorageSystem::updatePeoplemonInfo(const core::pplmn::OwnedPeoplemon& ppl) {
259  nickname.getSection().setString(ppl.name());
260  nickname.getTransform().setOrigin(nickname.getLocalBounds().width * 0.5f, 0.f);
261  level.getSection().setString("Level " + std::to_string(ppl.currentLevel()));
262  itemLabel.getSection(1).setString(ppl.holdItem() == core::item::Id::None ?
263  "None" :
265  updateThumbnail(core::pplmn::Peoplemon::thumbnailImage(ppl.id()));
266 }
267 
268 void StorageSystem::updateThumbnail(const std::string& src) {
269  thumbTxtr = systems.engine().renderer().texturePool().getOrLoadTexture(src);
270  if (thumbnail.entity() == bl::ecs::InvalidEntity) {
271  thumbnail.create(systems.engine(), thumbTxtr);
272  thumbnail.getTransform().setPosition(ThumbnailPosition);
273  thumbnail.setParent(background);
274  if (overlay) { thumbnail.addToScene(overlay, bl::rc::UpdateSpeed::Static); }
275  }
276  else { thumbnail.setTexture(thumbTxtr); }
277  thumbnail.scaleToSize(ThumbnailSize);
278 }
279 
280 void StorageSystem::onSelect(const sf::Vector2i& pos) {
281  selectPos = pos;
282 
283  switch (state) {
284  case MenuState::PlacingPeoplemon:
285  if (!systems.player().state().storage.get(currentBox, pos)) {
286  systems.player().state().storage.add(
287  currentBox, pos, systems.player().state().peoplemon[depositedPeoplemon]);
288  systems.player().state().peoplemon.erase(systems.player().state().peoplemon.begin() +
289  depositedPeoplemon);
290  activeGrid->update(systems.player().state().storage.getBox(currentBox));
291  cursor.setHolding(core::pplmn::Id::Unknown);
292  enterState(MenuState::BrowsingBox);
293  onCursor(cursor.getPosition());
294  }
295  else { bl::audio::AudioSystem::playOrRestartSound(core::Properties::MenuMoveFailSound()); }
296  break;
297  case MenuState::BrowsingBox:
298  if (hovered != nullptr) { enterState(MenuState::BrowseMenuOpen); }
299  break;
300  case MenuState::MovingPeoplemon:
301  if (hovered) {
302  hovered->position = ogMovePos; // to properly move
303  hovered = systems.player().state().storage.move(*hovered, currentBox, pos);
304  activeGrid->update(systems.player().state().storage.getBox(currentBox));
305  }
306  cursor.setHolding(core::pplmn::Id::Unknown);
307  enterState(MenuState::BrowsingBox);
308  break;
309  default:
310  break;
311  }
312 }
313 
314 void StorageSystem::boxLeft() {
315  if (currentBox == 0) return;
316  --currentBox;
317  slideVel = SlideVel;
318  cursor.setX(core::player::StorageSystem::BoxWidth - 1);
319  finishBoxChange();
320  enterState(MenuState::BoxSliding);
321 }
322 
323 void StorageSystem::boxRight() {
324  if (currentBox == core::player::StorageSystem::BoxCount - 1) return;
325  ++currentBox;
326  slideVel = -SlideVel;
327  cursor.setX(0);
328  finishBoxChange();
329  enterState(MenuState::BoxSliding);
330 }
331 
332 void StorageSystem::finishBoxChange() {
333  boxTitle.getSection().setString("Storage Box " + std::to_string(currentBox + 1));
334  boxTitle.getTransform().setOrigin(boxTitle.getLocalBounds().width * 0.5f,
335  boxTitle.getLocalBounds().height * 0.5f);
336  slideOffset = 0.f;
337  leftArrow.setHidden(currentBox == 0);
338  rightArrow.setHidden(currentBox == 13);
339 
340  std::swap(activeGrid, slidingOutGrid);
341  activeGrid->update(systems.player().state().storage.getBox(currentBox));
342  activeGrid->notifyOffset(0.f);
343 }
344 
345 void StorageSystem::showContextMessage(const std::string& msg, bool cm) {
346  closeMenuAfterMessage = cm;
347  systems.hud().displayMessage(msg, std::bind(&StorageSystem::onMessageDone, this));
348  enterState(MenuState::WaitingContextMessage);
349 }
350 
351 void StorageSystem::onWithdraw() {
352  if (systems.player().state().peoplemon.size() == 6) {
353  showContextMessage("Your party is full! Ditch some other loser to make room.", false);
354  }
355  else {
356  showContextMessage(hovered->peoplemon.name() + " was added to your party!");
357  systems.player().state().peoplemon.emplace_back(hovered->peoplemon);
358  systems.player().state().storage.remove(currentBox, selectPos);
359  activeGrid->update(systems.player().state().storage.getBox(currentBox));
360  }
361 }
362 
363 void StorageSystem::onStartMove() {
364  ogMovePos = cursor.getPosition();
365  hovered->position = {-5, -5};
366  cursor.setHolding(hovered->peoplemon.id());
367  activeGrid->update(systems.player().state().storage.getBox(currentBox));
368  enterState(MenuState::MovingPeoplemon);
369 }
370 
371 void StorageSystem::onTakeItem() {
372  if (hovered->peoplemon.holdItem() != core::item::Id::None) {
373  showContextMessage(hovered->peoplemon.name() + " had their " +
374  core::item::Item::getName(hovered->peoplemon.holdItem()) +
375  " ripped from their hands!");
376  systems.player().state().bag.addItem(hovered->peoplemon.holdItem());
377  hovered->peoplemon.holdItem() = core::item::Id::None;
378  }
379  else { showContextMessage(hovered->peoplemon.name() + " isn't holding anything!", false); }
380 }
381 
382 void StorageSystem::onRelease() {
383  systems.hud().promptUser(
384  "Are you sure you want to tell " + hovered->peoplemon.name() + " to go away forever?",
385  {"Yes", "No"},
386  std::bind(&StorageSystem::onReleaseConfirm, this, std::placeholders::_1));
387  enterState(MenuState::WaitingReleaseConfirm);
388 }
389 
390 void StorageSystem::onCloseContextMenu() {
391  bl::audio::AudioSystem::playOrRestartSound(core::Properties::MenuBackSound());
392  enterState(MenuState::BrowsingBox);
393 }
394 
395 bool StorageSystem::observe(const bl::input::Actor&, unsigned int cmd, bl::input::DispatchType,
396  bool eventTriggered) {
397  bl::menu::Menu* toSend = nullptr;
398  if (cmd == core::input::Control::Back) {
399  if (!eventTriggered) return true;
400 
401  switch (state) {
402  case MenuState::ChooseAction:
403  close();
404  break;
405  case MenuState::PlacingPeoplemon:
406  cursor.setHolding(core::pplmn::Id::Unknown);
407  enterState(MenuState::ChooseAction);
408  break;
409  case MenuState::BrowsingBox:
410  enterState(MenuState::ChooseAction);
411  break;
412  case MenuState::MovingPeoplemon:
413  if (hovered) {
414  hovered->position = ogMovePos;
415  activeGrid->update(systems.player().state().storage.getBox(currentBox));
416  }
417  cursor.setHolding(core::pplmn::Id::Unknown);
418  [[fallthrough]];
419  case MenuState::BrowseMenuOpen:
420  enterState(MenuState::BrowsingBox);
421  onCursor(cursor.getPosition());
422  break;
423  default:
424  break;
425  }
426  return true;
427  }
428 
429  switch (state) {
430  case MenuState::ChooseAction:
431  toSend = &actionMenu;
432  break;
433 
434  case MenuState::PlacingPeoplemon:
435  case MenuState::BrowsingBox:
436  case MenuState::MovingPeoplemon:
437  if (cmd == core::input::Control::Interact) {
438  if (eventTriggered) { onSelect(cursor.getPosition()); }
439  }
440  else if (cmd == core::input::Control::MoveLeft && cursor.getPosition().x == 0) {
441  if (currentBox > 0) {
442  boxLeft();
443  bl::audio::AudioSystem::playOrRestartSound(pageSlideSound);
444  }
445  else { bl::audio::AudioSystem::playOrRestartSound(pageSlideFailSound); }
446  }
447  else if (cmd == core::input::Control::MoveRight &&
448  cursor.getPosition().x == core::player::StorageSystem::BoxWidth - 1) {
449  if (currentBox < core::player::StorageSystem::BoxCount - 1) {
450  boxRight();
451  bl::audio::AudioSystem::playOrRestartSound(pageSlideSound);
452  }
453  else { bl::audio::AudioSystem::playOrRestartSound(pageSlideFailSound); }
454  }
455  else {
456  if (cursor.process(cmd, eventTriggered)) {
457  onCursor(cursor.getPosition());
458  bl::audio::AudioSystem::playOrRestartSound(cursorMoveSound);
459  enterState(MenuState::CursorMoving);
460  }
461  else {
462  bl::audio::AudioSystem::playOrRestartSound(core::Properties::MenuMoveFailSound());
463  }
464  }
465  break;
466 
467  case MenuState::BrowseMenuOpen:
468  toSend = &contextMenu;
469  break;
470 
471  default:
472  break;
473  }
474 
475  if (toSend != nullptr) {
476  menuDriver.drive(toSend);
477  menuDriver.sendControl(cmd, eventTriggered);
478  }
479 
480  return true;
481 }
482 
483 void StorageSystem::enterState(MenuState ns) {
484  prevState = state;
485  state = ns;
486 
487  cursor.setHidden(ns == MenuState::ChooseAction || ns == MenuState::BoxSliding ||
488  ns == MenuState::WaitingHudMessage);
489  contextMenu.setHidden(true);
490 
491  switch (ns) {
492  case MenuState::BrowseMenuOpen:
493  positionContextMenu();
494  [[fallthrough]];
495 
496  case MenuState::WaitingContextMessage:
497  case MenuState::WaitingReleaseConfirm:
498  contextMenu.setHidden(false);
499  break;
500 
501  default:
502  break;
503  }
504  if (hovered != nullptr) { updatePeoplemonInfo(hovered->peoplemon); }
505 }
506 
507 void StorageSystem::onReleaseConfirm(const std::string& c) {
508  if (c == "Yes") {
509  showContextMessage(hovered->peoplemon.name() +
510  " was released and will probably end up on the streets.");
511  systems.player().state().storage.remove(currentBox, selectPos);
512  activeGrid->update(systems.player().state().storage.getBox(currentBox));
513  }
514  else { enterState(MenuState::BrowseMenuOpen); }
515 }
516 
517 void StorageSystem::onMessageDone() {
518  switch (state) {
519  case MenuState::WaitingContextMessage:
520  enterState(closeMenuAfterMessage ? MenuState::BrowsingBox : MenuState::BrowseMenuOpen);
521  onCursor(cursor.getPosition());
522  break;
523  case MenuState::WaitingHudMessage:
524  enterState(MenuState::ChooseAction);
525  break;
526  }
527 }
528 
529 void StorageSystem::showPeoplemonInfo(bool s) {
530  const bool hidden = !s;
531  nickname.setHidden(hidden);
532  level.setHidden(hidden);
533  itemLabel.setHidden(hidden);
534  if (hidden) {
535  updateThumbnail(bl::util::FileUtil::joinPath(core::Properties::MenuImagePath(),
536  "StorageSystem/question.png"));
537  }
538 }
539 
540 void StorageSystem::positionContextMenu() {
541  constexpr float Padding = 5.f;
542 
543  glm::vec2 pos(cursor.getPosition().x + 1, cursor.getPosition().y + 1);
545  pos += menu::StorageGrid::BoxPosition + glm::vec2{Padding, Padding};
546  if (pos.x + contextMenu.getBounds().width > core::Properties::WindowSize().x) {
547  pos.x -= contextMenu.getBounds().width + menu::StorageCursor::TileSize() + Padding * 2.f;
548  }
549  if (pos.y + contextMenu.getBounds().height > core::Properties::WindowSize().y) {
550  pos.y -= contextMenu.getBounds().height + menu::StorageCursor::TileSize() + Padding * 4.f;
551  }
552 
553  contextMenu.setPosition(pos);
554 }
555 
556 } // namespace state
557 } // namespace game
Parent namespace for all functionality unique to the game.
static const std::string & getName(item::Id item)
Returns the name of the given item.
Definition: Item.cpp:91
Represents an instance of a peoplemon. Can be a wild peoplemon, trainer, or player peoplemon....
unsigned int currentLevel() const
Returns the current level of this peoplemon.
Id id() const
Returns the id of this peoplemon.
item::Id & holdItem()
Access the current hold item of this peoplemon.
const std::string & name() const
Returns the name of this peoplemon, custom or defualt.
static std::string thumbnailImage(Id id)
Returns the path of the image to render as the peoplemon thumbnail.
Definition: Peoplemon.cpp:211
Represents a Peoplemon in storage.
OwnedPeoplemon peoplemon
The peoplemon itself.
static constexpr int BoxCount
static constexpr int BoxWidth
Wrapper around bl::engine::Configuration. Provides application configuration in variables that may be...
Definition: Properties.hpp:28
static bl::audio::AudioSystem::Handle MenuMoveFailSound()
Definition: Properties.cpp:707
static const sf::VulkanFont & MenuFont()
Definition: Properties.cpp:363
static bl::audio::AudioSystem::Handle MenuBackSound()
Definition: Properties.cpp:712
static const std::string & MenuImagePath()
Definition: Properties.cpp:303
static sf::Vector2f WindowSize()
Definition: Properties.cpp:262
Owns all primary systems and a reference to the engine.
Definition: Systems.hpp:47
const bl::engine::Engine & engine() const
Const accessor for the Engine.
Definition: Systems.cpp:35
static float TileSize()
Returns the size of a square on the grid.
static constexpr glm::vec2 BoxPosition
Definition: StorageGrid.hpp:22
static constexpr glm::vec2 BoxSize
Definition: StorageGrid.hpp:23
Parent to all game states. Provides some commonly required data like core game systems.
Definition: State.hpp:29
Game state for the peoplemon storage system menu.
static bl::engine::State::Ptr create(core::system::Systems &systems)
Create a new storage system menu.