Exemplo n.º 1
0
OptionsState::OptionsState(std::shared_ptr<GameManager> game)
{
	this->game = game;

	input = true;
	playerName = std::make_pair("Player", false);
	labyrinthWidth = std::make_pair("5", false);
	labyrinthHeight = std::make_pair("5", false);

	background.setTexture(game->textureManager.getTexture("menuBackground"));
	sf::Vector2f position = static_cast<sf::Vector2f>(game->window.getSize());
	view.setSize(position);
	position *= 0.5f;
	view.setCenter(position);

	float inputWidth = 256;
	float inputHeight = 32;

	guiSystem.emplace("inputLabels", Gui(sf::Vector2f(inputWidth, inputHeight), 4, false, game->styleSheets.at("text"),
	{
		std::make_pair("Player name:", "null"),
		std::make_pair("Labyrinth width(0-9): ", "null"),
		std::make_pair("Labyrinth height(0-9):", "null"),
	}));
	guiSystem.at("inputLabels").setPosition(static_cast<float>(game->window.getSize().x) / 2.0f - inputWidth / 2,
		static_cast<float>(game->window.getSize().y) / 2.0f - (static_cast<float>(guiSystem.at("inputLabels").entries.size() + 2) * 0.5f) * inputHeight);
	guiSystem.at("inputLabels").setOrigin(inputWidth / 2, inputHeight / 2);
	guiSystem.at("inputLabels").show();

	guiSystem.emplace("inputEntries", Gui(sf::Vector2f(inputWidth, inputHeight), 4, false, game->styleSheets.at("text"),
	{
		std::make_pair("Player", "player_name_input"),
		std::make_pair("5", "labyrinth_width_input"),
		std::make_pair("5", "labyrinth_height_input"),
	}));
	guiSystem.at("inputEntries").setPosition(static_cast<float>(game->window.getSize().x) / 2.0f + inputWidth / 2,
		static_cast<float>(game->window.getSize().y) / 2.0f - (static_cast<float>(guiSystem.at("inputEntries").entries.size() + 2) * 0.5f) * inputHeight);
	guiSystem.at("inputEntries").setOrigin(inputWidth / 2, inputHeight / 2);
	guiSystem.at("inputEntries").show();

	guiSystem.emplace("buttons", Gui(sf::Vector2f(inputWidth, inputHeight), 4, false, game->styleSheets.at("text2"),
	{
		std::make_pair("Start", "start_game"),
		std::make_pair("Back", "exit_to_menu")
	}));
	guiSystem.at("buttons").setPosition(static_cast<float>(game->window.getSize().x) / 2.0f,
		static_cast<float>(game->window.getSize().y) / 1.5f - (static_cast<float>(guiSystem.at("buttons").entries.size() - 1) * 0.5f) * inputHeight);
	guiSystem.at("buttons").setOrigin(inputWidth / 2, inputHeight / 2);
	guiSystem.at("buttons").show();
}
GameStateEditor::GameStateEditor(Game* game)
{
	this->game = game;
	sf::Vector2f pos = sf::Vector2f(this->game->window.getSize());
	this->guiView.setSize(pos);
	this->gameView.setSize(pos);
	pos *= 0.5f;
	this->guiView.setCenter(pos);
	this->gameView.setCenter(pos);

    this->city = City("city", this->game->tileSize, this->game->tileAtlas);
	this->city.shuffleTiles();

    /* Create gui elements */
	this->guiSystem.emplace("rightClickMenu", Gui(sf::Vector2f(196, 16), 2, false, this->game->stylesheets.at("button"),
		{
			std::make_pair("Flatten $" 			+ this->game->tileAtlas["grass"].getCost(), "grass"),
			std::make_pair("Forest $" 			+ this->game->tileAtlas["forest"].getCost(), "forest" ),
			std::make_pair("Residential Zone $" + this->game->tileAtlas["residential"].getCost(), "residential"),
			std::make_pair("Commercial Zone $" 	+ this->game->tileAtlas["commercial"].getCost(), "commercial"),
			std::make_pair("Industrial Zone $" 	+ this->game->tileAtlas["industrial"].getCost(), "industrial"),
			std::make_pair("Road $" 			+ this->game->tileAtlas["road"].getCost(), "road")
		}));

	this->guiSystem.emplace("selectionCostText", Gui(sf::Vector2f(196, 16), 0, false, this->game->stylesheets.at("text"),
		{ std::make_pair("", "") }));

	this->guiSystem.emplace("infoBar", Gui(sf::Vector2f(this->game->window.getSize().x / 5 , 16), 2, true, this->game->stylesheets.at("button"),
		{ std::make_pair("time", "time"),
		std::make_pair("funds", "funds"),
		std::make_pair("population", "population"),
		std::make_pair("employment", "employment"),
		std::make_pair("current tile", "tile") }));
	this->guiSystem.at("infoBar").setPosition(sf::Vector2f(0, this->game->window.getSize().y - 16));
	this->guiSystem.at("infoBar").show();

	this->zoomLevel = 1.0f;

	/* Centre the camera on the city.map */
	sf::Vector2f centre(this->city.map.width, this->city.map.height*0.5);
	centre *= float(this->city.map.tileSize);
	gameView.setCenter(centre);

    this->selectionStart = sf::Vector2i(0, 0);
    this->selectionEnd = sf::Vector2i(0, 0);

    this->currentTile = &this->game->tileAtlas.at("grass");
	this->actionState = ActionState::NONE;
}
Exemplo n.º 3
0
int main(){
	EngineInit();

	while(true){
		Input();
		Gui();
		Logic();
		Render();
	}
  
	return 0;
}
Exemplo n.º 4
0
 std::vector<Gui> Patch::getGuis() const noexcept
 {
     std::vector<Gui> objects;
     if(isValid())
     {
         t_canvas* cnv = reinterpret_cast<t_canvas*>(m_ptr);
         t_symbol* hsl = gensym("hsl");
         t_symbol* vsl = gensym("vsl");
         t_symbol* tgl = gensym("tgl");
         t_symbol* nbx = gensym("nbx");
         t_symbol* vra = gensym("vradio");
         t_symbol* hra = gensym("hradio");
         for(t_gobj *y = cnv->gl_list; y; y = y->g_next)
         {
             if(y->g_pd->c_name == hsl)
             {
                 objects.push_back(Gui(*this, Gui::Type::HorizontalSlider, reinterpret_cast<void *>(y)));
             }
             else if(y->g_pd->c_name == vsl)
             {
                 objects.push_back(Gui(*this, Gui::Type::VerticalSlider, reinterpret_cast<void *>(y)));
             }
             else if(y->g_pd->c_name == tgl)
             {
                 objects.push_back(Gui(*this, Gui::Type::Toggle, reinterpret_cast<void *>(y)));
             }
             else if(y->g_pd->c_name == nbx)
             {
                 objects.push_back(Gui(*this, Gui::Type::Number, reinterpret_cast<void *>(y)));
             }
             else if(y->g_pd->c_name == vra)
             {
                 objects.push_back(Gui(*this, Gui::Type::VerticalRadio, reinterpret_cast<void *>(y)));
             }
             else if(y->g_pd->c_name == hra)
             {
                 objects.push_back(Gui(*this, Gui::Type::HorizontalRadio, reinterpret_cast<void *>(y)));
             }
         }
     }
     return objects;
 }
Exemplo n.º 5
0









//*************************************************************************************************
//	Constructor
//*************************************************************************************************

Gui::Gui()
{
}


//*************************************************************************************************
//	Preinstantiate object
//*************************************************************************************************

Gui GUI = Gui();