-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from Gaya1858/main
Slight changes item_set to item_map in SelectAction function. We have more functionalities added to the current version of our code. (Textbox, world theme changes...)
- Loading branch information
Showing
28 changed files
with
2,756 additions
and
176 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* @author : Team - 3 | ||
* @date: 11/15/2023 | ||
* Inventory class creates an array of buttons and uses it as inventory | ||
*/ | ||
|
||
#include "Inventory.hpp" | ||
|
||
/** | ||
* @brief Build an inventory window and an inventory list | ||
* | ||
* @param font The font used by the inventory list | ||
*/ | ||
void i_2D::Inventory::ConstructInventory(sf::Font &font) { | ||
mInventoryWindow = std::make_unique<sf::RectangleShape>(); | ||
mInventoryWindow->setSize({mWorldSize.x,mWorldSize.y/2}); | ||
mInventoryWindow->setFillColor(sf::Color::Black); | ||
mInventoryWindow->setPosition(sf::Vector2f{0.f,50.f}); | ||
if(mWorldSize.x > 1800){ | ||
mCol = 5; | ||
}else mCol = 3; | ||
if(mWorldSize.y > 900){ | ||
mRow = 4; | ||
}else mRow = 3; | ||
for(int i = 0; i < mRow; i++) { | ||
std::vector<std::unique_ptr<Button>> v1; | ||
for (int j = 0; j < mCol; j++) { | ||
v1.push_back(std::make_unique<Button>( | ||
"text", sf::Vector2f{(mWorldSize.x)/mCol,(mWorldSize.y/2-50)/mRow}, | ||
sf::Color::Black, sf::Color::White, font)); | ||
v1[j]->setPosition(sf::Vector2f{j*(mWorldSize.x/mCol), | ||
mWorldSize.y/2 + 50 + i*(mWorldSize.y/2-50)/mRow}); | ||
} | ||
mInventoryList.push_back(std::move(v1)); | ||
} | ||
} | ||
|
||
/** | ||
* @brief Draws the inventory onto the render window | ||
* | ||
* @param window The render window of the world | ||
*/ | ||
void i_2D::Inventory::DrawTo(sf::RenderWindow &window) { | ||
window.draw(*mInventoryWindow); | ||
for(const auto &x : mInventoryList){ | ||
for(const auto &y : x){ | ||
y->drawTo(window); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @brief Handle the mouse move event | ||
* | ||
* @param window The render window of the world | ||
*/ | ||
void i_2D::Inventory::HandleMouseMove(sf::RenderWindow &window) { | ||
for(auto &x : mInventoryList){ | ||
for(auto &y : x){ | ||
if(y->isMouseOver(window)){ | ||
y->setBackColor(sf::Color::Magenta); | ||
}else y->setBackColor(sf::Color::Black); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* @author : Team - 3 | ||
* @date: 11/15/2023 | ||
* Inventory class creates an array of buttons and uses it as inventory | ||
*/ | ||
|
||
#ifndef CSE_491_INVENTORY_HPP | ||
#define CSE_491_INVENTORY_HPP | ||
|
||
#include <SFML/Graphics.hpp> | ||
#include "Button.hpp" | ||
#include <vector> | ||
#include <memory> | ||
|
||
namespace i_2D { | ||
/*** | ||
* @class Inventory | ||
* | ||
* @brief Represent the inventory of entities. | ||
* | ||
* An interface/visual representation of an inventory. | ||
*/ | ||
class Inventory { | ||
private: | ||
/// Projected inventory screen | ||
std::unique_ptr<sf::RectangleShape> mInventoryWindow; | ||
/// List of items in an inventory | ||
std::vector<std::vector<std::unique_ptr<Button>>> mInventoryList; | ||
sf::Vector2f mWorldSize; ///< Size of the world | ||
int mCol=0; ///< Number of columns enumerating the inventory list | ||
int mRow=0; ///< Number of rows enumerating the inventory list | ||
|
||
public: | ||
explicit Inventory(const sf::Vector2f size) : mWorldSize(size) {} | ||
void SetSize(const sf::Vector2f size) {mWorldSize = size;} | ||
void ConstructInventory(sf::Font &font); | ||
void DrawTo(sf::RenderWindow &window); | ||
void HandleMouseMove(sf::RenderWindow &window); | ||
}; | ||
} | ||
|
||
|
||
#endif //CSE_491_INVENTORY_HPP |
Oops, something went wrong.