Example #1
0
void eventMenu()
{
    SDL_Event event;
    while (SDL_PollEvent(&event))
    {
        inputButton(&choixJeu,&event);
        inputButton(&choixStat,&event);
        inputButton(&choixQuit,&event);

        switch(event.type)
        {
        case SDL_QUIT:
            printf("eventLogin: event quit received\n");
            changeStep(end);
            break;
        case SDL_KEYUP:
            break;
        }
        if(event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_LEFT)
            printf("%d - %d\n",event.button.x,event.button.y);
    }
}
Example #2
0
int KeyboardOptions::run()
{
	int retVal = 0;

	display();
	
	inputButton("up", "Up: ", gfx::getScreenWidth() / 10, gfx::getScreenHeight() / 16 + gfx::getScreenHeight() / 32 * 0, gfx::getScreenWidth() / 5, gfx::getScreenHeight() / 20, "button.png", "hover.png", "input.png");
	inputButton("down", "Down: ", gfx::getScreenWidth() / 10, gfx::getScreenHeight() / 16 + gfx::getScreenHeight() / 32 * 2, gfx::getScreenWidth() / 5, gfx::getScreenHeight() / 20, "button.png", "hover.png", "input.png");
	inputButton("left", "Left: ", gfx::getScreenWidth() / 10, gfx::getScreenHeight() / 16 + gfx::getScreenHeight() / 32 * 4, gfx::getScreenWidth() / 5, gfx::getScreenHeight() / 20, "button.png", "hover.png", "input.png");
	inputButton("right", "Right: ", gfx::getScreenWidth() / 10, gfx::getScreenHeight() / 16 + gfx::getScreenHeight() / 32 * 6, gfx::getScreenWidth() / 5, gfx::getScreenHeight() / 20, "button.png", "hover.png", "input.png");
	inputButton("fire_1", "Fire 1: ", gfx::getScreenWidth() / 10, gfx::getScreenHeight() / 16 + gfx::getScreenHeight() / 32 * 8, gfx::getScreenWidth() / 5, gfx::getScreenHeight() / 20, "button.png", "hover.png", "input.png");
	inputButton("fire_2", "Fire 2: ", gfx::getScreenWidth() / 10, gfx::getScreenHeight() / 16 + gfx::getScreenHeight() / 32 * 10, gfx::getScreenWidth() / 5, gfx::getScreenHeight() / 20, "button.png", "hover.png", "input.png");
	inputButton("rotate_left", "Rotate left: ", gfx::getScreenWidth() / 10, gfx::getScreenHeight() / 16 + gfx::getScreenHeight() / 32 * 12, gfx::getScreenWidth() / 5, gfx::getScreenHeight() / 20, "button.png", "hover.png", "input.png");
	inputButton("rotate_right", "Rotate right: ", gfx::getScreenWidth() / 10, gfx::getScreenHeight() / 16 + gfx::getScreenHeight() / 32 * 14, gfx::getScreenWidth() / 5, gfx::getScreenHeight() / 20, "button.png", "hover.png", "input.png");
	
	if (input::button("Back", gfx::getScreenWidth() / 10, gfx::getScreenHeight() / 16 * 13, gfx::getScreenWidth() / 5, gfx::getScreenHeight() / 10, "button_creepy.png", "hover_creepy.png"))
	{
		nullifyBools();
		retVal = OPTIONS;
	}
	else if (input::keyHeld(SDLK_ESCAPE))
	{
		nullifyBools();
		retVal = OPTIONS;
	}
	else
	{
		for (auto i = m_KeyBools.begin(); i != m_KeyBools.end(); i++)
		{
			if (i->second && input::getKeyPress())
			{
				bool compared = false;

				for (auto j = keyboard::m_Keys.begin(); j != keyboard::m_Keys.end(); j++)
				{
					if (input::getKeyPress() == j->second)
					{
						compared = true;

						unsigned short temp = keyboard::m_Keys[j->first];
						keyboard::m_Keys[j->first] = keyboard::m_Keys[i->first];
						keyboard::m_Keys[i->first] = temp;

						break;
					}
				}
				if (!compared)
				{
					keyboard::m_Keys[i->first] = input::getKeyPress();
				}
				i->second = false;
				save(ms_SavePath);
			}
		}

		if (input::buttonHeld(SDL_BUTTON_LEFT))
		{
			nullifyBools();
		}
	}
	return retVal;
}