Esempio n. 1
0
bool TextboxParent::UpdateTextboxes()
{
	if (textboxes.size() == 0)
		return false;
	unsigned int index = textboxes.size() - 1;
	Textbox* active = textboxes[index];
	if (!active || active->SetToClose())
		return false;
	active->Update();
	for (unsigned int i = 0; i < textboxes.size(); i++)
	{
		if (!textboxes[i])
			continue;
		if (textboxes[i]->SetToClose())
		{
			if (textboxes[i]->DeleteOnClose())
			{
				delete textboxes[i];
				textboxes[i] = 0;
			}
			else
				textboxes[i]->CancelClose();
			textboxes.erase(textboxes.begin() + i--);
		}
	}
	return true;
}
Esempio n. 2
0
int main()
{
//	TestScenario test;

//	test.scenarioEvents();

	sf::RenderWindow* window = new sf::RenderWindow(sf::VideoMode(1980, 1080), "SFML works!", sf::Style::Fullscreen);
//	sf::RenderWindow* window = new sf::RenderWindow(sf::VideoMode(1000, 580), "SFML works!");

//	Game game;

//	game.GameLoop();
	
	
	sf::CircleShape shape(100.f);
	shape.setFillColor(sf::Color::Green);

	Button exitButton("Exit", 840, 700);
	Textbox testbox;
	sf::Clock time;
	sf::Vector2i mousePos;
	while (window->isOpen())
	{
		sf::Event event;

		
		
		while (testbox.Update(time.restart().asSeconds()))
		{
			while (window->pollEvent(event))
			{
				mousePos = sf::Mouse::getPosition(*window);
				if (exitButton.ButtonFunction(mousePos) || event.type == sf::Event::Closed || sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
				{
					window->close();
					return 0;
				}
			}


			window->clear();
			window->draw(shape);
			testbox.Draw(window);
			exitButton.Draw(window); 
			window->display();

		}
		testbox.ChangeText("Well it worked well \nThat's really nice to know :) \n едцедцедц");

		while (testbox.Update(time.restart().asSeconds()))
		{
			while (window->pollEvent(event))
			{
				mousePos = sf::Mouse::getPosition(*window);
				if (exitButton.ButtonFunction(mousePos) || event.type == sf::Event::Closed || sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
				{
					window->close();
					return 0;
				}
			}


			window->clear(sf::Color(222,222,222));
			window->draw(shape);
			testbox.Draw(window);
			exitButton.Draw(window);
			window->display();

		}
		testbox.ChangeText("Program gonna loop now soo that's it folks!");
	}
	
//	game.Delete();
	return 0;
}