Exemple #1
0
void launchwebpage(char *webpagename)
  {
#ifdef WINDOWS
  SDL_WM_IconifyWindow();
  ShellExecute(NULL,L"open",(LPTSTR)webpagename,L"",L"c:\\",SW_SHOWNORMAL);
#endif
#ifdef MAC
  /*
  OSStatus err;
  ICInstance inst;
  long length,start,end;

  SDL_WM_IconifyWindow();

  err=ICStart(&inst,'Gish');
  if (err==noErr)
    {
    length=strlen(webpagename);
    start=0;
    end=length;
    ICLaunchURL(inst,NULL,webpagename,length,&start,&end);
    }
  ICStop(inst);
  */
#endif
#if defined(LINUX) || defined(__FreeBSD__)
  char command[100] = "xdg-open http://";
  strcat(command, webpagename);
  SDL_WM_IconifyWindow();
  system((const char*)command);
#endif
  }
Exemple #2
0
void launchwebpage(char *webpagename)
  {
#ifdef WINDOZE
  SDL_WM_IconifyWindow();
  ShellExecute(NULL,"open",webpagename,"","c:\\",SW_SHOWNORMAL);
#endif
#ifdef THINKSTUPID
  /*
  OSStatus err;
  ICInstance inst;
  long length,start,end;

  SDL_WM_IconifyWindow();

  err=ICStart(&inst,'Gish');
  if (err==noErr)
    {
    length=strlen(webpagename);
    start=0;
    end=length;
    ICLaunchURL(inst,NULL,webpagename,length,&start,&end);
    }
  ICStop(inst);
  */
#endif
  }
Exemple #3
0
/**
 * @return whether window initialization succeeded
 * @param title char* string with window title
 *
 * Initializes the game window
 */
bool SpringApp::InitWindow(const char* title)
{
	unsigned int sdlInitFlags = SDL_INIT_VIDEO | SDL_INIT_TIMER;
#ifdef WIN32
	// the crash reporter should be catching the errors
	sdlInitFlags |= SDL_INIT_NOPARACHUTE;
#endif
	if ((SDL_Init(sdlInitFlags) == -1)) {
		LOG_L(L_FATAL, "Could not initialize SDL: %s", SDL_GetError());
		return false;
	}

	PrintAvailableResolutions();

	WindowManagerHelper::SetCaption(title);

	if (!SetSDLVideoMode()) {
		LOG_L(L_FATAL, "Failed to set SDL video mode: %s", SDL_GetError());
		return false;
	}

	RestoreWindowPosition();
	if (cmdline->IsSet("minimise")) {
		globalRendering->active = false;
		SDL_WM_IconifyWindow();
	}

	glClearColor(0.0f,0.0f,0.0f,0.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	SDL_GL_SwapBuffers();

	return true;
}
Exemple #4
0
void VID_Minimize (void)
{
#if SDL_VERSION_ATLEAST(2,0,0)
	SDL_MinimizeWindow(cls.window);
#else
	SDL_WM_IconifyWindow();
#endif
}
Exemple #5
0
	void ProcessEvent(Event &inEvent)
	{
		#ifdef HX_MACOS
		if (inEvent.type == etKeyUp && (inEvent.flags & efCommandDown))
		{
			switch (inEvent.code)
			{
				case SDLK_q:
				case SDLK_w:
					inEvent.type = etQuit;
					break;
				case SDLK_m:
					SDL_WM_IconifyWindow();
					return;
			}
		}
		#endif
		
		#if defined(HX_WINDOWS) || defined(HX_LINUX)
		if (inEvent.type == etKeyUp && (inEvent.flags & efAltDown) && inEvent.value == keyF4)
		{
			inEvent.type = etQuit;
		}
		#endif
		
		#if defined(WEBOS) || defined(BLACKBERRY)
		if (inEvent.type == etMouseMove || inEvent.type == etMouseDown || inEvent.type == etMouseUp)
		{
			if (mSingleTouchID == NO_TOUCH || inEvent.value == mSingleTouchID || !mMultiTouch)
			inEvent.flags |= efPrimaryTouch;
			
			if (mMultiTouch)
			{
				switch(inEvent.type)
				{
					case etMouseDown: inEvent.type = etTouchBegin; break;
					case etMouseUp: inEvent.type = etTouchEnd; break;
					case etMouseMove: inEvent.type = etTouchMove; break;
				}
				
				if (inEvent.type == etTouchBegin)
				{	
					mDownX = inEvent.x;
					mDownY = inEvent.y;	
				}
				
				if (inEvent.type == etTouchEnd)
				{	
					if (mSingleTouchID == inEvent.value)
						mSingleTouchID = NO_TOUCH;
				}
			}
		}
		#endif
		
		HandleEvent(inEvent);
	}
Exemple #6
0
static PyObject*
_sdl_wmiconify (PyObject *self)
{
    ASSERT_VIDEO_SURFACE_SET(NULL);

    if (!SDL_WM_IconifyWindow ())
        Py_RETURN_FALSE;
    Py_RETURN_TRUE;
}
void OpenGLSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
	switch (f) {
	case OSystem::kFeatureIconifyWindow:
		if (enable)
			SDL_WM_IconifyWindow();
		break;
	default:
		OpenGLGraphicsManager::setFeatureState(f, enable);
	}
}
/*
 * @brief Minimize the game so that user is back at the desktop
 */
void GLimp_Minimize(void)
{
#ifdef __APPLE__
	// SDL_WM_IconifyWindow doesn't work on fullscreen windows on Mac
	if (r_fullscreen->integer)
	{
		ri.Cvar_Set("r_fullscreen", "0");
	}
#endif
	SDL_WM_IconifyWindow();
}
Exemple #9
0
/**
 * Shortcut to 'Boss' key, ie minmize Window and switch to another application
 */
static void ShortCut_BossKey(void)
{
    /* If we are in full-screen, then return to a window */
    Screen_ReturnFromFullScreen();

    if (bGrabMouse)
    {
        SDL_WM_GrabInput(SDL_GRAB_OFF);
        bGrabMouse = false;
    }
    Main_PauseEmulation(true);

    /* Minimize Window and give up processing to next one! */
#if WITH_SDL2
    SDL_MinimizeWindow(sdlWindow);
#else
    SDL_WM_IconifyWindow();
#endif
}
Exemple #10
0
/**
 * @brief Open URL in system browser
 * @param[in] url    URL to open
 * @param     doexit Quit from game after opening URL
 */
void Sys_OpenURL(const char *url, qboolean doexit)
{
#ifndef DEDICATED
#ifndef __AROS__
	char fn[MAX_OSPATH];
	char cmdline[MAX_CMD];
#endif

	static qboolean doexit_spamguard = qfalse;

	if (doexit_spamguard)
	{
		Com_DPrintf("Sys_OpenURL: already in a doexit sequence, ignoring %s\n", url);
		return;
	}

	Com_Printf("Open URL: %s\n", url);

#ifndef __AROS__
	Com_DPrintf("URL script: %s\n", fn);

#ifdef __APPLE__
	Com_sprintf(cmdline, MAX_CMD, "open '%s' &", url);
#else
	Com_sprintf(cmdline, MAX_CMD, "xdg-open '%s' &", url);
#endif

	Sys_StartProcess(cmdline, doexit);
#else
	if ((OpenURLBase = OpenLibrary("openurl.library", 1)))
	{
		URL_Open(url, TAG_DONE);
		CloseLibrary(OpenURLBase);
	}
#endif

	SDL_WM_IconifyWindow();
#endif
}
Exemple #11
0
void OSystem_SDL::setFeatureState(Feature f, bool enable) {
	switch (f) {
	case kFeatureFullscreenMode:
		setFullscreenMode(enable);
		break;
	case kFeatureAspectRatioCorrection:
		setAspectRatioCorrection(enable);
		break;
	case kFeatureAutoComputeDirtyRects:
		if (enable)
			_modeFlags |= DF_WANT_RECT_OPTIM;
		else
			_modeFlags &= ~DF_WANT_RECT_OPTIM;
		break;
	case kFeatureIconifyWindow:
		if (enable)
			SDL_WM_IconifyWindow();
		break;
	default:
		break;
	}
}
Exemple #12
0
/*
==================
Sys_OpenURL
==================
*/
void Sys_OpenURL(const char *url, qboolean doexit)
{
#ifndef DEDICATED
	HWND wnd;

	static qboolean doexit_spamguard = qfalse;

	if (doexit_spamguard)
	{
		Com_DPrintf("Sys_OpenURL: already in a doexit sequence, ignoring %s\n", url);
		return;
	}

	Com_Printf("Open URL: %s\n", url);

	if (!ShellExecute(NULL, "open", url, NULL, NULL, SW_RESTORE))
	{
		// couldn't start it, popup error box
		Com_Error(ERR_DROP, "Could not open url: '%s' ", url);
		return;
	}

	wnd = GetForegroundWindow();

	if (wnd)
	{
		ShowWindow(wnd, SW_MAXIMIZE);
	}

	if (doexit)
	{
		// show_bug.cgi?id=612
		doexit_spamguard = qtrue;
		Cbuf_ExecuteText(EXEC_APPEND, "quit\n");
	}

	SDL_WM_IconifyWindow();
#endif
}
void OpenGLSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
	switch (f) {
	case OSystem::kFeatureFullscreenMode:
		assert(getTransactionMode() != kTransactionNone);
		_wantsFullScreen = enable;
		// When we switch to windowed mode we will ignore resize events. This
		// avoids bad resizes to the (former) fullscreen resolution.
		if (!enable) {
			_ignoreResizeEvents = 10;
		}
		break;

	case OSystem::kFeatureIconifyWindow:
		if (enable) {
			SDL_WM_IconifyWindow();
		}
		break;

	default:
		OpenGLGraphicsManager::setFeatureState(f, enable);
	}
}
Exemple #14
0
/*
===============
GLimp_Minimize

Minimize the game so that user is back at the desktop
===============
*/
void GLimp_Minimize(void)
{
	SDL_WM_IconifyWindow();
}
Exemple #15
0
/// \brief Main program function
///
/// This function does very little on its own. It manages some output to
/// player's console, directs subsystems to initialize themselves and makes
/// choice of rendering engine. Then it runs the main game loop, processing
/// events and sending them further into the game.
int main(int argc, char *argv[])
{

    #if !defined(WIN32) && !defined(__APPLE__)
    #ifdef _GLIBCXX_DEBUG
	/*#if __WORDSIZE != 64*/

    /* Install our signal handler */
    struct sigaction sa;

    sa.sa_sigaction = /*(void *)*/crashhndl;
    sigemptyset (&sa.sa_mask);
    sa.sa_flags = SA_RESTART | SA_SIGINFO;

    sigaction(SIGSEGV, &sa, NULL);
    sigaction(SIGFPE, &sa, NULL);
    /*#endif*/
	#endif
    #endif



#ifdef WIN32
	WORD wVersionRequested;
	WSADATA wsaData;
	wVersionRequested = MAKEWORD( 2, 2 );

	if(WSAStartup(wVersionRequested, &wsaData) != 0){
		DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Winsock startup failed!!");
		return -1;
	}

	if((LOBYTE(wsaData.wVersion) != 2) || (HIBYTE(wsaData.wVersion) != 2)){
		WSACleanup( );
		DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "No Winsock 2.2 found!");
		return -1;
	}

#endif

	//setenv("SDL_VIDEODRIVER", "aalib", 0);
	//setenv("AAOPTS","-width 200 -height 70 -dim -reverse -bold -normal -boldfont  -eight -extended ",0);
	//setenv("AAFont","-*-fixed-bold-*-*-*-*-55-*-*-*-*-*-*",0);
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, PRODUCTLONG "\n");
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "================================\n");
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "version " PRODUCTVERSION "\n");
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "compiled on " __DATE__ " " __TIME__ "\n");
#ifdef BUILDVERSION
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "build %s\n", BUILDVERSION);
#endif
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, " This is free software: you are free to change and redistribute it.\n"
		" There is NO WARRANTY, to the extent permitted by law. \n"
		" Review LICENSE in " PRODUCTSHORT " distribution for details.\n");


    yatc_fopen_init(argv[0]);



	options.Load();
	MAXFPS = options.maxfps;



#if HAVE_LIBINTL_H
    // set up i18n stuff
    if(options.lang.size())
    {
        std::string l("LANG=");
        l+=options.lang;
        putenv((char*)l.c_str());
    }
    setlocale( LC_ALL, "");//options.lang.c_str() );
    setlocale( LC_NUMERIC, "C");
    #if !BAZEL_BUILD
    bindtextdomain( "yatc", "./translations" );
    #else
    bindtextdomain( "yatc", (yatc_path_to_binary() + "yatc.runfiles/yatc/translations").c_str());
    #endif
    textdomain( "yatc" );
    bind_textdomain_codeset("yatc","windows-1252");
#endif

	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Checking graphics files existence...\n");
	checkFiles();
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "All graphics files were found.\n");


	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Initializing windowing...\n");

	if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0){
		std::stringstream out;
		out << "Couldn't initialize SDL: " << SDL_GetError() << std::endl;
		DEBUGPRINT(DEBUGPRINT_ERROR, DEBUGPRINT_LEVEL_OBLIGATORY, out.str().c_str());

		NativeGUIError(out.str().c_str(), PRODUCTSHORT " Fatal Error");
		exit(1);
	}

    // We are no longer dependant on .dat for this!
    // ivucica asks: nate, not dependant for what? why is this removed?
    // because of .ico? disagree.
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Loading data...\n");
	if(!Objects::getInstance()->loadDat("Tibia.dat")){
		DEBUGPRINT(DEBUGPRINT_ERROR, DEBUGPRINT_LEVEL_OBLIGATORY, gettext("Loading data file failed!"));
		std::string forreplace = gettext("Loading the data file '$$FILENAME$$' has failed.\nPlease place '$$FILENAME$$' in the same folder as $$PRODUCTSHORT$$.\n");
		forreplace = str_replace("$$FILENAME$$", "Tibia.dat", forreplace);
		forreplace = str_replace("$$PRODUCTSHORT$$", PRODUCTSHORT, forreplace);
		NativeGUIError(forreplace.c_str(), str_replace("$$PRODUCTSHORT$$", PRODUCTSHORT, gettext("$$PRODUCTSHORT$$ Fatal Error")).c_str());
		exit(1);
	}


	setIcon(); // must be called prior to first call to SDL_SetVideoMode() (currently done in engine)

	SDL_EnableKeyRepeat(200, 50);
	SDL_EnableUNICODE(1);

	try{
	    g_engine = NULL; // set to null, in case anything that happens inside engine constructor wants to know we're just constructing
		switch(options.engine){
			#ifdef USE_OPENGL
			case ENGINE_OPENGL:
				g_engine = new EngineGL;
				break;
			#endif

			default:
				DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_WARNING, "Unknown engine was selected. Falling back to SDL.");
				options.engine = ENGINE_SDL;
			case ENGINE_SDL:
				g_engine = new EngineSDL;
				break;
		}

		if(!g_engine->isSupported()){
			DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_WARNING, "The selected graphics engine is not supported. Falling back to SDL.");
			delete g_engine;
			g_engine = NULL; // set to null, in case anything that happens inside engine constructor wants to know we're just constructing
			options.engine = ENGINE_SDL;
			g_engine = new EngineSDL;
		}

		// NOTE (nfries88): Make sure the window is sized as per the options
		int w = MAX(options.w, 656);
		int h = MAX(options.h, 352+options.consoleh);
		g_engine->doResize(w, h);


		DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Loading skin...\n");
		g_skin.loadSkin();
		DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Skin has been loaded\n");


		DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Constructing gamemode...\n");
		resetDefaultCursor();
		if (argc == 1)
		{
		    g_game = new GM_MainMenu();
            //g_game = new GM_Debug(); // ivucica: this is for testing -- choice should be a cmd line option
		} else
		{
		    g_game = new GM_MainMenu();
            ProtocolGame* protocol = ProtocolConfig::createGameProtocol(854,"","","",false);
            g_connection = new ConnectionReplay(argv[1], protocol);
            if (argc==3)
            {
                sscanf(argv[2], "%f", &g_replayspeed);
            }

		}


        DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Initializing framerate manager...\n");
        SDL_initFramerate(&g_fpsmgr);
        SDL_setFramerate(&g_fpsmgr,MAXFPS);


		DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Running\n");
        g_running = true;

        #ifdef WIN32
        SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
        #endif

		SDL_Event event;
		while(g_running){

            //g_engine->fpsMutexLock();

            //int beginticks = SDL_GetTicks();
            g_engine->performFpsCalc();

			//first process sdl events
			while(SDL_PollEvent(&event)){
				switch (event.type){
					case SDL_VIDEORESIZE:
						g_engine->doResize(event.resize.w, event.resize.h);
						g_game->doResize(event.resize.w, event.resize.h);
						break;

					case SDL_QUIT:
						g_game->onExitAttempt();
						break;

					case SDL_KEYDOWN:
						onKeyDown(event);
						break;
                    case SDL_KEYUP:
                        if((event.key.keysym.sym == SDLK_LSUPER)
                          || (event.key.keysym.sym == SDLK_RSUPER))
                            superkey_state = false;
                        break;

					case SDL_MOUSEBUTTONUP:
					case SDL_MOUSEBUTTONDOWN:
						#ifdef WINCE
						if (ptrx < 5 && ptry < 5)
							SDL_WM_IconifyWindow(); // appears to crash the application?! ah nevermind
						#endif
						g_game->mouseEvent(event);
						break;

					case SDL_MOUSEMOTION:
						ptrx = event.motion.x;
						ptry = event.motion.y;
						g_game->mouseEvent(event);
						break;
					default:
						break;
				}
			}
			//update current frame time
			g_frameDiff = SDL_GetTicks() - g_frameTime;
			g_frameTime = SDL_GetTicks();


            if (MAXFPS) {
                SDL_framerateDelay(&g_fpsmgr);

            }

			//check connection
			if(g_connection){
				g_connection->executeNetwork();
			}

            if (!(SDL_GetAppState() & SDL_APPACTIVE)) {// if the application is minimized
                #ifdef WIN32
                Sleep(100); // sleep a while, and don't paint
                #else
                usleep(100 * 1000);
                #endif
            } else { //otherwise update scene
                g_game->updateScene();
                g_engine->Flip();
            }
			g_frames ++;


			//g_engine->fpsMutexUnlock();

		}
	}
	catch(std::string errtext){
		DEBUGPRINT(DEBUGPRINT_ERROR, DEBUGPRINT_LEVEL_OBLIGATORY, "%s", errtext.c_str());
	}

	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Game over\n");

	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Terminating protocol connection from main...\n");
	delete g_connection;
	g_connection = NULL;
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Destroying map...\n");
	Map::getInstance().clear();
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Destroying creature cache...\n");
	Creatures::getInstance().clear();
	Creatures::destroyInstance();
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Destroying inventory...\n");
	Inventory::getInstance().clear();

	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Unloading data...\n");
	Objects::getInstance()->unloadDat();
    Objects::destroyInstance();

    DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Unloading skin...\n");
	g_skin.unloadSkin();


	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Saving options...\n");
	options.Save();
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Finishing engine...\n");
	delete g_engine;
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Ending game...\n");
	delete g_game;
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Shutting down SDL...\n");
	SDL_Quit();

#ifdef WIN32
	WSACleanup();
#endif

	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Thanks for playing!\n");

	return 0;
}
Exemple #16
0
/**
 * @brief Initializes the SpringApp instance
 * @return whether initialization was successful
 */
bool SpringApp::Initialize ()
{
	logOutput.SetMirrorToStdout(!!configHandler.GetInt("StdoutDebug",0));

	// Initialize class system
	creg::ClassBinder::InitializeClasses ();

	// Initialize crash reporting
#ifdef _MSC_VER
	Install( (LPGETLOGFILE) crashCallback, "*****@*****.**", "TA Spring Crashreport");
	if (!GetInstance())
	{
		ErrorMessageBox("Error installing crash reporter", "CrashReport error:", MBF_OK);
		return false;
	}
#endif // _MSC_VER
#ifdef __MINGW32__
	CrashHandler::Install();
#endif // __MINGW32__

	FileSystemHandler::Initialize(true);

	if (!ParseCmdLine ())
		return false;

	if (!InitWindow ("RtsSpring"))
	{
		SDL_Quit ();
		return false;
	}

	mouseInput = IMouseInput::Get ();

	// Global structures
	ENTER_SYNCED;
	gs=SAFE_NEW CGlobalSyncedStuff();
	ENTER_UNSYNCED;
	gu=SAFE_NEW CGlobalUnsyncedStuff();

	if (cmdline->result("minimise")) {
		gu->active = false;
		SDL_WM_IconifyWindow();
	}

	// Enable auto quit?
	int quit_time;
	if (cmdline->result("quit", quit_time)) {
		gu->autoQuit = true;
		gu->quitTime = quit_time;
	}

	InitOpenGL();
	palette.Init();

	// Initialize keyboard
	SDL_EnableUNICODE(1);
	SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
	SDL_SetModState (KMOD_NONE);
	
	keys = SAFE_NEW Uint8[SDLK_LAST];
	memset (keys,0,sizeof(Uint8)*SDLK_LAST);

	// Initialize font
	font = SAFE_NEW CglFont(configHandler.GetInt("FontCharFirst", 32),
	                   configHandler.GetInt("FontCharLast", 223),
	                   configHandler.GetString("FontFile", "Luxi.ttf").c_str());

	// Initialize GLEW
	LoadExtensions();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	SDL_GL_SwapBuffers();

	// Initialize ScriptHandler / LUA
	CScriptHandler::Instance().StartLua();

	// Create CGameSetup and CPreGame objects
	CreateGameSetup ();

	return true;
}
Exemple #17
0
/**
 * @brief Initializes the SpringApp instance
 * @return whether initialization was successful
 */
bool SpringApp::Initialize ()
{
	logOutput.SetMirrorToStdout(!!configHandler.GetInt("StdoutDebug",0));

	// Initialize class system
	creg::System::InitializeClasses ();

	// Initialize crash reporting
#ifdef _WIN32
#if defined(_CRASHRPT_H_)
	Install( (LPGETLOGFILE) crashCallback, "*****@*****.**", "Spring Crashreport");
	if (!GetInstance())
	{
		ErrorMessageBox("Error installing crash reporter", "CrashReport error:", MBF_OK);
		return false;
	}
#elif defined(CRASHHANDLER_H)
	CrashHandler::Install();
#endif
	InitializeSEH();
#endif

	ParseCmdLine();
	FileSystemHandler::Initialize(true);

	if (!InitWindow ("RtsSpring"))
	{
		SDL_Quit ();
		return false;
	}

	mouseInput = IMouseInput::Get ();

	// Global structures
	ENTER_SYNCED;
	gs=SAFE_NEW CGlobalSyncedStuff();
	ENTER_UNSYNCED;
	gu=SAFE_NEW CGlobalUnsyncedStuff();

	if (cmdline->result("minimise")) {
		gu->active = false;
		SDL_WM_IconifyWindow();
	}

	// Enable auto quit?
	int quit_time;
	if (cmdline->result("quit", quit_time)) {
		gu->autoQuit = true;
		gu->quitTime = quit_time;
	}

	InitOpenGL();
	palette.Init();

	// Initialize keyboard
	SDL_EnableUNICODE(1);
	SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
	SDL_SetModState (KMOD_NONE);

	keys = SAFE_NEW Uint8[SDLK_LAST];
	memset (keys,0,sizeof(Uint8)*SDLK_LAST);

	// Initialize font
	const int charFirst = configHandler.GetInt("FontCharFirst", 32);
	const int charLast  = configHandler.GetInt("FontCharLast", 255);
	std::string fontFile = configHandler.GetString("FontFile", "fonts/Luxi.ttf");

	try {
		font = SAFE_NEW CglFont(charFirst, charLast, fontFile.c_str());
	} catch(content_error&) {
		// If the standard location fails, retry in fonts directory or vice versa.
		if (fontFile.substr(0, 6) == "fonts/")
			fontFile = fontFile.substr(6);
		else
			fontFile = "fonts/" + fontFile;
		font = SAFE_NEW CglFont(charFirst, charLast, fontFile.c_str());
	}

	// Initialize GLEW
	LoadExtensions();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	SDL_GL_SwapBuffers();

	// Initialize named texture handler
	CNamedTextures::Init();

	// Initialize Lua GL
	LuaOpenGL::Init();

	// Initialize ScriptHandler / LUA
	CScriptHandler::Instance().StartLua();

	// Create CGameSetup and CPreGame objects
	CreateGameSetup ();

	return true;
}
Exemple #18
0
int main (int argc,char *argv[])
  {
  int count;
  int flags;
  const char *temp;

#ifdef DATAPATH
  chdir(DATAPATH);
#endif

  checkbigendian();

  loadconfig();
  loadscores();
  loadplayers();

  flags=SDL_INIT_VIDEO|SDL_INIT_TIMER;
  if (config.joystick)
    flags|=SDL_INIT_JOYSTICK;

  SDL_Init(flags);

  sdlvideoinfo=SDL_GetVideoInfo();
  sdlpixelformat=sdlvideoinfo->vfmt;
  if (sdlpixelformat->BitsPerPixel==16)
    config.bitsperpixel=16;

  for (count=1;count<argc;count++)
    {
    if (strcmp("-nosound",argv[count])==0)
      {
      config.sound=0;
      option.sound=0;
      option.music=0;
      }
    if (strcmp("-sound",argv[count])==0)
      config.sound=1;
    if (strcmp("-nomusic",argv[count])==0)
      option.music=0;
    }

  saveconfig();

  SDL_ShowCursor(SDL_DISABLE);

  listvideomodes();

  SDL_WM_SetCaption("Gish","SDL");
  SDL_WM_SetIcon(SDL_LoadBMP("gish.bmp"),iconmask);

  if (windowinfo.bitsperpixel==16)
    {
    SDL_GL_SetAttribute(SDL_GL_RED_SIZE,5);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,6);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,5);
    SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,0);
    }
  if (windowinfo.bitsperpixel==32)
    {
    SDL_GL_SetAttribute(SDL_GL_RED_SIZE,8);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,8);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,8);
    SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,8);
    }
  SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,windowinfo.depthbits);
  SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE,windowinfo.stencilbits);
  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);

  if (windowinfo.fullscreen)
    SDL_SetVideoMode(windowinfo.resolutionx,windowinfo.resolutiony,windowinfo.bitsperpixel,SDL_OPENGL|SDL_FULLSCREEN);
  else
    SDL_SetVideoMode(windowinfo.resolutionx,windowinfo.resolutiony,windowinfo.bitsperpixel,SDL_OPENGL);

  loadglextentions();

  for (count=0;count<2048;count++)
    glGenTextures(1,&texture[count].glname);

  glDisable(GL_DEPTH_TEST);
  glDepthMask(GL_FALSE);

  if (config.joystick)
    {
    numofjoysticks=SDL_NumJoysticks();
    for (count=0;count<numofjoysticks;count++)
      {
      joy[count]=SDL_JoystickOpen(count);
      temp=SDL_JoystickName(count);
      strcpy(joystick[count].name,temp);
      joystick[count].numofbuttons=SDL_JoystickNumButtons(joy[count]);
      joystick[count].numofhats=SDL_JoystickNumHats(joy[count]);
      }

    SDL_JoystickEventState(SDL_IGNORE);
    }

  font.texturenum=0;
  font.cursornum=0;
  font.sizex=640;
  font.sizey=480;

  loadtexture(1000,"font00.png",0,GL_CLAMP,GL_CLAMP,GL_LINEAR,GL_LINEAR);
  loadtexture(1001,"font01.png",0,GL_CLAMP,GL_CLAMP,GL_LINEAR,GL_LINEAR);

  loadtexture(768,"mouse00.png",0,GL_CLAMP,GL_CLAMP,GL_LINEAR,GL_LINEAR);
  loadtexture(769,"mouse00.png",0,GL_CLAMP,GL_CLAMP,GL_LINEAR,GL_LINEAR);

  setupmenuitems();

  if (!glext.multitexture)
    {
    notsupportedmenu();

    SDL_WM_IconifyWindow();
    SDL_Quit();
    return(0);
    }
    
  if (config.sound)
    setupaudio();

  mainmenu();

  saveconfig();
  savescores();
  saveplayers();

  if (config.sound)
    shutdownaudio();

  SDL_WM_IconifyWindow();

  SDL_Quit();

  return(0);
  }
Exemple #19
0
void CGraphics_SDL::Minimize()
{
	SDL_WM_IconifyWindow();
}
bool MenuBase::doInput(SDL_Event &event) {
	switch (event.type) {
		case (SDL_KEYDOWN): {
			// Look for a keypress
			switch(event.key.keysym.sym) {

				case SDLK_ESCAPE: {
					if((pChildWindow == NULL) && (bAllowQuiting == true)) {
						quit();
					}
                } break;

				case SDLK_RETURN: {
					if(SDL_GetModState() & KMOD_ALT) {
						SDL_WM_ToggleFullScreen(screen);
					}
                } break;

                case SDLK_p: {
                    if(SDL_GetModState() & KMOD_CTRL) {
                        // fall through to SDLK_PRINT
                    } else {
                        break;  // do not fall through
                    }
                } // fall through

				case SDLK_PRINT:
				case SDLK_SYSREQ: {
                    std::string screenshotFilename;
                    int i = 1;
                    do {
                        screenshotFilename = "Screenshot" + stringify(i) + ".bmp";
                        i++;
                    } while(existsFile(screenshotFilename) == true);

                    SDL_SaveBMP(screen, screenshotFilename.c_str());
                } break;

                case SDLK_TAB: {
                    if(SDL_GetModState() & KMOD_ALT) {
                        SDL_WM_IconifyWindow();
                    }
                } break;

				default: {
				} break;
			}
		} break;

		case SDL_MOUSEMOTION: {
			SDL_MouseMotionEvent* mouse = &event.motion;

			drawnMouseX = mouse->x;
			drawnMouseY = mouse->y;
		} break;

		case SDL_QUIT: {
			if((pChildWindow == NULL) && (bAllowQuiting == true)) {
				quit();
			}
        } break;

		default: {
        } break;
	}

	handleInput(event);

	return !quiting;
}
void SDLWindow::hide() {
	SDL_WM_IconifyWindow();
	onShow(false);
}
void SDLWindow::tick() {
	
	SDL_Event event;
	while(SDL_PollEvent(&event)) {
		
		switch(event.type) {
			
			case SDL_ACTIVEEVENT: {
				if(event.active.state & SDL_APPINPUTFOCUS) {
					// ignored
				}
				if(event.active.state & SDL_APPACTIVE) {
					if(event.active.gain) {
						onRestore();
					} else {
						onMinimize();
					}
				}
				if(input != NULL && (event.active.state & SDL_APPMOUSEFOCUS)) {
					input->onInputEvent(event);
				}
				break;
			}
			
			case SDL_KEYDOWN:
				
				// For some reason, release notes from SDL 1.2.12 says a SDL_QUIT message
				// should be sent when Command+Q is pressed on Mac OS or ALT-F4 on other platforms
				// but it doesn't look like it's working as expected...
#if ARX_PLATFORM == ARX_PLATFORM_MACOSX
				if(event.key.keysym.sym == SDLK_q
					&& (event.key.keysym.mod & KMOD_META) != KMOD_NONE) {
#else
				if(event.key.keysym.sym == SDLK_F4
					&& (event.key.keysym.mod & KMOD_ALT) != KMOD_NONE) {
#endif
					onDestroy();
					break;
				}
				
#if ARX_PLATFORM != ARX_PLATFORM_WIN32
				// The SDL X11 backend always grabs all keys when in fullscreen mode,
				// ufortunately breaking window manager shortcuts.
				// At least provide users with a way to switch to other windows.
				if(event.key.keysym.sym == SDLK_TAB
				   && (event.key.keysym.mod & KMOD_ALT) != KMOD_NONE) {
					SDL_WM_IconifyWindow();
				}
#endif
				
			case SDL_KEYUP:
			case SDL_MOUSEMOTION:
			case SDL_MOUSEBUTTONDOWN:
			case SDL_MOUSEBUTTONUP:
			case SDL_JOYAXISMOTION:
			case SDL_JOYBALLMOTION:
			case SDL_JOYHATMOTION:
			case SDL_JOYBUTTONDOWN:
			case SDL_JOYBUTTONUP: {
				if(input) {
					input->onInputEvent(event);
				}
				break;
			}
			
			case SDL_QUIT: {
				onDestroy();
				break;
			}
			
			case SDL_VIDEORESIZE: {
				Vec2i newSize(event.resize.w, event.resize.h);
				if(newSize != size_ && !isFullscreen_) {
					setMode(DisplayMode(newSize, depth_), false);
					updateSize(false);
				}
				break;
			}
			
			case SDL_VIDEOEXPOSE: {
				onPaint();
				break;
			}
			
		}
		
	}
	
}

Vec2i SDLWindow::getCursorPosition() const {
	int cursorPosX, cursorPosY;
	SDL_GetMouseState(&cursorPosX, &cursorPosY);
	return Vec2i(cursorPosX, cursorPosY);
}
//! Minimizes window if possible
void CIrrDeviceSDL::minimizeWindow()
{
	SDL_WM_IconifyWindow();
}
Exemple #24
0
/*
===============
GLimp_EndFrame

Responsible for doing a swapbuffers
===============
*/
void GLimp_EndFrame( void )
{
	// don't flip if drawing to front buffer
	if ( Q_stricmp( r_drawBuffer->string, "GL_FRONT" ) != 0 )
	{
		SDL_GL_SwapBuffers();
	}

	if (r_minimize && r_minimize->integer){
	      extern qboolean fullscreen_minimized;
	      extern void IN_DeactivateMouse(void);
	      SDL_Surface *s = SDL_GetVideoSurface();
	      qboolean fullscreen = qfalse;
	      qboolean minimized = qfalse;
	      fullscreen = (s && (s->flags & SDL_FULLSCREEN));
	      #ifdef MACOS_X
		    // this is a bit crap, but the mac SDL_WM_IconifyWindow does not work
		    // on fullscreen windows, nor does the SDL_WM_ToggleFullscreen work
	      if (!fullscreen){
		      if (SDL_WM_IconifyWindow()){
			    IN_DeactivateMouse();
		      }
		      Cvar_Set("r_minimize", "0");
		    }
    
	      else if (r_fullscreen->integer){
		      Cvar_Set("r_fullscreen", "0");
		      fullscreen_minimized = qtrue;
		  }
	      #else
		    minimized = (SDL_WM_IconifyWindow() != 0);
		    if (fullscreen && minimized)
		    fullscreen_minimized = qtrue;
		    // this shouldn't be necessary, but seems to prevent X11 mouse problems
		    if (minimized){
			IN_DeactivateMouse();
		    }
		    Cvar_Set("r_minimize", "0");
	      #endif // MACOS_X
	}
    
	if( r_fullscreen->modified )
	{
		qboolean    fullscreen;
		qboolean    needToToggle = qtrue;
		qboolean    sdlToggled = qfalse;
		SDL_Surface *s = SDL_GetVideoSurface( );

		if( s )
		{
			// Find out the current state
			fullscreen = !!( s->flags & SDL_FULLSCREEN );
				
			if( r_fullscreen->integer && ri.Cvar_VariableIntegerValue( "in_nograb" ) )
			{
				ri.Printf( PRINT_ALL, "Fullscreen not allowed with in_nograb 1\n");
				ri.Cvar_Set( "r_fullscreen", "0" );
				r_fullscreen->modified = qfalse;
			}

			// Is the state we want different from the current state?
			needToToggle = !!r_fullscreen->integer != fullscreen;

			if( needToToggle )
				sdlToggled = SDL_WM_ToggleFullScreen( s );
		}

		if( needToToggle )
		{
			// SDL_WM_ToggleFullScreen didn't work, so do it the slow way
			if( !sdlToggled )
				ri.Cmd_ExecuteText(EXEC_APPEND, "vid_restart");

			ri.IN_Restart( );
		}

		r_fullscreen->modified = qfalse;
	}
}
Exemple #25
0
int HandleEvent(SDL_Event *event)
{
	static int buttonStates[MAX_BUTTONS] = { 0 };
	int lastx=0, lasty=0;
	bool mouseEvent = false;
	int done, rawkey, key, unicode;

	done = 0;
	switch( event->type ) {
	    case SDL_ACTIVEEVENT:
			/* See what happened */
			printf( "app %s ", event->active.gain ? "gained" : "lost" );
			if ( event->active.state & SDL_APPACTIVE ) 
			{
				printf( "active " );
				/*
				if (event->active.gain)
					Cvar_SetVarValue(&gfx, 1);
				else
					Cvar_SetVarValue(&gfx, 0);
				*/
			} 
			else if ( event->active.state & SDL_APPMOUSEFOCUS ) {
				printf( "mouse " );
				hasMouseFocus = event->active.gain;
			} else if ( event->active.state & SDL_APPINPUTFOCUS ) {
				printf( "input " );
				hasMouseFocus = event->active.gain;
			}
			printf( "focus\n" );
			
			if( !event->active.gain && GL_SDL_IsFullScreen()) {
				SDL_WM_IconifyWindow();
			}
			
			break;

	    case SDL_KEYDOWN:
	    case SDL_KEYUP:
			/*if ( (event->key.keysym.unicode & 0xFF80) == 0 )
				key = event->key.keysym.unicode & 0x7F;
			else
				//international keyboard, try using the keysym
			*/
			key = event->key.keysym.sym;
			if (event->key.keysym.unicode)
				unicode = event->key.keysym.unicode & 0x7F;
			else
				unicode = key;
			rawkey = key;
			
			switch (key)
			{
				case SDLK_LSHIFT:
				case SDLK_RSHIFT:
				  			key = KEY_SHIFT;
				  			break;
				case SDLK_LCTRL:
				case SDLK_RCTRL:
				  			key = KEY_CTRL;
				  			break;
				case SDLK_LALT:
				case SDLK_RALT:
				  			key = KEY_ALT;
				  			break;
				case SDLK_ESCAPE:
							key = KEY_ESCAPE;
							break;
				case SDLK_BACKSPACE:
							key = KEY_BACKSPACE;
							break;
				case SDLK_PAUSE:
							key = KEY_PAUSE;
							break;
				case SDLK_PRINT:
							key = KEY_PRINT;
							break;
				case SDLK_HOME:
							key = KEY_HOME;
							break;
				case SDLK_END:
							key = KEY_END;
							break;
				case SDLK_DELETE:
							key = KEY_DEL;
							break;
				case SDLK_INSERT:
							key = KEY_INS;
							break;
				case SDLK_PAGEUP:
							key = KEY_PGUP;
							break;
				case SDLK_PAGEDOWN:
							key = KEY_PGDN;
							break;
				case SDLK_UP:
				  			key = KEY_UP;
				  			break;
				case SDLK_DOWN:
				  			key = KEY_DOWN;
				  			break;
				case SDLK_LEFT:
				  			key = KEY_LEFT;
				  			break;
				case SDLK_RIGHT:
				  			key = KEY_RIGHT;
				  			break;
				case SDLK_KP0:
				case SDLK_KP1:
				case SDLK_KP2:
				case SDLK_KP3:
				case SDLK_KP4:
				case SDLK_KP5:
				case SDLK_KP6:
				case SDLK_KP7:
				case SDLK_KP8:
				case SDLK_KP9:
							key = KEY_KEYPAD_0 + key - SDLK_KP0;
							break;
				case SDLK_KP_PERIOD:
							key = KEY_KEYPAD_DECIMAL;
							break;
				case SDLK_KP_DIVIDE:
							key = KEY_KEYPAD_SLASH;
							break;
				case SDLK_KP_MULTIPLY:
							key = KEY_KEYPAD_ASTERISK;
							break;
				case SDLK_KP_MINUS:
							key = KEY_KEYPAD_MINUS;
							break;
				case SDLK_KP_PLUS:
							key = KEY_KEYPAD_PLUS;
							break;
				case SDLK_KP_ENTER:
							key = KEY_KEYPAD_ENTER;
							break;
				case SDLK_LSUPER:
							key = KEY_LEFT_WINDOWS;
							break;
				case SDLK_RSUPER:
							key = KEY_RIGHT_WINDOWS;
							break;
				case SDLK_MENU:
							key = KEY_MENU;
							break;
				case SDLK_F1:
				case SDLK_F2:
				case SDLK_F3:
				case SDLK_F4:
				case SDLK_F5:
				case SDLK_F6:
				case SDLK_F7:
				case SDLK_F8:
				case SDLK_F9:
				case SDLK_F10:
				case SDLK_F11:
				case SDLK_F12:
				case SDLK_F13:
				case SDLK_F14:
				case SDLK_F15:
							key = KEY_F1 + key - SDLK_F1;
							break;
				case 132:
							key = KEY_ALT;
							break;
			}
			if (key != rawkey) //we modified the value
				unicode = key;

			//FIXME
			/*if (sys_showKeycodes.integer)
				Console_Printf("key %i (%s) (unicode %i [%s]) %s\n", key, SDL_GetKeyName(key), unicode, SDL_GetKeyName(unicode), event->type == SDL_KEYDOWN ? "pressed" : "released");*/

			if (event->type == SDL_KEYDOWN)
			{
				//alt-enter hack
				if (key == KEY_ENTER && keyDown == KEY_ALT)
				{
					Cmd_Exec("toggle vid_fullscreen; changevideo");
				}
				//alt-tab hack
				if (key == KEY_TAB && keyDown == KEY_ALT)
				{
					SDL_WM_IconifyWindow();
				}
					
				//Console_DPrintf("key %i pressed\n", key);
				keyDown = key;
				keyDownTime = System_Milliseconds();
			}
			else
			{
				if (keyDown == key)
				{
					//Console_DPrintf("key %i released\n", key);
					keyDown = -1;
				}
			}

			//printf("button %c %s\n", key, event->key.state ? "pressed" : "unpressed");
			Input_Event(key, unicode, event->key.state);
			done = 1;
			break;
		case SDL_MOUSEBUTTONDOWN:
		case SDL_MOUSEBUTTONUP:
			//fprintf(stderr, "mouse button event!  button %d is %d\n", event->button.button, event->button.state);
			if (((event->button.state && !buttonDownThisFrame[event->button.button]) 
				|| (!event->button.state && !buttonUpThisFrame[event->button.button]))
				&& event->button.state != buttonStates[event->button.button])
			{
				if (event->button.state)
					buttonDownThisFrame[event->button.button] = true;
				else
					buttonUpThisFrame[event->button.button] = true;
				buttonStates[event->button.button] = event->button.state;
				switch(event->button.button)
				{
					case SDL_BUTTON_LEFT:
						Input_Event(KEY_LBUTTON, 0, event->button.state);
						done = 1;
						break;
					case SDL_BUTTON_RIGHT:
						Input_Event(KEY_RBUTTON, 0, event->button.state);
						done = 1;
						break;
					case SDL_BUTTON_MIDDLE:
						Input_Event(KEY_MBUTTON, 0, event->button.state);
						done = 1;
						break;
					case SDL_BUTTON_WHEELUP:
						Input_Event(KEY_MWHEELUP, 0, event->button.state);
						done = 1;
						break;
					case SDL_BUTTON_WHEELDOWN:
						Input_Event(KEY_MWHEELDOWN, 0, event->button.state);
						done = 1;
						break;
					/*case SDL_BUTTON_X1:
						Input_Event(KEY_XBUTTON1, 0, event->button.state);
						done = 1;
						break;
					case SDL_BUTTON_X2:
						Input_Event(KEY_XBUTTON2, 0, event->button.state);
						done = 1;
						break;*/
					default:
						Console_DPrintf("unknown button %d\n", event->button.button);
						break;
				}
			}
			break;
		case SDL_MOUSEMOTION:
		{
			mouseEvent=true;
			lastx = event->motion.x;
			lasty = event->motion.y;
			//if(y != Vid_GetScreenH()>>1 && x != Vid_GetScreenW()>>1) {
				if (inverty.integer)
					lasty = Vid_GetScreenH() - lasty;
				//fprintf(stderr, "mouse motion event!  now (%d, %d)\n", event->motion.x, event->motion.y);
			
			//}
		}break;
		case SDL_VIDEORESIZE:
			if (vid_mode.integer == -2)
			{
				silent_vid_mode_change = true;
				Cvar_SetValue("vid_mode0_width", event->resize.w);
				Cvar_SetValue("vid_mode0_height", event->resize.h);
				Cmd_Exec("changevideo");
				silent_vid_mode_change = false;
			}
		    done = 1;
			break;
	    case SDL_QUIT:
			System_Quit();
			done = 1;
		break;
	}
	
	if(mouseEvent)
		Input_UpdateMouse(lastx, lasty);
	
	return(done);
}
Exemple #26
0
bool command_executor::execute_command(HOTKEY_COMMAND command, int /*index*/)
{
	switch(command) {
	    case HOTKEY_MINIMIZE:
            SDL_WM_IconifyWindow();
            break;
		case HOTKEY_CYCLE_UNITS:
			cycle_units();
			break;
		case HOTKEY_CYCLE_BACK_UNITS:
			cycle_back_units();
			break;
        case HOTKEY_SELECT_TILE:
			toggle_selectmode();
			break;
        case HOTKEY_RIGHT_CLICK:
			toggle_right_click();
			break;
		case HOTKEY_ENDTURN:
			end_turn();
			break;
		case HOTKEY_UNIT_HOLD_POSITION:
			unit_hold_position();
			break;
		case HOTKEY_END_UNIT_TURN:
			end_unit_turn();
			break;
		case HOTKEY_LEADER:
			goto_leader();
			break;
		case HOTKEY_UNDO:
			undo();
			break;
        case HOTKEY_CANCEL_MENU:
            break;
		case HOTKEY_REDO:
			redo();
			break;
		case HOTKEY_UNIT_DESCRIPTION:
			unit_description();
			break;
		case HOTKEY_RENAME_UNIT:
			rename_unit();
			break;
		case HOTKEY_SAVE_GAME:
			save_game();
			break;
		case HOTKEY_SAVE_REPLAY:
			save_replay();
			break;
		case HOTKEY_SAVE_MAP:
			save_map();
			break;
		case HOTKEY_LOAD_GAME:
			load_game();
			break;
		case HOTKEY_TOGGLE_ELLIPSES:
			toggle_ellipses();
			break;
		case HOTKEY_TOGGLE_GRID:
			toggle_grid();
			break;
		case HOTKEY_STATUS_TABLE:
			status_table();
			break;
		case HOTKEY_RECALL:
			recall();
			break;
		case HOTKEY_RECRUIT:
			recruit();
			break;
		case hotkey::HOTKEY_REPEAT_RECRUIT:
			repeat_recruit();
			break;
		case HOTKEY_SPEAK:
			speak();
			break;
		case HOTKEY_SPEAK_ALLY:
			whisper();
			break;
		case HOTKEY_SPEAK_ALL:
			shout();
			break;
		case HOTKEY_CREATE_UNIT:
			create_unit();
			break;
		case HOTKEY_CHANGE_SIDE:
			change_side();
			break;
		case HOTKEY_PREFERENCES:
			preferences();
			break;
		case HOTKEY_OBJECTIVES:
			objectives();
			break;
		case HOTKEY_UNIT_LIST:
			unit_list();
			break;
		case HOTKEY_STATISTICS:
			show_statistics();
			break;
		case HOTKEY_STOP_NETWORK:
			stop_network();
			break;
		case HOTKEY_START_NETWORK:
			start_network();
			break;
		case HOTKEY_LABEL_TEAM_TERRAIN:
			label_terrain(true);
			break;
		case HOTKEY_LABEL_TERRAIN:
			label_terrain(false);
			break;
		case HOTKEY_CLEAR_LABELS:
			clear_labels();
			break;
		case HOTKEY_SHOW_ENEMY_MOVES:
			show_enemy_moves(false);
			break;
		case HOTKEY_BEST_ENEMY_MOVES:
			show_enemy_moves(true);
			break;
		case HOTKEY_DELAY_SHROUD:
			toggle_shroud_updates();
			break;
		case HOTKEY_UPDATE_SHROUD:
			update_shroud_now();
			break;
		case HOTKEY_CONTINUE_MOVE:
			continue_move();
			break;
		case HOTKEY_SEARCH:
			search();
			break;
		case HOTKEY_HELP:
			show_help();
			break;
		case HOTKEY_CHAT_LOG:
			show_chat_log();
			break;
		case HOTKEY_USER_CMD:
			user_command();
			break;
		case HOTKEY_CUSTOM_CMD:
			custom_command();
			break;
		case HOTKEY_AI_FORMULA:
			ai_formula();
			break;
		case HOTKEY_CLEAR_MSG:
			clear_messages();
			break;
		 case HOTKEY_LANGUAGE:
			change_language();
			break;
		 case HOTKEY_PLAY_REPLAY:
			play_replay();
			 break;
		 case HOTKEY_RESET_REPLAY:
			reset_replay();
			 break;
		 case HOTKEY_STOP_REPLAY:
			 stop_replay();
			 break;
		 case HOTKEY_REPLAY_NEXT_TURN:
			replay_next_turn();
			 break;
		 case HOTKEY_REPLAY_NEXT_SIDE:
			replay_next_side();
			 break;
		 case HOTKEY_REPLAY_SHOW_EVERYTHING:
			replay_show_everything();
			 break;
		 case HOTKEY_REPLAY_SHOW_EACH:
			replay_show_each();
			 break;
		 case HOTKEY_REPLAY_SHOW_TEAM1:
			replay_show_team1();
			 break;
		 case HOTKEY_REPLAY_SKIP_ANIMATION:
			replay_skip_animation();
			 break;
		 case HOTKEY_WB_TOGGLE:
			 whiteboard_toggle();
			 break;
		 case HOTKEY_WB_EXECUTE_ACTION:
			 whiteboard_execute_action();
			 break;
		 case HOTKEY_WB_EXECUTE_ALL_ACTIONS:
			 whiteboard_execute_all_actions();
			 break;
		 case HOTKEY_WB_DELETE_ACTION:
			 whiteboard_delete_action();
			 break;
		 case HOTKEY_WB_BUMP_UP_ACTION:
			 whiteboard_bump_up_action();
			 break;
		 case HOTKEY_WB_BUMP_DOWN_ACTION:
			 whiteboard_bump_down_action();
			 break;
		 case HOTKEY_WB_SUPPOSE_DEAD:
			 whiteboard_suppose_dead();
			 break;
		 case HOTKEY_LEFT_MOUSE_CLICK:
			 left_mouse_click();
			 break;
		 case HOTKEY_RIGHT_MOUSE_CLICK:
			 right_mouse_click();
			 break;
		 default:
			 return false;
	}
	return true;
}
Exemple #27
0
int exaIconifyWindow()
{
	SDL_WM_GrabInput (SDL_GRAB_OFF);
	return !SDL_WM_IconifyWindow();
}
void
HotKey_Iconify(void)
{
    printf("Ctrl-Z: iconifying window!\n");
    SDL_WM_IconifyWindow();
}
Exemple #29
0
static int bgd_minimize( INSTANCE * my, int * params )
{
    return SDL_WM_IconifyWindow();
}