]> git.lizzy.rs Git - dragonblocks-bedrock.git/blob - src/inventory.cpp
Some structure Changes
[dragonblocks-bedrock.git] / src / inventory.cpp
1 #include "node.h"
2 #include "inventory.h" 
3 Inventory::Inventory(){
4         count = 0;
5         selected = 0;
6         for(int i = 0; i < Node::count; i++){
7                 if(! Node::getNodeById(i) -> hidden){
8                         list[count] = Node::getNodeById(i);
9                         count++;
10                 }
11         }
12 }
13 Node *Inventory::getSlot(int nr){
14         if(nr >= 0 && nr < count)
15                 return list[nr];
16         return NULL; 
17 }
18 void Inventory::select(int nr){
19         if(nr >= 0 && nr < count)
20                 selected = nr;
21 }
22 void Inventory::selectUp(){
23         select(selected - 1);
24 }
25 void Inventory::selectDown(){
26         select(selected + 1);
27 }
28 Node *Inventory::getSelectedSlot(){
29         return list[selected];
30 }