#include <sfml\graphics.hpp>
#include <iostream>
#include <string>
#include <regex>
using namespace sf;
using namespace std;
int main () {
const int x = 300; const int y = 375;//global x & y
string iNbr;
//Window:
RenderWindow w;
w.create(VideoMode(x, y), "Dice Roller", Style::Close && Style::Titlebar);
//Text:
Font arial;
arial.loadFromFile("arial.ttf");
Text t;
t.setFont(arial);
t.setCharacterSize(18);
t.setColor(Color(50, 50, 50));
t.setPosition(x/30, y/30);
t.setStyle(Text::Style::Bold);
t.setString("INSIRA O NÚMERO DE DADOS:");
Text tShadow;
tShadow.setFont(arial);
tShadow.setCharacterSize(18);
tShadow.setColor(Color(150, 150, 150));
tShadow.setPosition(x/30, y/27.3);
tShadow.setStyle(Text::Style::Bold);
tShadow.setString("INSIRA O NÚMERO DE DADOS:");
Text n;
n.setFont(arial);
n.setCharacterSize(120);
n.setColor(Color(150, 150, 150));
n.setPosition(x*2/7, y/12);
n.setStyle(Text::Style::Bold);
//Linha para escrever:
RectangleShape line (Vector2f(x/2, 3));
line.setPosition(x/4, y*4/9);
line.setFillColor(Color(50, 50, 50));
//--------------------------------------------------------
//Program:
while (w.isOpen()) {
Event e;
while (w.pollEvent(e)){
switch (e.type) {
case Event::Closed:
w.close();
break;
case Event::TextEntered: {
regex isI ("[[digit]]+");//regex deffinition
if (e.text.unicode == '\b'){ //backsapace
if (iNbr.size() > 0)
{
iNbr.erase(iNbr.size() -1);
n.setString(iNbr);
}
} else if (regex_match(iNbr, isI)) { //regex_match
iNbr += e.text.unicode;
n.setString(iNbr);
}
break;}
default:
break;
}
w.clear(Color(230, 225, 225));
w.draw(tShadow);
w.draw(t);
w.draw(line);
w.draw(n);
w.display();
}//pollEvent
}//w.isOpen
}//main