Skip to content

Commit

Permalink
v 0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Ironbell committed Jan 27, 2018
1 parent 3086dca commit 7211da4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion include/GUI/MerchantWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class MerchantWindow final {
void deselectCurrentSlot();
InventorySlot* getSelectedSlot();

std::map<std::string, InventorySlot> m_items;
std::map<std::string, InventorySlot*> m_items;
MerchantItemDescriptionWindow* m_descriptionWindow = nullptr;

void showDescription(const Item* item);
Expand Down
2 changes: 1 addition & 1 deletion include/Global/global_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <cassert>

// versioning
#define CENDRIC_VERSION_NR "0.8.0"
#define CENDRIC_VERSION_NR "0.9.0"

// Debug version
#define DEBUG
Expand Down
28 changes: 14 additions & 14 deletions src/GUI/MerchantWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ MerchantWindow::~MerchantWindow() {
}

void MerchantWindow::clearAllSlots() {
m_items.clear();
CLEAR_MAP(m_items);
m_selectedSlotId = "";
}

Expand All @@ -92,15 +92,15 @@ void MerchantWindow::notifyChange(const std::string& itemID) {
calculateSlotPositions();
}
else {
m_items.at(itemID).setAmount(m_interface->getMerchantData().wares.at(itemID));
m_items.at(itemID)->setAmount(m_interface->getMerchantData().wares.at(itemID));
}
return;
}

// the slot for that item has not been found. The slot is added with the current amount in the core
if (!contains(m_interface->getMerchantData().wares, itemID)) return;

m_items.insert({ itemID, InventorySlot(itemID, m_interface->getMerchantData().wares.at(itemID)) });
m_items.insert({ itemID, new InventorySlot(itemID, m_interface->getMerchantData().wares.at(itemID)) });

calculateSlotPositions();
}
Expand All @@ -110,14 +110,14 @@ void MerchantWindow::update(const sf::Time& frameTime) {

// check whether an item was selected
for (auto& slot : m_items) {
sf::Vector2f pos = slot.second.getPosition();
sf::Vector2f pos = slot.second->getPosition();
if (pos.y < TOP + SCROLL_WINDOW_TOP ||
pos.y + InventorySlot::SIZE > TOP + SCROLL_WINDOW_TOP + SCROLL_WINDOW_HEIGHT) continue;
slot.second.update(frameTime);
if (slot.second.isMousedOver()) {
selectSlot(slot.second.getItemID());
if (slot.second.isRightClicked()) {
m_interface->buyItem(slot.second.getItem());
slot.second->update(frameTime);
if (slot.second->isMousedOver()) {
selectSlot(slot.second->getItemID());
if (slot.second->isRightClicked()) {
m_interface->buyItem(slot.second->getItem());
break;
}
}
Expand Down Expand Up @@ -163,15 +163,15 @@ void MerchantWindow::deselectCurrentSlot() {
InventorySlot* MerchantWindow::getSelectedSlot() {
if (m_selectedSlotId.empty()) return nullptr;
if (!contains(m_items, m_selectedSlotId)) return nullptr;
return &m_items.at(m_selectedSlotId);
return m_items.at(m_selectedSlotId);
}

void MerchantWindow::render(sf::RenderTarget& target) {
m_window->render(target);
target.draw(m_title);

for (auto& it : m_items) {
it.second.render(m_scrollHelper->texture);
it.second->render(m_scrollHelper->texture);
}
m_scrollHelper->render(target);

Expand All @@ -183,7 +183,7 @@ void MerchantWindow::render(sf::RenderTarget& target) {

void MerchantWindow::renderAfterForeground(sf::RenderTarget& target) {
for (auto& it : m_items) {
it.second.renderAfterForeground(target);
it.second->renderAfterForeground(target);
}
}

Expand Down Expand Up @@ -214,7 +214,7 @@ void MerchantWindow::reload() {
continue;
}

m_items.insert({ it.first, InventorySlot(it.first, it.second) });
m_items.insert({ it.first, new InventorySlot(it.first, it.second) });
}
}

Expand Down Expand Up @@ -248,7 +248,7 @@ void MerchantWindow::calculateSlotPositions() {
int y = 1;
int x = 1;
for (auto& it : m_items) {
it.second.setPosition(sf::Vector2f(xOffset, yOffset));
it.second->setPosition(sf::Vector2f(xOffset, yOffset));
if (x + 1 > SLOT_COUNT_X) {
x = 1;
xOffset = xOffsetStart;
Expand Down

0 comments on commit 7211da4

Please sign in to comment.