Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

pes 2012 editor capitalizer patch

By: a guest on Jan 2nd, 2012  |  syntax: Diff  |  size: 5.13 KB  |  views: 184  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. diff -ru ./src/editor/GlobalPanel.java /home/diego/workspace/editor2012/src/editor/GlobalPanel.java
  2. --- ./src/editor/GlobalPanel.java       2009-11-21 11:22:47.000000000 +0000
  3. +++ /home/diego/workspace/editor2012/src/editor/GlobalPanel.java        2012-01-02 22:14:00.000000000 +0000
  4. @@ -18,6 +18,33 @@
  5.   *
  6.   * You should have received a copy of the GNU General Public License
  7.   * along with PES Editor.  If not, see <http://www.gnu.org/licenses/>.
  8. + *
  9. + *
  10. + * The functions:
  11. + *
  12. + *  public static String capitalizeFully(String str, char[] delimiters)
  13. + *  private static String capitalize(String str, char[] delimiters)
  14. + *  private static boolean isDelimiter(char ch, char[] delimiters)
  15. + *  
  16. + * have been derived from the Apache Commons 2.5 WordUtils package, under the
  17. + * Apache License, Version 2.0, that can be downloaded from:
  18. + *
  19. + * http://commons.apache.org/lang/
  20. + *
  21. + * Licensed to the Apache Software Foundation (ASF) under one or more
  22. + * contributor license agreements.  See the NOTICE file distributed with
  23. + * this work for additional information regarding copyright ownership.
  24. + * The ASF licenses this file to You under the Apache License, Version 2.0
  25. + * (the "License"); you may not use this file except in compliance with
  26. + * the License.  You may obtain a copy of the License at
  27. + *
  28. + *      http://www.apache.org/licenses/LICENSE-2.0
  29. + *
  30. + * Unless required by applicable law or agreed to in writing, software
  31. + * distributed under the License is distributed on an "AS IS" BASIS,
  32. + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  33. + * See the License for the specific language governing permissions and
  34. + * limitations under the License.
  35.   */
  36.  
  37.  package editor;
  38. @@ -44,7 +71,7 @@
  39.  
  40.         private JComboBox opBox;
  41.  
  42. -       private JButton doButton;
  43. +       private JButton doButton, uppercaseButton, lowercaseButton;
  44.  
  45.         private JComboBox scopeBox;
  46.  
  47. @@ -81,8 +108,10 @@
  48.                 JPanel panel99 = new JPanel();
  49.                 JPanel scopePanel = new JPanel(new GridLayout(2, 3));
  50.                 JPanel main = new JPanel(new GridLayout(0, 1));
  51. +               JPanel casepanel = new JPanel();
  52.                 scopePanel.setBorder(BorderFactory.createTitledBorder("Scope"));
  53.                 panel99.setBorder(BorderFactory.createTitledBorder("Adjustment"));
  54. +               casepanel.setBorder(BorderFactory.createTitledBorder("Modify player names"));
  55.                 scopeBox = new JComboBox(scopes);
  56.                 teamBox = new JComboBox();
  57.                 checkBox = new JCheckBox();
  58. @@ -334,6 +363,39 @@
  59.                                 }
  60.                         }
  61.                 });
  62. +              
  63. +               uppercaseButton = new JButton("To uppercase");
  64. +               uppercaseButton.addActionListener(new ActionListener() {
  65. +                       public void actionPerformed(ActionEvent a) {
  66. +                               for (int p = 1; p < Player.total; p++) {
  67. +                                       Player play = new Player(of, p, 0);
  68. +                                       String newName = play.name.toUpperCase();
  69. +                                       play.setName(newName);
  70. +                               }
  71. +                       }
  72. +               });
  73. +              
  74. +              
  75. +               lowercaseButton = new JButton("Capitalize");
  76. +               lowercaseButton.addActionListener(new ActionListener() {
  77. +                       public void actionPerformed(ActionEvent a) {
  78. +                               char delimiters[] = {' ', '.', '-', '\''};
  79. +                               for (int p = 1; p < Player.total; p++) {
  80. +                                       Player play = new Player(of, p, 0);
  81. +                                       String newName = capitalizeFully(play.name, delimiters);
  82. +                                      
  83. +                                       if (play.name.startsWith("MC"))
  84. +                                               newName = "Mc" + capitalizeFully(newName.substring(2), delimiters);
  85. +                                      
  86. +                                       //newName.spl
  87. +
  88. +                                       play.setName(newName);
  89. +                               }
  90. +                       }
  91. +               });
  92. +              
  93. +              
  94. +              
  95.                 scopePanel.add(new JLabel("Registered Position:"));
  96.                 scopePanel.add(new JLabel("Exclude Team:"));
  97.                 scopePanel.add(new JLabel("Created Players:"));
  98. @@ -344,8 +406,11 @@
  99.                 panel99.add(opBox);
  100.                 panel99.add(numField);
  101.                 panel99.add(doButton);
  102. +               casepanel.add(uppercaseButton);
  103. +               casepanel.add(lowercaseButton);
  104.                 main.add(scopePanel);
  105.                 main.add(panel99);
  106. +               main.add(casepanel);
  107.                 add(main);
  108.         }
  109.  
  110. @@ -475,4 +540,53 @@
  111.                 return result;
  112.         }
  113.  
  114. +              
  115. +       public static String capitalizeFully(String str, char[] delimiters) {
  116. +               int delimLen = (delimiters == null ? -1 : delimiters.length);
  117. +               if (str == null || str.length() == 0 || delimLen == 0) {
  118. +                       return str;
  119. +               }
  120. +               str = str.toLowerCase();
  121. +               return capitalize(str, delimiters);
  122. +       }
  123. +
  124. +
  125. +       private static String capitalize(String str, char[] delimiters) {
  126. +               int delimLen = (delimiters == null ? -1 : delimiters.length);
  127. +               if (str == null || str.length() == 0 || delimLen == 0) {
  128. +                       return str;
  129. +               }
  130. +
  131. +               int strLen = str.length();
  132. +               StringBuffer buffer = new StringBuffer(strLen);
  133. +               boolean capitalizeNext = true;
  134. +               for (int i = 0; i < strLen; i++) {
  135. +                       char ch = str.charAt(i);                                         
  136. +                       if (isDelimiter(ch, delimiters)) {
  137. +                               buffer.append(ch);
  138. +                               capitalizeNext = true;
  139. +                       } else if (capitalizeNext) {
  140. +                               buffer.append(Character.toTitleCase(ch));
  141. +                               capitalizeNext = false;
  142. +                       } else {
  143. +                               buffer.append(ch);
  144. +                       }
  145. +               }
  146. +
  147. +               return buffer.toString();
  148. +       }
  149. +
  150. +       private static boolean isDelimiter(char ch, char[] delimiters) {
  151. +               if (delimiters == null) {
  152. +                       return Character.isWhitespace(ch);
  153. +               }
  154. +               for (int i = 0, isize = delimiters.length; i < isize; i++) {
  155. +                       if (ch == delimiters[i]) {
  156. +                               return true;
  157. +                       }
  158. +               }
  159. +               return false;
  160. +       }
  161. +
  162. +
  163.  }