mirror of
				https://github.com/Klagarge/PokeHES.git
				synced 2025-10-30 19:29:17 +00:00 
			
		
		
		
	finish format text
This commit is contained in:
		| @@ -16,6 +16,7 @@ import com.badlogic.gdx.maps.tiled.TmxMapLoader; | |||||||
| import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; | import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; | ||||||
| import com.badlogic.gdx.math.Vector2; | import com.badlogic.gdx.math.Vector2; | ||||||
|  |  | ||||||
|  | import Entity.Character.Direction; | ||||||
| import Entity.Player; | import Entity.Player; | ||||||
| import ch.hevs.gdx2d.components.screen_management.RenderingScreen; | import ch.hevs.gdx2d.components.screen_management.RenderingScreen; | ||||||
| import ch.hevs.gdx2d.lib.GdxGraphics; | import ch.hevs.gdx2d.lib.GdxGraphics; | ||||||
| @@ -160,7 +161,7 @@ public class ScreenMap extends RenderingScreen{ | |||||||
| 				try { Door.nextMap = mapProperties.get("nextMap").toString(); } catch (Exception e) { } | 				try { Door.nextMap = mapProperties.get("nextMap").toString(); } catch (Exception e) { } | ||||||
| 				try { Door.nextX = Integer.parseInt(mapProperties.get("nextX").toString()); } catch (Exception e) { } | 				try { Door.nextX = Integer.parseInt(mapProperties.get("nextX").toString()); } catch (Exception e) { } | ||||||
| 				try { Door.nextY = Integer.parseInt(mapProperties.get("nextY").toString()); } catch (Exception e) { } | 				try { Door.nextY = Integer.parseInt(mapProperties.get("nextY").toString()); } catch (Exception e) { } | ||||||
| 				try { Door.nextDirection = Door.nextDirection.valueOf(mapProperties.get("nextDirection").toString()); } catch (Exception e) { } | 				try { Door.nextDirection = Direction.valueOf(mapProperties.get("nextDirection").toString()); } catch (Exception e) { } | ||||||
| 			} | 			} | ||||||
|         } |         } | ||||||
|          |          | ||||||
|   | |||||||
| @@ -14,63 +14,75 @@ import java.util.RandomAccess; | |||||||
| class testYann{ | class testYann{ | ||||||
|     public static void main(String[] args) { |     public static void main(String[] args) { | ||||||
|  |  | ||||||
|         System.out.println(111); |  | ||||||
|          |          | ||||||
|         String line = "   Je vais te manger tout cru asdnkajsdh asl      "; |         String text = "aaaaaa aaaaaa\naaaaaa aaaaaa"; | ||||||
|  |         String newText =""; | ||||||
|         String cutLine = ""; |         String cutLine = ""; | ||||||
|         String newLine = ""; |         String newLine = ""; | ||||||
|  |  | ||||||
|         int cut = 12; |         int cut = 6; | ||||||
|  |  | ||||||
|         int startC = 0; |         int startC = 0; | ||||||
|         int stoppC = cut; |         int stoppC = cut; | ||||||
|  |  | ||||||
|         if(cut>line.length()-1){ |         String[] s = text.split("\n"); | ||||||
|             newLine  =line; |  | ||||||
|         } |  | ||||||
|         else{ |  | ||||||
|              |  | ||||||
|             char[] c = new char[line.length()]; |  | ||||||
|  |  | ||||||
|             for(int i=0; i<c.length;i++){ |         for(String line : s){ | ||||||
|                 c[i] = line.charAt(i); |             System.out.println(line); | ||||||
|  |  | ||||||
|  |             if(cut>line.length()-1){ | ||||||
|  |                 newLine  =line; | ||||||
|             } |             } | ||||||
|  |             else{ | ||||||
|  |  | ||||||
|  |  | ||||||
|             while(true){ |  | ||||||
|                 for(int i =stoppC; i>=startC; i--){ |  | ||||||
|                     if(c[i] == ' '){ |  | ||||||
|                         stoppC = i; |  | ||||||
|                         break; |  | ||||||
|                     } |  | ||||||
|                     else if(stoppC == c.length-1){ |  | ||||||
|                         break; |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 //découper le mot  |  | ||||||
|                 for(int i=startC;i<=stoppC;i++){ |  | ||||||
|                     cutLine += c[i]; |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 newLine +=  cutLine+"\n"; |  | ||||||
|                 cutLine = ""; |  | ||||||
|  |  | ||||||
|                 startC = stoppC + 1; |  | ||||||
|  |  | ||||||
|                  |                  | ||||||
|                 if(c.length-1-stoppC <=0){ |                 char[] c = new char[line.length()]; | ||||||
|                     break; |      | ||||||
|  |                 for(int i=0; i<c.length;i++){ | ||||||
|  |                     c[i] = line.charAt(i); | ||||||
|                 } |                 } | ||||||
|                 else if(c.length-1-stoppC <= cut){ |      | ||||||
|                     stoppC = c.length-1; |      | ||||||
|                 } |      | ||||||
|                 else{ |                 while(true){ | ||||||
|                     stoppC += cut; |                     for(int i =stoppC; i>=startC; i--){ | ||||||
|  |                         if(c[i] == ' '){ | ||||||
|  |                             stoppC = i; | ||||||
|  |                             break; | ||||||
|  |                         } | ||||||
|  |                         else if(stoppC == c.length-1){ | ||||||
|  |                             break; | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |      | ||||||
|  |                     //découper le mot  | ||||||
|  |                     for(int i=startC;i<=stoppC;i++){ | ||||||
|  |                         cutLine += c[i]; | ||||||
|  |                     } | ||||||
|  |      | ||||||
|  |                     newLine +=  cutLine+"\n"; | ||||||
|  |                     cutLine = ""; | ||||||
|  |      | ||||||
|  |                     startC = stoppC + 1; | ||||||
|  |      | ||||||
|  |                      | ||||||
|  |                     if(c.length-1-stoppC <=0){ | ||||||
|  |                         break; | ||||||
|  |                     } | ||||||
|  |                     else if(c.length-1-stoppC <= cut){ | ||||||
|  |                         stoppC = c.length-1; | ||||||
|  |                     } | ||||||
|  |                     else{ | ||||||
|  |                         stoppC += cut; | ||||||
|  |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  |             newText += newLine + "\n"; | ||||||
|  |          | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |          | ||||||
|          |          | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -78,7 +90,7 @@ class testYann{ | |||||||
|         |         | ||||||
|  |  | ||||||
|  |  | ||||||
|         System.out.println(newLine); |         System.out.println(newText); | ||||||
|  |  | ||||||
|          |          | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user