- [NEW] Ja se mostren els items en el treeview
This commit is contained in:
@@ -86,8 +86,15 @@ bool loop()
|
||||
loadRoom(r);
|
||||
} else {
|
||||
auto enemies = room.at("enemies").as_seq();
|
||||
if (!enemies.empty()) treeview::option("ENEMIES:", 1);
|
||||
for (auto enemy : enemies) {
|
||||
treeview::option(enemy["animation"].get_value<std::string>().c_str(), 1);
|
||||
treeview::option(enemy["animation"].get_value<std::string>().c_str(), 2);
|
||||
}
|
||||
auto items = room.at("items").as_seq();
|
||||
if (!items.empty()) treeview::option("ITEMS:", 1);
|
||||
char tmp[5];
|
||||
for (int i=0; i<items.size(); ++i) {
|
||||
treeview::option(SDL_itoa(i, tmp, 10), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ namespace treeview
|
||||
{
|
||||
int width = 200;
|
||||
int scroll = 0;
|
||||
int current[2] = {-1, -1};
|
||||
int selected[2] = {-1, -1};
|
||||
int current[3] = {-1, -1};
|
||||
int selected[3] = {-1, -1};
|
||||
int line = 0;
|
||||
int element = 0;
|
||||
int max_elements = 0;
|
||||
@@ -18,7 +18,7 @@ namespace treeview
|
||||
draw::setClip(0,48,treeview::width, draw::getWindowSize().y-48);
|
||||
draw::setColor(0xff181818);
|
||||
draw::fillrect(0,48,treeview::width, draw::getWindowSize().y-48);
|
||||
current[0] = current[1] = line = element = 0;
|
||||
current[0] = current[1] = current[2] = line = element = 0;
|
||||
|
||||
max_elements = (draw::getWindowSize().y-48) / 24;
|
||||
int mx = input::mouseX();
|
||||
@@ -36,17 +36,19 @@ namespace treeview
|
||||
int mx = input::mouseX();
|
||||
int my = input::mouseY();
|
||||
const int opt_y = (48+line*24);
|
||||
if (mx>=0 && my>=opt_y && mx<treeview::width && my<opt_y+24) {
|
||||
if (input::mouseClk(input::mouse::button::left)) {
|
||||
input::mouseDiscard();
|
||||
selected[level] = current[level];
|
||||
if (level<1) selected[level+1] = -1;
|
||||
if (level!=1) {
|
||||
if (mx>=0 && my>=opt_y && mx<treeview::width && my<opt_y+24) {
|
||||
if (input::mouseClk(input::mouse::button::left)) {
|
||||
input::mouseDiscard();
|
||||
selected[level] = current[level];
|
||||
if (level==0) selected[2] = -1;
|
||||
}
|
||||
draw::setColor(selected[level]==current[level] ? 0xff37373d : 0xff2a2d2e);
|
||||
draw::fillrect(0, opt_y, treeview::width, 24);
|
||||
} else if (selected[level] == current[level]) {
|
||||
draw::setColor(0xff37373d);
|
||||
draw::fillrect(0, opt_y, treeview::width, 24);
|
||||
}
|
||||
draw::setColor(selected[level]==current[level] ? 0xff37373d : 0xff2a2d2e);
|
||||
draw::fillrect(0, opt_y, treeview::width, 24);
|
||||
} else if (selected[level] == current[level]) {
|
||||
draw::setColor(0xff37373d);
|
||||
draw::fillrect(0, opt_y, treeview::width, 24);
|
||||
}
|
||||
font::print(label, 8+16*level, opt_y+8);
|
||||
line++;
|
||||
|
||||
Reference in New Issue
Block a user