- No se, molts canvis i coses
This commit is contained in:
68
source/menu.cpp
Normal file
68
source/menu.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#include "menu.h"
|
||||
#include "japi/input.h"
|
||||
#include "japi/draw.h"
|
||||
#include "japi/font.h"
|
||||
|
||||
namespace menu
|
||||
{
|
||||
int x1, x2, m;
|
||||
int menu_shown = -1;
|
||||
|
||||
void start()
|
||||
{
|
||||
draw::setColor(0xff3c3c3c);
|
||||
draw::fillrect(0,0,draw::getWindowSize().x,24);
|
||||
x1=0; x2=0; m=-1;
|
||||
}
|
||||
|
||||
bool option(const char* label)
|
||||
{
|
||||
m++;
|
||||
x1 = x2 + 8; x2 = x1 + font::len(label)+8;
|
||||
int mx = input::mouseX();
|
||||
int my = input::mouseY();
|
||||
if (mx>=x1 && my>=0 && mx<x2 && my<24) {
|
||||
draw::setColor(0xff464646);
|
||||
draw::fillrect(x1-8, 0, x2-x1+8, 24);
|
||||
if (input::mouseClk(input::mouse::button::left)) {
|
||||
input::mouseDiscard();
|
||||
menu_shown = (menu_shown == m) ? -1 : m;
|
||||
} else {
|
||||
if (menu_shown != -1) menu_shown = m;
|
||||
}
|
||||
}
|
||||
font::print(label, x1, 9);
|
||||
|
||||
return menu_shown==m;
|
||||
}
|
||||
|
||||
namespace popup
|
||||
{
|
||||
void start()
|
||||
{
|
||||
draw::setColor(0xff3c3c3c);
|
||||
draw::fillrect(x1-8,24,200,200);
|
||||
|
||||
int mx = input::mouseX();
|
||||
int my = input::mouseY();
|
||||
if (mx>=x1-8 && my>=24 && mx<x1-8+200 && my<24+200) {
|
||||
if (input::mouseClk(input::mouse::button::left)) {
|
||||
input::mouseDiscard();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool option(const char* label)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void end()
|
||||
{
|
||||
if (input::mouseClk(input::mouse::button::left)) {
|
||||
menu_shown = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user