Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
RehtiGui Class Reference

Class that manages the GUI window. More...

#include <RehtiGui.hpp>

Collaboration diagram for RehtiGui:
Collaboration graph

Public Member Functions

 RehtiGui (VkInstance instance, VkPhysicalDevice gpu, VkDevice logDevice, GLFWwindow *pWindow, VkQueue graphicsQueue, VkDescriptorPool descPool, uint32_t imageCount, VkRenderPass renderPass, std::shared_ptr< GraphicsObjectManager > pGfxManager)
 
 ~RehtiGui ()
 
void uploadFonts (VkCommandBuffer cmdBuffer)
 
void uploadEnded ()
 
void newFrame ()
 
void recordGuiData (VkCommandBuffer cmdBuff)
 Records ui primitives into the given command buffer. More...
 
void startRender ()
 Starts rendering ui primitives. Must be called at the top of draw function. More...
 
void addInventoryItemClickCallback (std::function< void(const int id)> callback)
 Adds callback function for clicking an item in inventory. More...
 
void addDropItemCallback (std::function< void(const int id)> callback)
 Adds callback function for dropping an item in inventory. More...
 
void addEquipmentItemClickCallback (std::function< void(const int id)> callback)
 Adds callback function for clicking and item in equipment. More...
 
void setInventory (std::vector< GameItem > inventory)
 Set contents of player's inventory. More...
 
std::vector< GameItem > & getEquipment ()
 Get reference to the player's equipment vector. More...
 
void setEquipment (std::vector< GameItem > equipment)
 Set contents of player's equipment. More...
 
void setSkills (std::vector< Skill > skills)
 Set skills of player. More...
 
void setHp (int hp)
 Set hp of player. More...
 
bool LoadTextureFromFile (const char *filename, const int id)
 Load texture from file and save it to member map guiIconsM with key id. More...
 
bool LoadTextureFromImageData (const int id, ImageData &imgData)
 Load texture from ImageData and save it to member map guiIconsM with key id. More...
 

Private Member Functions

void drawInventory ()
 Draws inventory tab to GUI window. More...
 
void drawEquipment ()
 Draws equipment tab to GUI window. More...
 
void drawSkills ()
 Draws skills tab to GUI window. More...
 
void drawEquipmentSlot (int index)
 Helper function for a single equipment slot. More...
 

Private Attributes

VkDevice logDeviceM
 
VkDescriptorPool descPoolM
 
VkQueue graphicsQueueM
 
VkSampler samplerM
 
std::shared_ptr< GraphicsObjectManagerpGraphicsObjectManagerM
 
UiTab openTabM
 
std::function< void(const int id)> inventoryItemClickCallbackM
 
std::function< void(const int id)> dropItemCallbackM
 
std::function< void(const int id)> equipmentItemClickCallbackM
 
std::vector< GameItem > inventoryM
 
std::vector< GameItem > equipmentM
 
std::vector< Skill > skillsM
 
int hpM
 
std::mutex invMutexM
 
std::mutex equipmentMutexM
 
std::mutex skillsMutexM
 
int windowWidthM = 300
 
int windowHeightM = 500
 
ImVec2 iconSizeM = ImVec2(windowWidthM * 0.8 / 4, windowWidthM * 0.8 / 4)
 
AssetCacheassetCacheM
 
std::unordered_map< int, VkDescriptorSet > guiIconsM
 

Detailed Description

Class that manages the GUI window.

Constructor & Destructor Documentation

◆ RehtiGui()

RehtiGui::RehtiGui ( VkInstance  instance,
VkPhysicalDevice  gpu,
VkDevice  logDevice,
GLFWwindow *  pWindow,
VkQueue  graphicsQueue,
VkDescriptorPool  descPool,
uint32_t  imageCount,
VkRenderPass  renderPass,
std::shared_ptr< GraphicsObjectManager pGfxManager 
)
Here is the call graph for this function:

◆ ~RehtiGui()

RehtiGui::~RehtiGui ( )

Member Function Documentation

◆ addDropItemCallback()

void RehtiGui::addDropItemCallback ( std::function< void(const int id)>  callback)

Adds callback function for dropping an item in inventory.

Parameters
callback

◆ addEquipmentItemClickCallback()

void RehtiGui::addEquipmentItemClickCallback ( std::function< void(const int id)>  callback)

Adds callback function for clicking and item in equipment.

Parameters
callback

◆ addInventoryItemClickCallback()

void RehtiGui::addInventoryItemClickCallback ( std::function< void(const int id)>  callback)

Adds callback function for clicking an item in inventory.

Parameters
callback

◆ drawEquipment()

void RehtiGui::drawEquipment ( )
private

Draws equipment tab to GUI window.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawEquipmentSlot()

void RehtiGui::drawEquipmentSlot ( int  index)
private

Helper function for a single equipment slot.

Parameters
index
Here is the caller graph for this function:

◆ drawInventory()

void RehtiGui::drawInventory ( )
private

Draws inventory tab to GUI window.

Here is the caller graph for this function:

◆ drawSkills()

void RehtiGui::drawSkills ( )
private

Draws skills tab to GUI window.

Here is the caller graph for this function:

◆ getEquipment()

std::vector< GameItem > & RehtiGui::getEquipment ( )

Get reference to the player's equipment vector.

Returns
std::vector<GameItem>&

◆ LoadTextureFromFile()

bool RehtiGui::LoadTextureFromFile ( const char *  filename,
const int  id 
)

Load texture from file and save it to member map guiIconsM with key id.

Parameters
filename
id
Returns
success
Here is the caller graph for this function:

◆ LoadTextureFromImageData()

bool RehtiGui::LoadTextureFromImageData ( const int  id,
ImageData imgData 
)

Load texture from ImageData and save it to member map guiIconsM with key id.

Parameters
id
imgData
Returns
success
Here is the caller graph for this function:

◆ newFrame()

void RehtiGui::newFrame ( )
Here is the call graph for this function:

◆ recordGuiData()

void RehtiGui::recordGuiData ( VkCommandBuffer  cmdBuff)

Records ui primitives into the given command buffer.

Parameters
cmdBuff

◆ setEquipment()

void RehtiGui::setEquipment ( std::vector< GameItem >  equipment)

Set contents of player's equipment.

Parameters
equipment

◆ setHp()

void RehtiGui::setHp ( int  hp)

Set hp of player.

Parameters
hp

◆ setInventory()

void RehtiGui::setInventory ( std::vector< GameItem >  inventory)

Set contents of player's inventory.

Parameters
inventory

◆ setSkills()

void RehtiGui::setSkills ( std::vector< Skill >  skills)

Set skills of player.

Parameters
skills

◆ startRender()

void RehtiGui::startRender ( )

Starts rendering ui primitives. Must be called at the top of draw function.

◆ uploadEnded()

void RehtiGui::uploadEnded ( )

◆ uploadFonts()

void RehtiGui::uploadFonts ( VkCommandBuffer  cmdBuffer)

Member Data Documentation

◆ assetCacheM

AssetCache& RehtiGui::assetCacheM
private

◆ descPoolM

VkDescriptorPool RehtiGui::descPoolM
private

◆ dropItemCallbackM

std::function<void(const int id)> RehtiGui::dropItemCallbackM
private

◆ equipmentItemClickCallbackM

std::function<void(const int id)> RehtiGui::equipmentItemClickCallbackM
private

◆ equipmentM

std::vector<GameItem> RehtiGui::equipmentM
private

◆ equipmentMutexM

std::mutex RehtiGui::equipmentMutexM
private

◆ graphicsQueueM

VkQueue RehtiGui::graphicsQueueM
private

◆ guiIconsM

std::unordered_map<int, VkDescriptorSet> RehtiGui::guiIconsM
private

◆ hpM

int RehtiGui::hpM
private

◆ iconSizeM

ImVec2 RehtiGui::iconSizeM = ImVec2(windowWidthM * 0.8 / 4, windowWidthM * 0.8 / 4)
private

◆ inventoryItemClickCallbackM

std::function<void(const int id)> RehtiGui::inventoryItemClickCallbackM
private

◆ inventoryM

std::vector<GameItem> RehtiGui::inventoryM
private

◆ invMutexM

std::mutex RehtiGui::invMutexM
private

◆ logDeviceM

VkDevice RehtiGui::logDeviceM
private

◆ openTabM

UiTab RehtiGui::openTabM
private

◆ pGraphicsObjectManagerM

std::shared_ptr<GraphicsObjectManager> RehtiGui::pGraphicsObjectManagerM
private

◆ samplerM

VkSampler RehtiGui::samplerM
private

◆ skillsM

std::vector<Skill> RehtiGui::skillsM
private

◆ skillsMutexM

std::mutex RehtiGui::skillsMutexM
private

◆ windowHeightM

int RehtiGui::windowHeightM = 500
private

◆ windowWidthM

int RehtiGui::windowWidthM = 300
private

The documentation for this class was generated from the following files: