示例#1
0
void KBlocksScene::pauseGame(bool flag, bool fromUI)
{
    if (!mGameStarted) {
        return;
    }

    QString resuming(i18n("Game Resumed!"));
    QString pausing(i18n("Game Paused!"));

    for (int i = 0; i < mGroupCount; i++) {
        maGroupList[i]->pauseGame(flag);
    }

    if (!mSnapshotMode) {
        if (flag) {
            mUpdateTimer.stop();
            if (!fromUI) {
                showMessage(pausing, 2000);
            }
        } else {
            mUpdateTimer.start();
            if (!fromUI) {
                showMessage(resuming, 2000);
            }
        }
    }
}
示例#2
0
文件: main.c 项目: arebena/test_sdl
void	show(SDL_Renderer *ren, SDL_Surface *to_show)
{
	SDL_Rect		pj_box;
	SDL_Texture		*tex;
	
	pj_box.x = 0;
	pj_box.y = 0;
	pj_box.w = 50;
	pj_box.h = 70;

	tex = SDL_CreateTextureFromSurface(ren, to_show);
	SDL_RenderCopy(ren, tex, NULL, &pj_box);
	SDL_DestroyTexture(tex);
	SDL_RenderPresent(ren);
	pausing("----------");
}
示例#3
0
 int main(int argc, char *argv[])
 {
    // Input buffer and and commands
 	char buffer[BUFFER_LEN] = { 0 };
 	char command[BUFFER_LEN] = { 0 };
 	char arg[BUFFER_LEN] = { 0 };
 	char fileN [256] = {0};
 	bool enterManual = true;
    // variable used to check pass
 	bool check =false;

    // current working directory
    char cwd[PATH_MAX + 1];

    // Get the argurment for the file.
 	tokenize(argv[1]);
    // Checking through the files for the bat file
 	check = foldercheck(tokens[0]);
    // copies the file into a tmp variable before we clear tokens
 	strcpy(fileN, tokens[0]);
 	clearTokens();
    // If the file was found
 	if(check)
 	{   
        // Load the file
 		FILE *f;
 		f=fopen(fileN, "r");

        //sets it so you do not go into manual entry afterwords
 		enterManual = false;

        if (getcwd(cwd, PATH_MAX + 1) != NULL) {
            printf("%s$ ", cwd);
        }
        // Enters a loop to get the inputs from the file
 		while(fgets(buffer, BUFFER_LEN,f) != NULL)
 		{
            // tokenizes the buffer
 			tokenize(buffer);
 			strcpy(command, tokens[0]);
            //Checks for commands
 			if(strcmp(command, "dir") ==0)
 			{
 				directory();
 			}
 			else if (strcmp(command, "cd") == 0)
 			{

 				changedir(tokens[1]);
 			}

 			else if(strcmp(command, "clr") ==0)
 			{
 				clear();
 			}
 			else if(strcmp(command, "echo") == 0)
 			{
 				echo(tokens,i);
 			}

 			else if(strcmp(command, "pause") == 0)
 			{
 				pausing();
 			}

 			else if(strcmp(command, "environ")==0)
 			{
 				environ();
 			}
 			else if(strcmp(command, "help") ==0)
 			{
                help(tokens[1]);
 			}
            // quit command -- exit the shell
 			else if (strcmp(command, "quit") == 0)
 			{
 				return EXIT_SUCCESS;
 			}
            // If it is not a valid command checks if they are trying to start a program
 			else
 			{   
                // Check if there is a file in the program
 				check = false;
 				check = foldercheck(command);
                // if program name is found
 				if(check)
 				{  
                    // create first part of program string
                    char begin[250] = {"./"};
                    strcat (begin,tokens[0]);
                    int count = 0;
                    check = true;
                    // Loops 7 times to get the max of seven parameter
                    for(int i = 1; i < 7; i++)
                    {   
                        // makes it so no blanks go into the checks
                        if(strcmp(tokens[i]," ") != 0)
                        {
                            // checks for write symbol 
                            if(strcmp(tokens[i], ">") == 0)
                            {
                                // gets next token and sets it to write
                                i++;
                                freopen(tokens[i],"w",stdout);
                            }
                            // cbecks for append symbol
                            else if (strcmp(tokens[i], ">>") == 0)
                            {
                                // gets next token and sets it to append
                                i++;
                                freopen(tokens[i],"a",stdout);
                            }
                            // checks for read input
                            else if (strcmp(tokens[i], "<") == 0)
                            {
                                // gets next input for file name and checks if it is a file
                                i++;
                                if(foldercheck(tokens[i]))
                                {
                                    // reads from file
                                    freopen(tokens[i],"r",stdin);    
                                }else
                                {
                                    // not found sets it to terminal and writes
                                    i = 7;
                                    freopen("/dev/tty", "w", stdout);
                                    printf("Invalid file read entry \n");
                                    check = false;
                                }
                            }
                            // checks if two args have already pass
                            else if(count < 2)
                            {
                                // appends the argument to the program call
                                count++;
                                char append [256] = {" "};
                                strcat (append,tokens[i]);
                                strcat (begin, append);
                            }
                            // Invalid call has been passed
                            else
                            {
                                freopen("/dev/tty", "w", stdout);
                                printf("Invalid file program entry type \n");
                                check = false;
                                i = 7;
                            }
                        }
                    }
                    // Runs if valid program call has been called
                    if(check)
                    {
                        system(begin);
                    }
                    freopen("/dev/tty", "w", stdout);
                    freopen("/dev/tty", "r", stdin);    
                }// Command does not exist
 				else
 				{
 					printf("Unsupported command, use help to display the manual. Please enter Manualy. %s \n",  command);
 					clearTokens();
 					enterManual = true;
 					break;

 				}
 			}
 			clearTokens();
            // Fetches cwd and prints it out before input
            if (getcwd(cwd, PATH_MAX + 1) != NULL) {
                printf("%s$ ", cwd);
            }
 		}
 	}
    // Checks if the user has to enter manually for the shell
 	if(enterManual)
 	{
        if (getcwd(cwd, PATH_MAX + 1) != NULL) {
            printf("%s$ ", cwd);
        }
 		while (fgets(buffer, BUFFER_LEN, stdin) != NULL)
 		{
            // tokenizes the buffer
 			tokenize(buffer);
 			strcpy(command, tokens[0]);
            //Checks for commands
 			if(strcmp(command, "dir") ==0)
 			{
 				directory();
 			}
 			else if (strcmp(command, "cd") == 0)
 			{

 				changedir(tokens[1]);
 			}

 			else if(strcmp(command, "clr") ==0)
 			{
 				clear();
 			}
 			else if(strcmp(command, "echo") == 0)
 			{
 				echo(tokens,i);
 			}

 			else if(strcmp(command, "pause") == 0)
 			{
 				pausing();
 			}

 			else if(strcmp(command, "environ")==0)
 			{
 				environ();
 			}
 			else if(strcmp(command, "help") ==0)
 			{
                help(tokens[1]);
 			}
            // quit command -- exit the shell
 			else if (strcmp(command, "quit") == 0)
 			{
 				return EXIT_SUCCESS;
 			}
            // If it is not a valid command checks if they are trying to start a program
 			else
 			{   
                // Check if there is a file in the program
 				check = false;
 				check = foldercheck(command);
                // if the program is found
 				if(check)
 				{
                    // create first part of program string
                    char begin[250] = {"./"};
                    strcat (begin,tokens[0]);
                    int count = 0;
                    check = true;
                    // Loops 7 times to get the max of seven parameter
                    for(int i = 1; i < 7; i++)
                    {   
                        // makes it so no blanks go into the checks
                        if(strcmp(tokens[i]," ") != 0)
                        {
                            // checks for write symbol 
                            if(strcmp(tokens[i], ">") == 0)
                            {
                                // gets next token and sets it to write
                                i++;
                                freopen(tokens[i],"w",stdout);
                            }
                            // cbecks for append symbol
                            else if (strcmp(tokens[i], ">>") == 0)
                            {
                                // gets next token and sets it to append
                                i++;
                                freopen(tokens[i],"a",stdout);
                            }
                            // checks for read input
                            else if (strcmp(tokens[i], "<") == 0)
                            {
                                // gets next input for file name and checks if it is a file
                                i++;
                                if(foldercheck(tokens[i]))
                                {
                                    // reads from file
                                    freopen(tokens[i],"r",stdin);    
                                }else
                                {
                                    // not found sets it to terminal and writes
                                    i = 7;
                                    freopen("/dev/tty", "w", stdout);
                                    printf("Invalid file read entry \n");
                                    check = false;
                                }
                            }
                            // checks if two args have already pass
                            else if(count < 2)
                            {
                                // appends the argument to the program call
                                count++;
                                char append [256] = {" "};
                                strcat (append,tokens[i]);
                                strcat (begin, append);
                            }
                            // Invalid call has been passed
                            else
                            {
                                freopen("/dev/tty", "w", stdout);
                                printf("Invalid file program entry type \n");
                                check = false;
                                i = 7;
                            }
                        }
                    }
                    // Runs if valid program call has been called
                    if(check)
                    {
                        system(begin);
                    }
                    freopen("/dev/tty", "w", stdout);
                    freopen("/dev/tty", "r", stdin);    
 				}
 				else
 				{
 					printf("Unsupported command, use help to display the manual.%s \n",  command);

 				}
 			}
 			clearTokens();
            // Fetches cwd and prints it out before input
            if (getcwd(cwd, PATH_MAX + 1) != NULL) {
                printf("%s$ ", cwd);
            }
 		}    
 	}   

 	return EXIT_SUCCESS;
 }