Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 46.64 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include<SDL2/SDL.h>
  3. #include<SDL2/SDL_image.h>
  4. #include<SDL2/SDL_ttf.h>
  5.  
  6.  
  7.  
  8.  
  9.  
  10. class LTexture
  11. {
  12.  
  13. public:
  14.  
  15.     LTexture();
  16.     ~LTexture();
  17.     bool loadFromFile(std::string path);
  18.  
  19. #if defined(_SDL_TTF_H) || defined(SDL_TTF_H)
  20.     bool loadFromRenderedText( std::string textureText, SDL_Color textColor );
  21. #endif
  22.  
  23.     void free();
  24.     void setColor(Uint8 red, Uint8 green, Uint8 blue);
  25.     void setBlendMode(SDL_BlendMode blending);
  26.     void setAlpha(Uint8 alpha);
  27.     void render(int x, int y, SDL_Rect* clip = NULL, double angle = 0.0, SDL_Point* center = NULL, SDL_RendererFlip flip = SDL_FLIP_NONE );
  28.     int getWidth();
  29.     int getHeight();
  30.  
  31. private:
  32.     SDL_Texture* mTexture;
  33.     int mWidth;
  34.     int mHeight;
  35.  
  36. };
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43. LTexture::LTexture()
  44. {
  45.     mTexture = NULL;
  46.     mWidth = 0;
  47.     mHeight = 0;
  48. }
  49.  
  50. LTexture::~LTexture()
  51. {
  52.     free();
  53. }
  54.  
  55.  
  56. // constants and declarations
  57.  
  58.  
  59. const int SCREEN_WIDTH = 500;
  60. const int SCREEN_HEIGHT = 500;
  61. int Font_WIDTH = 40;
  62. int day=20 , month, year=2019;
  63. char date[50];
  64. char indicator[5] = "!";
  65. bool global_check_for_first_window_flag = false;
  66. bool global_check_for_main_menu = false;
  67. bool firstWindowShowFuntionFlag = false;
  68. bool quit = false;
  69. bool init();
  70. bool loadMedia();
  71. void close();
  72. SDL_Texture* loadTexture(std::string path);
  73. SDL_Texture* firstWindow = NULL;
  74. SDL_Window* main_window = NULL;
  75. SDL_Renderer* main_renderer = NULL;
  76. TTF_Font* main_font=NULL;
  77. LTexture mainTextTexture[50];
  78. LTexture header_text_input_texture;
  79. LTexture Ltemp;
  80. LTexture indi;
  81. LTexture header;
  82. SDL_Color textColor;
  83. SDL_Texture* main_menu_texture = NULL;
  84. SDL_Texture* HeaderEntry = NULL;
  85. SDL_Texture* background_texture = NULL;
  86. SDL_Texture* selectBackground = NULL;
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95. bool LTexture::loadFromFile(std:: string path)
  96. {
  97.     free();
  98.     SDL_Texture* newTexture = NULL;
  99.     SDL_Surface* loadedSurface = IMG_Load(path.c_str());
  100.     if(loadedSurface==NULL)
  101.     {
  102.         printf( "Unable to load image %s! SDL_image Error: %s\n", path.c_str(), IMG_GetError() );
  103.     }
  104.     else
  105.     {
  106.         SDL_SetColorKey(loadedSurface, SDL_TRUE, SDL_MapRGB(loadedSurface->format, 0, 0xFF, 0xFF));
  107.         newTexture = SDL_CreateTextureFromSurface(main_renderer, loadedSurface);
  108.         if( newTexture == NULL )  printf( "Unable to create texture from %s! SDL Error: %s\n", path.c_str(), SDL_GetError() );
  109.  
  110.         else
  111.         {
  112.             mWidth = loadedSurface->w;
  113.             mHeight = loadedSurface->h;
  114.             if(path == "indi.png"){
  115.               mWidth = 5;
  116.               mHeight = 20;
  117.             }
  118.         }
  119.         SDL_FreeSurface(loadedSurface);
  120.     }
  121.     mTexture = newTexture;
  122.     return mTexture !=NULL;
  123. }
  124.  
  125.  
  126. #if defined(_SDL_TTF_H) || defined(SDL_TTF_H)
  127. bool LTexture::loadFromRenderedText(std::string textureText, SDL_Color textColor)
  128. {
  129.  
  130.     free();
  131.  
  132.     SDL_Surface* textSurface = TTF_RenderText_Solid(main_font, textureText.c_str(), textColor);
  133.     if( textSurface == NULL ) printf( "Unable to render text surface! SDL_ttf Error: %s\n", TTF_GetError() );
  134.     else
  135.     {
  136.         mTexture = SDL_CreateTextureFromSurface(main_renderer, textSurface);
  137.         if(mTexture == NULL)    printf( "Unable to create texture from rendered text! SDL Error: %s\n", SDL_GetError() );
  138.         else
  139.         {
  140.             mWidth = textSurface->w;
  141.             mHeight = textSurface->h;
  142.         }
  143.         SDL_FreeSurface(textSurface);
  144.     }
  145.     return mTexture!=NULL;
  146. }
  147.  
  148. #endif
  149.  
  150. void LTexture::free()
  151. {
  152.     if(mTexture!=NULL)
  153.     {
  154.         SDL_DestroyTexture(mTexture);
  155.         mTexture = NULL;
  156.         mWidth = 0;
  157.         mHeight = 0;
  158.     }
  159. }
  160.  
  161. void LTexture::setColor(Uint8 red, Uint8 green, Uint8 blue)
  162. {
  163.     SDL_SetTextureColorMod(mTexture, red, green, blue);
  164.  
  165. }
  166.  
  167. void LTexture::setBlendMode(SDL_BlendMode blending)
  168. {
  169.     SDL_SetTextureBlendMode(mTexture, blending);
  170. }
  171.  
  172. void LTexture::setAlpha(Uint8 alpha)
  173. {
  174.     SDL_SetTextureAlphaMod(mTexture, alpha);
  175. }
  176.  
  177. void LTexture::render(int x, int y, SDL_Rect* clip, double angle, SDL_Point* center, SDL_RendererFlip flip)
  178. {
  179.     SDL_Rect renderQuad = {x,y,mWidth,mHeight};
  180.     if(clip!=NULL)
  181.     {
  182.         renderQuad.w = clip->w;
  183.         renderQuad.h = clip->h;
  184.     }
  185.     SDL_RenderCopyEx(main_renderer, mTexture, clip, &renderQuad, angle, center, flip);
  186. }
  187.  
  188.  
  189. int LTexture::getWidth()
  190. {
  191.     return mWidth;
  192. }
  193.  
  194. int LTexture::getHeight()
  195. {
  196.     return mHeight;
  197. }
  198.  
  199.  
  200.  
  201.  
  202. SDL_Texture* loadTexture(std::string path){
  203.   SDL_Texture* newTexture = NULL;
  204.   SDL_Surface* loadedSurface = IMG_Load(path.c_str());
  205.   if(loadedSurface == NULL)     printf( "Unable to load image %s! SDL_image Error: %s\n", path.c_str(), IMG_GetError() );
  206.   else{
  207.     newTexture = SDL_CreateTextureFromSurface(main_renderer, loadedSurface);
  208.     if(newTexture==NULL)    printf( "Unable to create texture from %s! SDL Error: %s\n", path.c_str(), SDL_GetError() );
  209.         SDL_FreeSurface(loadedSurface);
  210.   }
  211.   return newTexture;
  212. }
  213.  
  214.  
  215.  
  216. bool init()
  217. {
  218.     bool success = true;
  219.     if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
  220.     {
  221.         printf( "SDL could not initialize! SDL Error: %s\n", SDL_GetError() );
  222.         success = false;
  223.     }
  224.     else
  225.     {
  226.         if(!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY,"1")) printf("Warning: Linear texture filtering not enabled!" );
  227.         main_window = SDL_CreateWindow("PASA",0,0,SCREEN_WIDTH,SCREEN_HEIGHT,SDL_WINDOW_SHOWN);
  228.         if(main_window==NULL)
  229.         {
  230.             printf( "Window could not be created! SDL Error: %s\n", SDL_GetError() );
  231.             success = false;
  232.         }
  233.         else
  234.         {
  235.             main_renderer = SDL_CreateRenderer(main_window,-1,SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
  236.             if( main_renderer == NULL )
  237.             {
  238.                 printf( "Renderer could not be created! SDL Error: %s\n", SDL_GetError() );
  239.                 success = false;
  240.             }
  241.             else
  242.             {
  243.                 SDL_SetRenderDrawColor(main_renderer, 0xFF,0xFF,0xFF,0xFF);
  244.                 int imgFlags = IMG_INIT_PNG;
  245.                 if(!(IMG_Init(imgFlags)&imgFlags))
  246.                 {
  247.                     printf( "SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError() );
  248.                     success = false;
  249.                 }
  250.                 if( TTF_Init() == -1 )
  251.                 {
  252.                     printf( "SDL_ttf could not initialize! SDL_ttf Error: %s\n", TTF_GetError() );
  253.                     success = false;
  254.                 }
  255.             }
  256.         }
  257.     }
  258.     return success;
  259. }
  260.  
  261.  
  262.  
  263. bool loadMedia()
  264. {
  265.     bool success = true;
  266.  
  267.     main_font = TTF_OpenFont("JosefinSans-Regular.ttf", Font_WIDTH);
  268.     if(main_font==NULL)
  269.     {
  270.         printf( "Failed to load font! SDL_ttf Error: %s\n", TTF_GetError() );
  271.         success = false;
  272.     }
  273.  
  274.  
  275.     // first window loader
  276.  
  277.     firstWindow = loadTexture("firstWindow.png");
  278.     if( firstWindow == NULL )
  279.     {
  280.         printf( "Failed to load firstWindow!\n" );
  281.         success = false;
  282.     }
  283.  
  284.     // main menu loader
  285.  
  286.     main_menu_texture = loadTexture("main_menu_texture.png");
  287.     if( main_menu_texture == NULL )
  288.     {
  289.         printf( "Failed to load main_menu_texture!\n" );
  290.         success = false;
  291.     }
  292.  
  293.     // header entry loader
  294.  
  295.     HeaderEntry = loadTexture("HeaderEntry.png");
  296.     if( HeaderEntry == NULL )
  297.     {
  298.         printf( "Failed to load HeaderEntry!\n" );
  299.         success = false;
  300.     }
  301.  
  302.     selectBackground = loadTexture("selectBackground.png");
  303.     if(selectBackground==NULL){
  304.       printf( "Failed to load selectBackground!\n" );
  305.       success = false;
  306.     }
  307.  
  308.     return success;
  309. }
  310.  
  311.  
  312.  
  313.  
  314. void close()
  315. {
  316.     for(int i=0; i<50; i++)
  317.     {
  318.         mainTextTexture[i].free();
  319.     }
  320.     SDL_DestroyTexture(firstWindow);
  321.     firstWindow = NULL;
  322.     SDL_DestroyTexture(main_menu_texture);
  323.     main_menu_texture = NULL;
  324.     SDL_DestroyTexture(HeaderEntry);
  325.     HeaderEntry = NULL;
  326.     SDL_DestroyTexture(background_texture);
  327.     background_texture = NULL;
  328.     SDL_DestroyTexture(selectBackground);
  329.     selectBackground = NULL;
  330.  
  331.     header.free();
  332.     TTF_CloseFont(main_font);
  333.     main_font = NULL;
  334.     SDL_DestroyRenderer(main_renderer);
  335.     main_renderer = NULL;
  336.     SDL_DestroyWindow(main_window);
  337.  
  338.     main_window = NULL;
  339.     TTF_Quit();
  340.     IMG_Quit();
  341.     SDL_Quit();
  342. }
  343.  
  344.  
  345.  
  346. void firstWindowShowFuntion(){
  347.     SDL_SetRenderDrawColor( main_renderer, 0x00, 0x00, 0x00, 0xFF );
  348.     SDL_RenderCopy(main_renderer, firstWindow, NULL, NULL);
  349.     SDL_RenderPresent(main_renderer);
  350.     SDL_Delay(600);
  351.     SDL_RenderClear( main_renderer );
  352.     firstWindowShowFuntionFlag = true;
  353. }
  354.  
  355.  
  356.  
  357. int main_menu_show_funtion(){
  358.   int xNewmin = (475*SCREEN_WIDTH/2000), xNewmax = (475*SCREEN_WIDTH/2000)+ (1050*SCREEN_WIDTH/2000);
  359.   int yNewmin = (123*SCREEN_HEIGHT/1000), yNewmax = (123*SCREEN_HEIGHT/1000)+ (185*SCREEN_HEIGHT/1000);
  360.  
  361.   int xOldmin = (475*SCREEN_WIDTH/2000), xOldmax = (475*SCREEN_WIDTH/2000)+ (1050*SCREEN_WIDTH/2000);
  362.   int yOldmin = (423*SCREEN_HEIGHT/1000), yOldmax = (423*SCREEN_HEIGHT/1000) + (185*SCREEN_HEIGHT/1000);
  363.  
  364.   int xExitmin = (475*SCREEN_WIDTH/2000), xExitmax = (475*SCREEN_WIDTH/2000) + (1050*SCREEN_WIDTH/2000);
  365.   int yExitmin = (695*SCREEN_HEIGHT/1000), yExitmax = (695*SCREEN_HEIGHT/1000) + (185*SCREEN_HEIGHT/1000);
  366.  
  367.   SDL_SetRenderDrawColor( main_renderer, 0x00, 0x00, 0x00, 0xFF );
  368.   SDL_RenderCopy(main_renderer, main_menu_texture, NULL, NULL);
  369.   SDL_RenderPresent(main_renderer);
  370.  
  371.   SDL_Event event_for_first_window2 ;
  372.   if(SDL_PollEvent(&event_for_first_window2)){
  373.  
  374.   if(event_for_first_window2.type == SDL_QUIT)
  375.   {
  376.     quit = true;
  377.   }
  378.  
  379.    if(event_for_first_window2.type == SDL_MOUSEBUTTONDOWN){
  380.  
  381.      if((event_for_first_window2.button.x>xNewmin)&&(event_for_first_window2.button.x<xNewmax)&&(event_for_first_window2.button.y>yNewmin)&&(event_for_first_window2.button.y<yNewmax)) {
  382.         return 1;
  383.       }
  384.  
  385.      if((event_for_first_window2.button.x > xOldmin)&&(event_for_first_window2.button.x<xOldmax)&&(event_for_first_window2.button.y>yOldmin)&&(event_for_first_window2.button.y<yOldmax))
  386.       {
  387.         return 2;
  388.       }
  389.  
  390.       if((event_for_first_window2.button.x>xExitmin)&&(event_for_first_window2.button.x<xExitmax)&&(event_for_first_window2.button.y>yExitmin)&&(event_for_first_window2.button.y<yExitmax))
  391.       {
  392.         return 3;
  393.       }
  394.     }
  395.   }
  396.  
  397.   SDL_RenderClear( main_renderer );
  398.   return 0;
  399. }
  400.  
  401.  
  402.  
  403.  
  404.  
  405. int backgroundTextureSelectionFuntion(){
  406.   SDL_Event eventForBack;
  407.  
  408.   int ymin = (207*SCREEN_HEIGHT/1000), ymax = (335*SCREEN_HEIGHT/1000);
  409.   int x1min = (174*SCREEN_WIDTH/2000), x1max = (490*SCREEN_WIDTH/2000);
  410.   int x2min = (572*SCREEN_WIDTH/2000), x2max = (883*SCREEN_WIDTH/2000);
  411.   int x3min = (971*SCREEN_WIDTH/2000), x3max = (1283*SCREEN_WIDTH/2000);
  412.   int x4min = (1380*SCREEN_WIDTH/2000), x4max = (1691*SCREEN_WIDTH/2000);
  413.  
  414.   SDL_SetRenderDrawColor( main_renderer, 0x00, 0x00, 0x00, 0xFF );
  415.   SDL_RenderCopy(main_renderer, selectBackground, NULL, NULL);
  416.   SDL_RenderPresent(main_renderer);
  417.  
  418.  
  419.   if(SDL_PollEvent(&eventForBack)){
  420.     if(eventForBack.type == SDL_QUIT)
  421.     {
  422.       quit = true;
  423.     }
  424.     if(eventForBack.type == SDL_MOUSEBUTTONDOWN){
  425.  
  426.       if((eventForBack.button.x>x1min)&&(eventForBack.button.x<x1max)&&(eventForBack.button.y>ymin)&&(eventForBack.button.y<ymax)) {
  427.          return 1;
  428.        }
  429.  
  430.       if
  431.        ((eventForBack.button.x>x2min)&&(eventForBack.button.x<x2max)&&(eventForBack.button.y>ymin)&&(eventForBack.button.y<ymax)) {
  432.         return 2;
  433.       }
  434.  
  435.       if((eventForBack.button.x>x3min)&&(eventForBack.button.x<x3max)&&(eventForBack.button.y>ymin)&&(eventForBack.button.y<ymax)) {
  436.          return 3;
  437.       }
  438.       if((eventForBack.button.x>x4min)&&(eventForBack.button.x<x4max)&&(eventForBack.button.y>ymin)&&(eventForBack.button.y<ymax)) {
  439.         return 4;
  440.       }
  441.  
  442.  
  443.  
  444.     }
  445.   }
  446.  
  447.   SDL_RenderClear( main_renderer );
  448.   return 0;
  449. }
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456. void HeaderInputFromUser(){
  457.  
  458.  
  459.   bool quit_this = false;
  460.   SDL_Event e1;
  461.   SDL_Color textColor ={0xFF,0xFF,0xFF};
  462.  
  463.  
  464.   std::string inputText = "";
  465.  
  466.   SDL_StartTextInput();
  467.  
  468.   while( !quit_this )
  469.   {
  470.     if(e1.type == SDL_QUIT) break;
  471.     bool renderText = false;
  472.  
  473.  
  474.     while( SDL_PollEvent( &e1 ) != 0 )
  475.     {
  476.  
  477.       if( e1.key.keysym.sym == SDLK_RETURN )
  478.       {
  479.         quit_this = true;
  480.       }
  481.  
  482.       else if( e1.type == SDL_KEYDOWN )
  483.       {
  484.  
  485.         if( e1.key.keysym.sym == SDLK_BACKSPACE && inputText.length() > 0 )
  486.         {
  487.                 inputText.pop_back();
  488.           renderText = true;
  489.         }
  490.  
  491.         else if( e1.key.keysym.sym == SDLK_c && SDL_GetModState() & KMOD_CTRL )
  492.         {
  493.           SDL_SetClipboardText( inputText.c_str() );
  494.         }
  495.         else if( e1.key.keysym.sym == SDLK_v && SDL_GetModState() & KMOD_CTRL )
  496.         {
  497.           inputText = SDL_GetClipboardText();
  498.           renderText = true;
  499.         }
  500.       }
  501.       else if( e1.type == SDL_TEXTINPUT )
  502.       {
  503.         if( !( SDL_GetModState() & KMOD_CTRL && ( e1.text.text[ 0 ] == 'c' || e1.text.text[ 0 ] == 'C' || e1.text.text[ 0 ] == 'v' || e1.text.text[ 0 ] == 'V' ) ) )
  504.         {
  505.           inputText += e1.text.text;
  506.           renderText = true;
  507.         }
  508.       }
  509.     }
  510.  
  511.  
  512.     if( renderText )
  513.     {
  514.  
  515.       if( inputText != "" )
  516.       {
  517.  
  518.         header_text_input_texture.loadFromRenderedText( inputText.c_str(), textColor );
  519.       }
  520.  
  521.       else
  522.       {
  523.  
  524.         header_text_input_texture.loadFromRenderedText( " ", textColor );
  525.       }
  526.     }
  527.  
  528.  
  529.  
  530.  
  531.  
  532.     SDL_SetRenderDrawColor( main_renderer, 0x00, 0xFF, 0xFF, 0xFF );
  533.     SDL_RenderClear( main_renderer );
  534.  
  535.     SDL_RenderCopy(main_renderer, HeaderEntry, NULL, NULL);
  536.  
  537.     header_text_input_texture.render( 200,200 );
  538.  
  539.  
  540.  
  541.  
  542.  
  543.     SDL_RenderPresent( main_renderer );
  544.   }
  545.  
  546.  
  547.   SDL_StopTextInput();
  548.  
  549.   sprintf(date,"%s",inputText);
  550.  
  551.  
  552. }
  553.  
  554.  
  555. void loadbackground_texture(int kontaBackground){
  556.  
  557.   if(kontaBackground == 2){
  558.      background_texture = loadTexture("yellow_back.png");
  559.      textColor = {0x00,0x00,0xFF};
  560.    }
  561.  
  562.   else if(kontaBackground == 3){
  563.   background_texture = loadTexture("dark_back.png");
  564.   textColor = {0xFF,0x00,0x00};
  565.   }
  566.  
  567.   else if(kontaBackground == 4) {
  568.     background_texture = loadTexture("green_back.png");
  569.     textColor = {0x00,0x00,0xFF};
  570.   }
  571.  
  572.   else{
  573.      background_texture = loadTexture("white_back.png");
  574.      textColor = {0x00,0x00,0x00};
  575.    }
  576.  
  577.   if( background_texture == NULL )
  578.   {
  579.       printf( "Failed to load main_menu_texture!\n" );
  580.   }
  581.  
  582. }
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591. int main(int argn, char* args[])
  592. {
  593.  
  594.     int z=0,p=0,q,count=0,x=0,current_line=0,c=0,total_line=0,flag=0,backspace_check=0,length,side_count=0;
  595.     int left_sign=0,tchar[100]={0},indi_xpos,indi_xpos_width[1000],final_indi_xpos,huda,left_check,middle_backspace=0;
  596.     int right_new_line=0,left_new_line=0,previous_line_indi_xpos=0,r_length,l_length,ctrl_count=0,all_select=0;
  597.     int scroll_count=0,max_line=0,up_sign=0;
  598.     char s[1001000],v[100][2002],ctemp[1000],char_temp,stemp[1000];
  599.  
  600.  
  601.    //sprintf(date, "%d th October, %d", day, year);
  602.  
  603.  
  604.     if(!init()) printf("Failed to initialize/n");
  605.     else
  606.     {
  607.         if(!loadMedia()) printf("Failed to load media\n");
  608.         else
  609.         {
  610.  
  611.           bool firstWindowShowFuntionFlag = false;
  612.           int mainMenuShowFuntionFlag = false;
  613.  
  614.           if(!firstWindowShowFuntionFlag) firstWindowShowFuntion();
  615.  
  616.  
  617.           while(mainMenuShowFuntionFlag==0){
  618.             mainMenuShowFuntionFlag = main_menu_show_funtion();
  619.             if(quit) return 0;
  620.           }
  621.  
  622.           if(mainMenuShowFuntionFlag==3) return 0;
  623.  
  624.  
  625.  
  626.  
  627.  
  628. ///           TEXT EDITOR PART
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.             HeaderInputFromUser();
  636.  
  637.             SDL_Color hColor = {0xD3,0xFF,0xCE};
  638.  
  639.             if(!header.loadFromRenderedText( date ,hColor))
  640.             {
  641.                 printf( "Failed to render text texture!\n" );
  642.             }
  643.  
  644.  
  645.             SDL_RenderClear(main_renderer);
  646.  
  647.  
  648.             int kontaBackground = 3, background_texture_selection_funtion_flag=0;
  649.  
  650.  
  651.             while(background_texture_selection_funtion_flag==0){
  652.               background_texture_selection_funtion_flag = backgroundTextureSelectionFuntion();
  653.               if(quit) return 0;
  654.             }
  655.             kontaBackground = background_texture_selection_funtion_flag;
  656.  
  657.  
  658.             loadbackground_texture(kontaBackground);
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.             bool quit = false;
  669.             SDL_Event e;
  670.             SDL_Color textColor = {0xFF,0xFF,0xFF};
  671.             std::string inputText[50];
  672.             std::string copyText[50];
  673.             std::string sh;
  674.             std::string itTemp;
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.             SDL_StartTextInput();
  684.  
  685.            
  686.  
  687.  
  688.  
  689.  
  690.            
  691.  
  692.             bool break_game_loop = false;
  693.  
  694.  
  695.             while(!quit)
  696.             {
  697.  
  698.                 bool renderText = false;
  699.  
  700.  
  701.                 while(SDL_PollEvent(&e)!=0)
  702.                 {
  703.  
  704.                    
  705.  
  706.                     if(e.type == SDL_QUIT) quit = true;
  707.  
  708.  
  709.                     else if(e.type == SDL_KEYDOWN)
  710.                     {
  711.  
  712.                        
  713.  
  714.                         huda=1;
  715.  
  716.  
  717.                         //backspace key
  718.  
  719.  
  720.  
  721.  
  722.  
  723.                         if( e.key.keysym.sym == SDLK_BACKSPACE )
  724.                         {
  725.  
  726.                             if(all_select==1)
  727.                              {
  728.                                 all_select=0;
  729.                                 sh=" ";
  730.                                 for(int i=0;i<=total_line;i++)
  731.                                 {
  732.                                     inputText[i]=sh;
  733.                                     mainTextTexture[i].loadFromRenderedText(inputText[i],textColor);
  734.                                     inputText[i].pop_back();
  735.                                 }
  736.                                 total_line=0;
  737.                                 current_line=0;
  738.                                 indi_xpos=0;
  739.                                
  740.                                
  741.                              }
  742.                              else if(current_line==0&&indi_xpos==0);
  743.                              //else if(mainTextTexture[current_line].getWidth()>=SCREEN_WIDTH-100);
  744.                              
  745.  
  746.  
  747.                             else if(left_sign<1)
  748.                             {
  749.  
  750.                              
  751.  
  752.  
  753.  
  754.  
  755.                                 //backspace main part
  756.  
  757.  
  758.  
  759.                                 if(inputText[current_line].length()==0&&current_line!=0)
  760.                                 {
  761.                                    
  762.  
  763.                                  
  764.                                     //majher ekta line kaatle
  765.  
  766.                              
  767.                                     if(current_line<total_line)
  768.                                     {
  769.                                       for(int a=0;a<total_line-current_line;a++)
  770.                                       {
  771.                                         sh=inputText[current_line+a];
  772.                                         inputText[current_line+a]=inputText[current_line+1+a];
  773.                                         inputText[current_line+1+a]=sh;
  774.                                         mainTextTexture[current_line+a].loadFromRenderedText( inputText[current_line+a].c_str(), textColor );
  775.                                       }
  776.                                     }
  777.  
  778.                                     if(total_line>0)total_line--;
  779.                                     current_line--;
  780.                                  
  781.                                     left_sign=0;
  782.                                    
  783.                                    
  784.  
  785.  
  786.                                     if(mainTextTexture[current_line].getWidth()>=SCREEN_WIDTH-100&&total_line>=0)
  787.                                     {
  788.                                         backspace_check=1;
  789.                                    
  790.                                     }
  791.                                     renderText = false;
  792.                                     mainTextTexture[current_line].loadFromRenderedText( inputText[current_line].c_str(), textColor );
  793.                                 }
  794.  
  795.                                 //first line zodi delete dite thaki
  796.  
  797.                                 else if(inputText[current_line].length()==0&&current_line==0)
  798.                                 {
  799.                                      if(current_line<total_line)
  800.                                     {
  801.                                       for(int a=0;a<total_line;a++)
  802.                                       {
  803.                                         sh=inputText[current_line+a];
  804.                                         inputText[current_line+a]=inputText[current_line+1+a];
  805.                                         inputText[current_line+1+a]=sh;
  806.                                         mainTextTexture[current_line+a].loadFromRenderedText( inputText[current_line+a].c_str(), textColor );
  807.                                       }
  808.                                     }
  809.  
  810.                                     if(total_line>0)total_line--;
  811.                                     current_line=0;
  812.                                    
  813.                                     left_sign=0;
  814.                                    
  815.                                     left_sign=strlen(inputText[current_line].c_str());
  816.                                 }
  817.  
  818.                                 //indicator er karone width bere gele overflow line theke kaTAr jonno
  819.  
  820.  
  821.                                 if(mainTextTexture[current_line].getWidth()>=SCREEN_WIDTH-100)
  822.                                 {
  823.                                     //printf("%d %d\n",current_line,mainTextTexture[current_line-1].getWidth() );
  824.                                     inputText[current_line].pop_back();
  825.                                     mainTextTexture[current_line].loadFromRenderedText( inputText[current_line].c_str(), textColor );
  826.                                     renderText = false;
  827.  
  828.                                 }
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.                                 else if(inputText[current_line].length() > 0)
  837.                                 {
  838.                                     inputText[current_line].pop_back();
  839.                                     renderText = true;
  840.                                 }
  841.                             }
  842.  
  843.                             else
  844.                                 {
  845.                                     middle_backspace=1;
  846.                                     renderText=true;
  847.                                 }
  848.                                 // printf("%d\n",left_sign );
  849.                         }
  850.  
  851.                         if(e.key.keysym.sym !=SDL_GetModState() & KMOD_CTRL)all_select=0;
  852.  
  853.  
  854.  
  855.                         //Up key
  856.  
  857.  
  858.  
  859.                         if( e.key.keysym.sym == SDLK_UP )
  860.                         {
  861.                            
  862.                          
  863.  
  864.                             if(current_line>0)
  865.                            
  866.                             {
  867.                                 //indicator y axis e align kora
  868.  
  869.  
  870.                              
  871.                                 {
  872.                                    
  873.  
  874.                                     previous_line_indi_xpos=final_indi_xpos;
  875.  
  876.                                     if(mainTextTexture[current_line-1].getWidth()>=SCREEN_WIDTH-100)backspace_check=1;
  877.  
  878.                                     current_line--;
  879.                                     printf("%d %d\n",mainTextTexture[current_line].getWidth() ,previous_line_indi_xpos);
  880.  
  881.                                     if(mainTextTexture[current_line].getWidth()<=previous_line_indi_xpos)left_sign=0;
  882.  
  883.  
  884.                                     else
  885.                                     {
  886.                                        
  887.  
  888.                                         for(int i=0;i<strlen(inputText[current_line].c_str())-1;i++)
  889.                                         {
  890.  
  891.                                             ctemp[i]=inputText[current_line].c_str()[i];
  892.                                             ctemp[i+1]=0;
  893.                                             Ltemp.loadFromRenderedText( ctemp, textColor );
  894.                                             l_length=Ltemp.getWidth();
  895.  
  896.  
  897.  
  898.                                             ctemp[i+1]=inputText[current_line].c_str()[i+1];
  899.                                             ctemp[i+1+1]=0;
  900.                                             Ltemp.loadFromRenderedText( ctemp, textColor );
  901.                                             r_length=Ltemp.getWidth();
  902.  
  903.                                                
  904.  
  905.                                             if(previous_line_indi_xpos>=l_length&&previous_line_indi_xpos<=r_length)
  906.                                             {
  907.                                                 if(previous_line_indi_xpos-l_length<=r_length-previous_line_indi_xpos)
  908.                                                 {
  909.                                                     left_sign=strlen(inputText[current_line].c_str())-i-1;
  910.                                                     break;
  911.                                                 }
  912.                                                 else
  913.                                                 {
  914.                                                     left_sign=strlen(inputText[current_line].c_str())-i-2;
  915.                                                     break;
  916.                                                 }
  917.  
  918.  
  919.                                             }
  920.  
  921.  
  922.                                         }
  923.                                     }
  924.  
  925.  
  926.                                 }
  927.                              
  928.  
  929.  
  930.                          
  931.                              
  932.  
  933.                             }
  934.                             else
  935.                             {
  936.                                 backspace_check=1;
  937.                                 current_line=0;
  938.                              
  939.                             }
  940.                             renderText=false;
  941.                         }
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.                         //down key
  949.  
  950.  
  951.  
  952.                         else if( e.key.keysym.sym == SDLK_DOWN &&inputText[current_line].length()>0)
  953.                         {
  954.                            
  955.                             if(current_line<total_line)
  956.                             {
  957.  
  958.                                 {
  959.                                    
  960.  
  961.                                     previous_line_indi_xpos=final_indi_xpos;
  962.  
  963.                                     if(mainTextTexture[current_line+1].getWidth()>=SCREEN_WIDTH-100)backspace_check=1;
  964.  
  965.                                     current_line++;
  966.                                
  967.  
  968.                                     if(mainTextTexture[current_line].getWidth()<=previous_line_indi_xpos)left_sign=0;
  969.  
  970.  
  971.                                     else
  972.                                     {
  973.                                        
  974.  
  975.                                         for(int i=0;i<strlen(inputText[current_line].c_str())-1;i++)
  976.                                         {
  977.  
  978.                                             ctemp[i]=inputText[current_line].c_str()[i];
  979.                                             ctemp[i+1]=0;
  980.                                             Ltemp.loadFromRenderedText( ctemp, textColor );
  981.                                             l_length=Ltemp.getWidth();
  982.  
  983.  
  984.  
  985.                                             ctemp[i+1]=inputText[current_line].c_str()[i+1];
  986.                                             ctemp[i+1+1]=0;
  987.                                             Ltemp.loadFromRenderedText( ctemp, textColor );
  988.                                             r_length=Ltemp.getWidth();
  989.  
  990.  
  991.  
  992.                                             if(previous_line_indi_xpos>=l_length&&previous_line_indi_xpos<=r_length)
  993.                                             {
  994.                                                
  995.                                                 if(previous_line_indi_xpos-l_length<=r_length-previous_line_indi_xpos)
  996.                                                 {
  997.                                                     left_sign=strlen(inputText[current_line].c_str())-i-1;
  998.                                                     break;
  999.                                                 }
  1000.                                                 else
  1001.                                                 {
  1002.                                                     left_sign=strlen(inputText[current_line].c_str())-i-2;
  1003.                                                     break;
  1004.                                                 }
  1005.  
  1006.                                             }
  1007.  
  1008.  
  1009.                                         }
  1010.                                     }
  1011.  
  1012.  
  1013.                                 }
  1014.  
  1015.  
  1016.                                
  1017.                    
  1018.                                
  1019.                             }
  1020.  
  1021.  
  1022.  
  1023.                             renderText = false;
  1024.                         }
  1025.                            
  1026.  
  1027.  
  1028.  
  1029.  
  1030.                                 //right key
  1031.  
  1032.                         else if( e.key.keysym.sym == SDLK_RIGHT )
  1033.                         {
  1034.                            
  1035.                           if(left_sign>0)left_sign--;
  1036.                              if(mainTextTexture[current_line].getWidth()>=SCREEN_WIDTH-100)
  1037.                             {
  1038.                                 backspace_check=1;
  1039.                                
  1040.                             }
  1041.  
  1042.                             //continuous right click
  1043.                             if(left_sign<=0&&current_line<total_line)
  1044.  
  1045.                             {
  1046.                                 if(mainTextTexture[current_line].getWidth()>=SCREEN_WIDTH-100||right_new_line==1)
  1047.                                 {
  1048.                                     current_line++;
  1049.                                     length=strlen(inputText[current_line].c_str());
  1050.                                     left_sign=length;
  1051.                                     right_new_line=0;
  1052.                                 }
  1053.                                 else
  1054.  
  1055.                                     right_new_line=1;
  1056.  
  1057.                             }
  1058.                         }
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.                             //left key
  1065.                           else if( e.key.keysym.sym == SDLK_LEFT )
  1066.                         {
  1067.  
  1068.                             //left overflow check
  1069.                             if(mainTextTexture[current_line].getWidth()>=SCREEN_WIDTH-100)
  1070.                             {
  1071.                                 backspace_check=1;
  1072.                                 left_check=1;
  1073.                             }
  1074.                            
  1075.                             if(indi_xpos>0)
  1076.                             {
  1077.                                left_sign++;
  1078.                                
  1079.                             }
  1080.                             if(left_sign==length&&current_line!=0&&left_new_line!=0)
  1081.                             {
  1082.                                 backspace_check=1;
  1083.                                 current_line--;
  1084.                                 left_sign=0;
  1085.                                 length=strlen(inputText[current_line].c_str());
  1086.                                 left_new_line=0;
  1087.                             }
  1088.  
  1089.                             if(left_sign==length&&current_line!=0&&left_new_line==0)
  1090.                             {
  1091.                                 left_new_line=1;
  1092.                             }
  1093.  
  1094.                         }
  1095.  
  1096.  
  1097.  
  1098.  
  1099.                         //enter key
  1100.  
  1101.  
  1102.  
  1103.                         else if( e.key.keysym.sym == SDLK_RETURN)
  1104.                         {
  1105.                             //line er majhe enter dile
  1106.  
  1107.                             if(left_sign>0)
  1108.                             {
  1109.                                 if(left_sign==length)
  1110.                                 {
  1111.                                     total_line++;
  1112.                                     mainTextTexture[current_line].loadFromRenderedText( "@", textColor );
  1113.                                     sh=inputText[current_line];
  1114.                                     for(int i=current_line+1;i<=total_line;i++)
  1115.                                     {
  1116.                                         if(i!=total_line)itTemp=inputText[i];
  1117.                                         inputText[i]=sh;
  1118.                                         if(i!=total_line) sh=itTemp;
  1119.                                         mainTextTexture[i].loadFromRenderedText( inputText[i].c_str(), textColor );
  1120.                                     }
  1121.                                     current_line++;
  1122.  
  1123.                                 }
  1124.                                 else
  1125.                                 {
  1126.                                     for(int i=0;i<indi_xpos;i++)
  1127.                                         ctemp[i]=inputText[current_line].c_str()[i];
  1128.                                     ctemp[indi_xpos]=0;
  1129.  
  1130.  
  1131.                                     for(int i=indi_xpos;i<length;i++)
  1132.                                         stemp[i-indi_xpos]=inputText[current_line].c_str()[i];
  1133.                                     stemp[length-indi_xpos]=0;
  1134.  
  1135.  
  1136.                                     total_line++;
  1137.                                     for(int i=0;i<length;i++)
  1138.                                         inputText[current_line].pop_back();
  1139.  
  1140.  
  1141.                                     inputText[current_line]=ctemp;
  1142.                                     mainTextTexture[current_line].loadFromRenderedText( inputText[current_line].c_str(), textColor );
  1143.  
  1144.  
  1145.                                     sh=inputText[current_line+1];
  1146.  
  1147.  
  1148.                                     inputText[current_line+1]=stemp;
  1149.                                     mainTextTexture[current_line+1].loadFromRenderedText( inputText[current_line+1].c_str(), textColor );
  1150.  
  1151.  
  1152.                                     for(int i=current_line+2;i<=total_line;i++)
  1153.                                     {
  1154.  
  1155.                                        if(i!=total_line)itTemp=inputText[i];
  1156.                                         inputText[i]=sh;
  1157.                                        if(i!=total_line) sh=itTemp;
  1158.                                         mainTextTexture[i].loadFromRenderedText( inputText[i].c_str(), textColor );
  1159.                                        
  1160.                                     }
  1161.                                     current_line++;
  1162.                                 }
  1163.  
  1164.  
  1165.  
  1166.                             }
  1167.                             else
  1168.                             {
  1169.  
  1170.                                 current_line++;
  1171.                                 total_line++;
  1172.                                 left_sign=0;
  1173.                             }
  1174.  
  1175.                  
  1176.                            //jani na jhamela badhle dekhbo c++;
  1177.                             if(inputText[current_line-1].length()==0)flag=1;
  1178.                             //mainTextTexture[i].loadFromRenderedText( inputText[i].c_str(), textColor );
  1179.  
  1180.  
  1181.                             renderText = false;
  1182.                         }
  1183.  
  1184.  
  1185.  
  1186.                         //shob select kora
  1187.  
  1188.                         else if(e.key.keysym.sym == SDLK_a && SDL_GetModState() & KMOD_CTRL)
  1189.                         {
  1190.                             if(all_select==1)all_select =0;
  1191.                             else
  1192.                                 all_select=1;
  1193.                         }
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.                         //copy something
  1202.  
  1203.                         else if( e.key.keysym.sym == SDLK_c && SDL_GetModState() & KMOD_CTRL )
  1204.                         {
  1205.                             for(int i=0; i<=current_line; i++)
  1206.                             {
  1207.                                 strcat(s,inputText[i].c_str());
  1208.                                 if(i!=current_line)strcat(s,"\n");
  1209.  
  1210.  
  1211.  
  1212.                             }
  1213.                             SDL_SetClipboardText(s);
  1214.                             s[0]=0;
  1215.                         }
  1216.  
  1217.                         //paste something
  1218.  
  1219.  
  1220.                         else if( e.key.keysym.sym == SDLK_v && SDL_GetModState() & KMOD_CTRL )
  1221.                         {
  1222.  
  1223.  
  1224.  
  1225.                             inputText[current_line] = inputText[current_line]+SDL_GetClipboardText();
  1226.  
  1227.                              int l=strlen(inputText[current_line].c_str());
  1228.  
  1229.                                 for(int i=0;i<l;i++)stemp[i]=inputText[current_line].c_str()[i];
  1230.                                     sh=inputText[current_line];
  1231.                                 for(int i=0;i<l;i++)inputText[current_line].pop_back();
  1232.  
  1233.                                 Ltemp.loadFromRenderedText( sh, textColor );
  1234.  
  1235.  
  1236.                                 if(Ltemp.getWidth()>=SCREEN_WIDTH-100)
  1237.                                  {
  1238.                                     for(int i=0;i<l;i++)
  1239.                                     {
  1240.  
  1241.  
  1242.                                         if(stemp[i]=='\n')continue;
  1243.                                             ctemp[count]=stemp[i];
  1244.                                             count++;
  1245.                                             ctemp[count]=0;
  1246.                                        
  1247.                                         sh=ctemp;
  1248.                                         if(i==l-1)
  1249.                                         {
  1250.                                             inputText[current_line]=sh;
  1251.                                             mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1252.                                         }
  1253.                                         Ltemp.loadFromRenderedText( sh, textColor );
  1254.                                         if(Ltemp.getWidth()>=SCREEN_WIDTH-100)
  1255.                                         {
  1256.                                        
  1257.                                             inputText[current_line]=sh;
  1258.                                             mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1259.                                             current_line++;
  1260.                                             total_line++;
  1261.                                             inputText[total_line]="@";
  1262.                                             for(int j=total_line;j>current_line+1;j--)
  1263.                                             {
  1264.                                                 sh=inputText[j];
  1265.                                                 inputText[j]=inputText[j-1];
  1266.                                                 inputText[j-1]=sh;
  1267.                                                 mainTextTexture[j].loadFromRenderedText( inputText[j], textColor );
  1268.                                             }
  1269.  
  1270.                                             for(int j=0;j<=count;j++)sh.pop_back();
  1271.  
  1272.  
  1273.                                             count=0;
  1274.                                             //inputText[current_line].pop_back();
  1275.  
  1276.  
  1277.                                         }
  1278.  
  1279.                                     }
  1280.  
  1281.                                  }
  1282.                                 else
  1283.                                 {
  1284.                                     inputText[current_line]=sh;
  1285.                                     mainTextTexture[current_line].loadFromRenderedText( inputText[current_line], textColor );
  1286.                                 }
  1287.                                 renderText=false;
  1288.                        
  1289.                         }
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.                         //newline
  1296.  
  1297.  
  1298.  
  1299.                          if( SDL_GetModState() & KMOD_CTRL )ctrl_count=1;
  1300.  
  1301.                         int width = mainTextTexture[current_line].getWidth();
  1302.                         if(width >= SCREEN_WIDTH-100&&ctrl_count!=1)
  1303.                         {
  1304.                            
  1305.                                if(backspace_check!=1)
  1306.                                {
  1307.  
  1308.                                 current_line++;
  1309.                  
  1310.                                 total_line++;
  1311.                                }
  1312.                                else
  1313.                                 backspace_check=0;
  1314.  
  1315.                                 renderText = true;
  1316.                          
  1317.  
  1318.                         }
  1319.                         else
  1320.                             ctrl_count=0;
  1321.  
  1322.  
  1323.  
  1324.  
  1325.                     }
  1326.  
  1327.  
  1328.  
  1329.  
  1330.  
  1331.  
  1332.                     else if( e.type == SDL_TEXTINPUT )
  1333.                     {
  1334.                         if( !( SDL_GetModState() & KMOD_CTRL && ( e.text.text[ 0 ] == 'c' || e.text.text[ 0 ] == 'C' || e.text.text[ 0 ] == 'v' || e.text.text[ 0 ] == 'V'|| e.text.text[ 0 ] == 'a' || e.text.text[ 0 ] == 'A' ) ) )
  1335.                         {
  1336.                             inputText[current_line] += e.text.text;
  1337.                             renderText = true;
  1338.                         }
  1339.                     }
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.  
  1346.                         //indicator
  1347.  
  1348.                      
  1349.  
  1350.                         length=strlen(inputText[current_line].c_str());
  1351.                         indi_xpos=length-left_sign;
  1352.                         if(indi_xpos<0)indi_xpos=0;
  1353.                  
  1354.                        
  1355.                         for(int i=0;i<=length;i++)
  1356.                         {
  1357.                             if(i<indi_xpos)ctemp[i]=inputText[current_line].c_str()[i];
  1358.                             stemp[i]=inputText[current_line].c_str()[i];
  1359.  
  1360.  
  1361.                         }
  1362.                         stemp[length+1]=0;
  1363.                         ctemp[indi_xpos]=0;
  1364.                         if(indi_xpos!=0)
  1365.                         {
  1366.                             Ltemp.loadFromRenderedText( ctemp, textColor );
  1367.                             final_indi_xpos=Ltemp.getWidth();
  1368.                         }
  1369.                         else
  1370.                             final_indi_xpos=0;
  1371.  
  1372.                         if(huda==1)
  1373.                         {
  1374.                             printf("%d %d %d %d\n",length,indi_xpos,final_indi_xpos,total_line );
  1375.                             huda=0;
  1376.                         }
  1377.  
  1378.  
  1379.                  
  1380.                   }
  1381.  
  1382.                
  1383.  
  1384.                     if( renderText )
  1385.                     {
  1386.  
  1387.                         if( inputText[current_line] != "" )
  1388.                         {
  1389.                             // //longer than window_width string
  1390.                             //  if(x!=0)
  1391.                             // {
  1392.                             //   x=0;
  1393.  
  1394.                             //     mainTextTexture[i].loadFromRenderedText( v[p], textColor );
  1395.  
  1396.                             // }
  1397.                          
  1398.  
  1399.  
  1400.                             //majhkhane kichu likhle
  1401.  
  1402.                             if(left_sign>=1&&mainTextTexture[current_line].getWidth()<SCREEN_WIDTH-100)
  1403.                             {
  1404.                                
  1405.                                 if(middle_backspace==0)
  1406.                                 {
  1407.                                    
  1408.                                     //ekhane ken eta disi jani na eita dile majhe kichu likhe Thikmoto kaj kore na .....left_sign++;
  1409.                                     for(int i=length-1;i>indi_xpos-1;i--)
  1410.                                     {
  1411.                                         char_temp=stemp[i];
  1412.                                         stemp[i]=stemp[i-1];
  1413.                                         stemp[i-1]=char_temp;
  1414.                                    
  1415.  
  1416.                                     }
  1417.                                        
  1418.                                      
  1419.                                 }
  1420.                                 else
  1421.                                 {
  1422.                                    
  1423.                                     for(int i=indi_xpos-1;i<length-1;i++)
  1424.                                     {
  1425.                                         char_temp=stemp[i];
  1426.                                         stemp[i]=stemp[i+1];
  1427.                                         stemp[i+1]=char_temp;
  1428.                                    
  1429.  
  1430.                                     }
  1431.                                     //left_sign--;
  1432.  
  1433.                                 }
  1434.                                 for(int i=0;i<=length;i++)inputText[current_line].pop_back();
  1435.                             }
  1436.  
  1437.  
  1438.                             inputText[current_line]=stemp;
  1439.                             if(middle_backspace!=0)
  1440.                             {
  1441.                                 middle_backspace=0;
  1442.                                 inputText[current_line].pop_back();
  1443.  
  1444.                             }
  1445.                             //printf("%d\n",total_line);
  1446.  
  1447.  
  1448.  
  1449.                             mainTextTexture[current_line].loadFromRenderedText( inputText[current_line].c_str(), textColor );
  1450.                      
  1451.  
  1452.                         }
  1453.  
  1454.                         else
  1455.                         {
  1456.                             mainTextTexture[current_line].loadFromRenderedText( " ", textColor );
  1457.                         }
  1458.                     }
  1459.  
  1460.  
  1461.                     //enter dile space nibe
  1462.  
  1463.                
  1464.                     if(flag==1)
  1465.                     {
  1466.                         flag=0;
  1467.                         inputText[current_line-1] +="@";
  1468.                         mainTextTexture[current_line-1].loadFromRenderedText( "@", textColor );
  1469.                     }
  1470.  
  1471.  
  1472.                     max_line=SCREEN_HEIGHT/50-2;
  1473.                     if( total_line>max_line)scroll_count=total_line-max_line;
  1474.                     else
  1475.                         scroll_count=0;
  1476.                     if(current_line<=scroll_count&&total_line!=0)up_sign=scroll_count-current_line;
  1477.                     else
  1478.                         up_sign=0;
  1479.  
  1480.                     SDL_SetRenderDrawColor( main_renderer, 0x00, 0x00, 0x00, 0xFF );
  1481.                     SDL_RenderClear( main_renderer );
  1482.  
  1483.  
  1484.                     SDL_RenderCopy(main_renderer, background_texture, NULL, NULL);
  1485.  
  1486.                         //for blinking indicaotr gDotTexture.render(final_indi_xpos,current_line*50+60);
  1487.                         c++;
  1488.                         if(c%70>=32) {
  1489.                         if(kontaBackground==3) SDL_SetRenderDrawColor( main_renderer, 0xFF, 0xFF, 0xFF, 0x00 );
  1490.                         else SDL_SetRenderDrawColor( main_renderer, 0x00, 0x00, 0x00, 0x00 );
  1491.                         SDL_RenderDrawLine( main_renderer, final_indi_xpos, (current_line-scroll_count+up_sign)*50+50,final_indi_xpos , (current_line-scroll_count+up_sign)*50+50+ 40 );
  1492.                       }
  1493.                         if(c>70)c=0;
  1494.  
  1495.  
  1496.                     header.render( 700,0);
  1497.                     for(int j=0; j<=total_line-scroll_count; j++ )   mainTextTexture[j+scroll_count-up_sign].render( 0, j*50+ 50 );
  1498.  
  1499.  
  1500.                     SDL_RenderPresent( main_renderer );
  1501.  
  1502.  
  1503.  
  1504.             }
  1505.             SDL_StopTextInput();
  1506.  
  1507.         }
  1508.     }
  1509.     close();
  1510.     return 0;
  1511. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement