コード例 #1
0
ContinToolButton::ContinToolButton(QWidget *parent) :
    QToolButton(parent)
{
    mTimer = new QTimer(this);
    setInterval(50);

    connect(mTimer,
            SIGNAL(timeout()),
            this,
            SIGNAL(clickUpdate()));
}
コード例 #2
0
ファイル: main.cpp プロジェクト: Kraetyz/Luaprojekt
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
	MSG msg = { 0 };
	window = InitWindow(hInstance); //1. Skapa fönster


	AllocConsole();

	HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);
	int hCrt = _open_osfhandle((long)handle_out, _O_TEXT);
	FILE* hf_out = _fdopen(hCrt, "w");
	setvbuf(hf_out, NULL, _IONBF, 1);
	*stdout = *hf_out;

	HANDLE handle_in = GetStdHandle(STD_INPUT_HANDLE);
	hCrt = _open_osfhandle((long)handle_in, _O_TEXT);
	FILE* hf_in = _fdopen(hCrt, "r");
	setvbuf(hf_in, NULL, _IONBF, 128);
	*stdin = *hf_in;

	if (window)
	{
		HDC hDC = GetDC(window);
		HGLRC hRC = CreateOpenGLContext(window); //2. Skapa och koppla OpenGL context

		glewInit(); //3. Initiera The OpenGL Extension Wrangler Library (GLEW)
		//glEnable(GL_CULL_FACE);

		SetViewport(); //4. Sätt viewport

		ShowWindow(window, nCmdShow);

		state = new Menu();

		buttonState = luaL_newstate();
		luaL_openlibs(buttonState);

		if (luaL_loadfile(buttonState, "Error.lua") || lua_pcall(buttonState, 0, 0, 0))
		{
			std::cout << "Error handler failed" << std::endl;
			std::cerr << lua_tostring(buttonState, -1) << std::endl;
			lua_pop(buttonState, 1);
		}
		lua_getglobal(buttonState, "ErrorHandler");
		int luaErrorHandlerPos = lua_gettop(buttonState);

		registerLuaFuncs();

		if (luaL_loadfile(buttonState, "menuButtons.txt") || lua_pcall(buttonState, 0, 0, luaErrorHandlerPos))
		{
			std::cout << "erroooor" << std::endl;
			std::cout << lua_tostring(buttonState, -1) << std::endl;
			lua_pop(buttonState, 1);
		}
		setupButtons();
		lua_pop(buttonState, 1);

		while (WM_QUIT != msg.message)
		{
			if (msg.message == WM_LBUTTONDOWN)
				clickUpdate();
			if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}

			else
			{
				Update(); //9. Rendera
				SwapBuffers(hDC); //10. Växla front- och back-buffer
			}
		}

		wglMakeCurrent(NULL, NULL);
		ReleaseDC(window, hDC);
		wglDeleteContext(hRC);
		DestroyWindow(window);
	}

	lua_close(buttonState);

	return (int)msg.wParam;
}