mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-14 17:58:01 +00:00
Merge branch 'remove_some_build_warnings' into 'master'
Remove some build warnings See merge request core-developers/forge!2219
This commit is contained in:
@@ -288,16 +288,17 @@ public class GuiChoose {
|
||||
public static List<CardView> manipulateCardList(final CMatchUI gui, final String title, final Iterable<CardView> cards, final Iterable<CardView> manipulable,
|
||||
final boolean toTop, final boolean toBottom, final boolean toAnywhere) {
|
||||
gui.setSelectables(manipulable);
|
||||
final Callable<List<CardView>> callable = new Callable<List<CardView>>() {
|
||||
@Override
|
||||
public List<CardView> call() {
|
||||
ListCardArea tempArea = ListCardArea.show(gui,title,cards,manipulable,toTop,toBottom,toAnywhere);
|
||||
// tempArea.pack();
|
||||
tempArea.show();
|
||||
final List<CardView> cardList = tempArea.getCards();
|
||||
return cardList;
|
||||
}
|
||||
};
|
||||
@SuppressWarnings("Convert2Lambda") // Avoid lambdas to maintain compatibility with Android 5 API
|
||||
final Callable<List<CardView>> callable = new Callable<List<CardView>>() {
|
||||
@Override
|
||||
public List<CardView> call() {
|
||||
ListCardArea tempArea = ListCardArea.show(gui,title,cards,manipulable,toTop,toBottom,toAnywhere);
|
||||
|
||||
// tempArea.pack();
|
||||
tempArea.setVisible(true);
|
||||
return tempArea.getCards();
|
||||
}
|
||||
};
|
||||
final FutureTask<List<CardView>> ft = new FutureTask<>(callable);
|
||||
FThreads.invokeInEdtAndWait(ft);
|
||||
gui.clearSelectables();
|
||||
|
||||
@@ -17,10 +17,9 @@ import forge.screens.home.EMenuGroup;
|
||||
import forge.screens.home.IVSubmenu;
|
||||
import forge.screens.home.VHomeUI;
|
||||
import forge.toolbox.*;
|
||||
import forge.util.storage.IStorage;
|
||||
import forge.util.Localizer;
|
||||
import forge.util.WordUtil;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.basic.BasicComboBoxRenderer;
|
||||
@@ -243,17 +242,15 @@ public enum VSubmenuQuestData implements IVSubmenu<CSubmenuQuestData> {
|
||||
cboAllowUnlocks.setSelected(true);
|
||||
|
||||
final Map<String, String> preconDescriptions = new HashMap<>();
|
||||
final IStorage<PreconDeck> preconDecks = QuestController.getPrecons();
|
||||
|
||||
for (final PreconDeck preconDeck : preconDecks) {
|
||||
for (final PreconDeck preconDeck : QuestController.getPrecons()) {
|
||||
if (QuestController.getPreconDeals(preconDeck).getMinWins() > 0) {
|
||||
continue;
|
||||
}
|
||||
final String name = preconDeck.getName();
|
||||
cbxPreconDeck.addItem(name);
|
||||
String description = preconDeck.getDescription();
|
||||
description = "<html>" + WordUtils.wrap(description, 40, "<br>", false) + "</html>";
|
||||
preconDescriptions.put(name, description);
|
||||
preconDescriptions.put(name, WordUtil.wordWrapAsHTML(description));
|
||||
}
|
||||
|
||||
// The cbx needs strictly typed renderer
|
||||
|
||||
@@ -28,8 +28,8 @@ import forge.properties.ForgeConstants;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.util.OperatingSystem;
|
||||
import forge.util.WordUtil;
|
||||
import forge.view.FView;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
@@ -1085,7 +1085,7 @@ public class FSkin {
|
||||
allSkins = new ArrayList<>();
|
||||
final List<String> skinDirectoryNames = getSkinDirectoryNames();
|
||||
for (String skinDirectoryName : skinDirectoryNames) {
|
||||
allSkins.add(WordUtils.capitalize(skinDirectoryName.replace('_', ' ')));
|
||||
allSkins.add(WordUtil.capitalize(skinDirectoryName.replace('_', ' ')));
|
||||
}
|
||||
Collections.sort(allSkins);
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ public class PlayerDetailsPanel extends JPanel {
|
||||
}
|
||||
|
||||
public void setToolTip(final String... args) {
|
||||
super.setToolTipText(String.format(tooltip, args));
|
||||
super.setToolTipText(String.format(tooltip, (Object) args));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,8 +12,8 @@ import forge.game.*;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.tournament.system.*;
|
||||
import forge.util.TextUtil;
|
||||
import forge.util.WordUtil;
|
||||
import forge.util.storage.IStorage;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.apache.commons.lang3.time.StopWatch;
|
||||
|
||||
import forge.deck.Deck;
|
||||
@@ -75,7 +75,7 @@ public class SimulateMatch {
|
||||
|
||||
GameType type = GameType.Constructed;
|
||||
if (params.containsKey("f")) {
|
||||
type = GameType.valueOf(WordUtils.capitalize(params.get("f").get(0)));
|
||||
type = GameType.valueOf(WordUtil.capitalize(params.get("f").get(0)));
|
||||
}
|
||||
|
||||
GameRules rules = new GameRules(type);
|
||||
|
||||
@@ -687,7 +687,7 @@ public class GifDecoder {
|
||||
} while ((blockSize > 0) && !err());
|
||||
}
|
||||
|
||||
public Animation getAnimation(PlayMode playType) {
|
||||
private Animation<TextureRegion> getAnimation(PlayMode playType) {
|
||||
int nrFrames = getFrameCount();
|
||||
Pixmap frame = getFrame(0);
|
||||
int width = frame.getWidth();
|
||||
@@ -725,12 +725,11 @@ public class GifDecoder {
|
||||
}
|
||||
float frameDuration = (float)getDelay(0);
|
||||
frameDuration /= 1000; // convert milliseconds into seconds
|
||||
Animation result = new Animation(frameDuration, texReg, playType);
|
||||
|
||||
return result;
|
||||
return new Animation<>(frameDuration, texReg, playType);
|
||||
}
|
||||
|
||||
public static Animation loadGIFAnimation(PlayMode playType, InputStream is) {
|
||||
public static Animation<TextureRegion> loadGIFAnimation(PlayMode playType, InputStream is) {
|
||||
GifDecoder gdec = new GifDecoder();
|
||||
gdec.read(is);
|
||||
return gdec.getAnimation(playType);
|
||||
|
||||
@@ -3,9 +3,9 @@ package forge.assets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.util.WordUtil;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import forge.Forge;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
@@ -102,7 +102,7 @@ public class FSkin {
|
||||
allSkins = new Array<>();
|
||||
final Array<String> skinDirectoryNames = getSkinDirectoryNames();
|
||||
for (final String skinDirectoryName : skinDirectoryNames) {
|
||||
allSkins.add(WordUtils.capitalize(skinDirectoryName.replace('_', ' ')));
|
||||
allSkins.add(WordUtil.capitalize(skinDirectoryName.replace('_', ' ')));
|
||||
}
|
||||
allSkins.sort();
|
||||
}
|
||||
|
||||
@@ -47,15 +47,10 @@ import forge.util.FileUtil;
|
||||
import forge.util.ThreadUtil;
|
||||
import forge.util.Utils;
|
||||
import forge.util.gui.SOptionPane;
|
||||
import forge.util.storage.IStorage;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -282,18 +277,12 @@ public class NewQuestScreen extends FScreen {
|
||||
|
||||
cbAllowUnlocks.setSelected(true);
|
||||
|
||||
final Map<String, String> preconDescriptions = new HashMap<>();
|
||||
IStorage<PreconDeck> preconDecks = QuestController.getPrecons();
|
||||
|
||||
for (PreconDeck preconDeck : preconDecks) {
|
||||
for (PreconDeck preconDeck : QuestController.getPrecons()) {
|
||||
if (QuestController.getPreconDeals(preconDeck).getMinWins() > 0) {
|
||||
continue;
|
||||
}
|
||||
String name = preconDeck.getName();
|
||||
cbxPreconDeck.addItem(name);
|
||||
String description = preconDeck.getDescription();
|
||||
description = "<html>" + WordUtils.wrap(description, 40, "<br>", false) + "</html>";
|
||||
preconDescriptions.put(name, description);
|
||||
}
|
||||
|
||||
// disable the very powerful sets -- they can be unlocked later for a high price
|
||||
|
||||
@@ -264,12 +264,8 @@ public abstract class GuiDownloadService implements Runnable {
|
||||
count++;
|
||||
cardSkipped = true; //assume skipped unless saved successfully
|
||||
String url = kv.getValue();
|
||||
/*
|
||||
* decode URL Key, Reverted to old version,
|
||||
* on Android 6.0 it throws an error
|
||||
* when you download the card price
|
||||
*/
|
||||
String decodedKey = URLDecoder.decode(kv.getKey());
|
||||
|
||||
String decodedKey = decodeURL(kv.getKey());
|
||||
final File fileDest = new File(decodedKey);
|
||||
final String filePath = fileDest.getPath();
|
||||
final String subLastIndex = filePath.contains("pics") ? "\\pics\\" : "\\db\\";
|
||||
@@ -365,6 +361,16 @@ public abstract class GuiDownloadService implements Runnable {
|
||||
GuiBase.getInterface().preventSystemSleep(false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static String decodeURL(String key) {
|
||||
/*
|
||||
* decode URL Key, Reverted to old version,
|
||||
* on Android 6.0 it throws an error
|
||||
* when you download the card price
|
||||
*/
|
||||
return URLDecoder.decode(key);
|
||||
}
|
||||
|
||||
protected Proxy getProxy() {
|
||||
if (type == 0) {
|
||||
return Proxy.NO_PROXY;
|
||||
@@ -385,7 +391,7 @@ public abstract class GuiDownloadService implements Runnable {
|
||||
|
||||
protected static void addMissingItems(Map<String, String> list, String nameUrlFile, String dir) {
|
||||
for (Pair<String, String> nameUrlPair : FileUtil.readNameUrlFile(nameUrlFile)) {
|
||||
File f = new File(dir, URLDecoder.decode(nameUrlPair.getLeft()));
|
||||
File f = new File(dir, decodeURL(nameUrlPair.getLeft()));
|
||||
//System.out.println(f.getAbsolutePath());
|
||||
if (!f.exists()) {
|
||||
list.put(f.getAbsolutePath(), nameUrlPair.getRight());
|
||||
|
||||
87
forge-gui/src/main/java/forge/util/WordUtil.java
Normal file
87
forge-gui/src/main/java/forge/util/WordUtil.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package forge.util;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class WordUtil {
|
||||
public static String capitalize(String str) {
|
||||
if (StringUtils.isEmpty(str)) {
|
||||
return str;
|
||||
}
|
||||
final char[] buffer = str.toCharArray();
|
||||
boolean capitalizeNext = true;
|
||||
for (int i = 0; i < buffer.length; i++) {
|
||||
final char ch = buffer[i];
|
||||
if (Character.isWhitespace(ch)) {
|
||||
capitalizeNext = true;
|
||||
} else if (capitalizeNext) {
|
||||
buffer[i] = Character.toTitleCase(ch);
|
||||
capitalizeNext = false;
|
||||
}
|
||||
}
|
||||
return new String(buffer);
|
||||
}
|
||||
|
||||
private final static Pattern patternToWrapOn = Pattern.compile(" ");
|
||||
public static String wordWrapAsHTML(String str) {
|
||||
String result = null;
|
||||
int wrapLength = 40;
|
||||
String newLineStr = "<br>";
|
||||
if (str != null) {
|
||||
final int inputLineLength = str.length();
|
||||
int offset = 0;
|
||||
final StringBuilder wrappedLine = new StringBuilder(inputLineLength + 32);
|
||||
while (offset < inputLineLength) {
|
||||
int spaceToWrapAt = -1;
|
||||
Matcher matcher = patternToWrapOn.matcher(str.substring(offset, Math.min(offset + wrapLength + 1, inputLineLength)));
|
||||
if (matcher.find()) {
|
||||
if (matcher.start() == 0) {
|
||||
offset += matcher.end();
|
||||
continue;
|
||||
}
|
||||
spaceToWrapAt = matcher.start() + offset;
|
||||
}
|
||||
|
||||
// only last line without leading spaces is left
|
||||
if (inputLineLength - offset <= wrapLength) {
|
||||
break;
|
||||
}
|
||||
|
||||
while (matcher.find()) {
|
||||
spaceToWrapAt = matcher.start() + offset;
|
||||
}
|
||||
|
||||
if (spaceToWrapAt >= offset) {
|
||||
// normal case
|
||||
wrappedLine.append(str, offset, spaceToWrapAt);
|
||||
wrappedLine.append(newLineStr);
|
||||
offset = spaceToWrapAt + 1;
|
||||
|
||||
} else {
|
||||
// do not wrap really long word, just extend beyond limit
|
||||
matcher = patternToWrapOn.matcher(str.substring(offset + wrapLength));
|
||||
if (matcher.find()) {
|
||||
spaceToWrapAt = matcher.start() + offset + wrapLength;
|
||||
}
|
||||
|
||||
if (spaceToWrapAt >= 0) {
|
||||
wrappedLine.append(str, offset, spaceToWrapAt);
|
||||
wrappedLine.append(newLineStr);
|
||||
offset = spaceToWrapAt + 1;
|
||||
} else {
|
||||
wrappedLine.append(str, offset, str.length());
|
||||
offset = inputLineLength;
|
||||
}
|
||||
}
|
||||
}// Whatever is left in line is short enough to just pass through
|
||||
wrappedLine.append(str, offset, str.length());
|
||||
result = wrappedLine.toString();
|
||||
}
|
||||
|
||||
return "<html>" + result + "</html>";
|
||||
}
|
||||
|
||||
private WordUtil() {}
|
||||
}
|
||||
Reference in New Issue
Block a user