v0.9.4: switched from spaces to tabs in new iOS code
This commit is contained in:
parent
5ad6594786
commit
603f91d10f
|
@ -22,82 +22,83 @@ import org.robovm.apple.glkit.GLKViewDrawableDepthFormat;
|
||||||
import org.robovm.apple.uikit.UIApplication;
|
import org.robovm.apple.uikit.UIApplication;
|
||||||
|
|
||||||
public class IOSLauncher extends IOSApplication.Delegate {
|
public class IOSLauncher extends IOSApplication.Delegate {
|
||||||
@Override
|
@Override
|
||||||
protected IOSApplication createApplication() {
|
protected IOSApplication createApplication() {
|
||||||
|
|
||||||
//ensures the app actually crashes if there's an error in the mobiVM runtime
|
//ensures the app actually crashes if there's an error in the mobiVM runtime
|
||||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||||
public void uncaughtException(Thread thread, Throwable ex) {
|
public void uncaughtException(Thread thread, Throwable ex) {
|
||||||
new NSException(ex.getClass().getName(), ex.getMessage(), new NSDictionary()).raise();
|
new NSException(ex.getClass().getName(), ex.getMessage(), new NSDictionary()).raise();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Game.version = NSBundle.getMainBundle().getInfoDictionaryObject("CFBundleVersionString").toString();
|
Game.version = NSBundle.getMainBundle().getInfoDictionaryObject("CFBundleVersionString").toString();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Game.version = "???";
|
Game.version = "???";
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Game.versionCode = Integer.parseInt(NSBundle.getMainBundle().getInfoDictionaryObject("CFBundleVersion").toString());
|
Game.versionCode = Integer.parseInt(NSBundle.getMainBundle().getInfoDictionaryObject("CFBundleVersion").toString());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Game.versionCode = 0;
|
Game.versionCode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UpdateImpl.supportsUpdates()) {
|
|
||||||
Updates.service = UpdateImpl.getUpdateService();
|
|
||||||
}
|
|
||||||
if (NewsImpl.supportsNews()) {
|
|
||||||
News.service = NewsImpl.getNewsService();
|
|
||||||
}
|
|
||||||
|
|
||||||
FileUtils.setDefaultFileProperties(Files.FileType.Local, "");
|
if (UpdateImpl.supportsUpdates()) {
|
||||||
|
Updates.service = UpdateImpl.getUpdateService();
|
||||||
|
}
|
||||||
|
if (NewsImpl.supportsNews()) {
|
||||||
|
News.service = NewsImpl.getNewsService();
|
||||||
|
}
|
||||||
|
|
||||||
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
|
FileUtils.setDefaultFileProperties(Files.FileType.Local, "");
|
||||||
|
|
||||||
config.colorFormat = GLKViewDrawableColorFormat.RGBA8888;
|
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
|
||||||
config.depthFormat = GLKViewDrawableDepthFormat.None;
|
|
||||||
config.hdpiMode = HdpiMode.Pixels;
|
|
||||||
|
|
||||||
CGRect statusBarFrame = UIApplication.getSharedApplication().getStatusBarFrame();
|
config.colorFormat = GLKViewDrawableColorFormat.RGBA8888;
|
||||||
double statusBarHeight = Math.min(statusBarFrame.getWidth(), statusBarFrame.getHeight());
|
config.depthFormat = GLKViewDrawableDepthFormat.None;
|
||||||
|
config.hdpiMode = HdpiMode.Pixels;
|
||||||
|
|
||||||
//if the application has a short status bar (no notch), then hide it
|
CGRect statusBarFrame = UIApplication.getSharedApplication().getStatusBarFrame();
|
||||||
//TODO we do this check elsewhere now, can this be removed?
|
double statusBarHeight = Math.min(statusBarFrame.getWidth(), statusBarFrame.getHeight());
|
||||||
if (statusBarHeight <= 24) {
|
|
||||||
UIApplication.getSharedApplication().setStatusBarHidden(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
config.useAccelerometer = false;
|
//if the application has a short status bar (no notch), then hide it
|
||||||
config.useCompass = false;
|
//TODO we do this check elsewhere now, can this be removed?
|
||||||
|
if (statusBarHeight <= 24) {
|
||||||
|
UIApplication.getSharedApplication().setStatusBarHidden(true);
|
||||||
|
}
|
||||||
|
|
||||||
//devices not currently listed in LibGDX's IOSDevice class
|
config.useAccelerometer = false;
|
||||||
config.addIosDevice("IPHONE_12_MINI", "iPhone13,1", 476);
|
config.useCompass = false;
|
||||||
config.addIosDevice("IPHONE_12", "iPhone13,2", 460);
|
|
||||||
config.addIosDevice("IPHONE_12_PRO", "iPhone13,3", 460);
|
|
||||||
config.addIosDevice("IPHONE_12_PRO_MAX", "iPhone13,4", 458);
|
|
||||||
|
|
||||||
config.addIosDevice("IPAD_7G_WIFI", "iPad7,11", 264);
|
//devices not currently listed in LibGDX's IOSDevice class
|
||||||
config.addIosDevice("IPAD_7G_WIFI_CELLULAR", "iPad7,12", 264);
|
config.addIosDevice("IPHONE_12_MINI", "iPhone13,1", 476);
|
||||||
|
config.addIosDevice("IPHONE_12", "iPhone13,2", 460);
|
||||||
|
config.addIosDevice("IPHONE_12_PRO", "iPhone13,3", 460);
|
||||||
|
config.addIosDevice("IPHONE_12_PRO_MAX", "iPhone13,4", 458);
|
||||||
|
|
||||||
config.addIosDevice("IPAD_8G_WIFI", "iPad11,6", 264);
|
config.addIosDevice("IPAD_7G_WIFI", "iPad7,11", 264);
|
||||||
config.addIosDevice("IPAD_8G_WIFI_CELLULAR", "iPad11,7", 264);
|
config.addIosDevice("IPAD_7G_WIFI_CELLULAR", "iPad7,12", 264);
|
||||||
config.addIosDevice("IPAD_AIR_4G_WIFI", "iPad13,1", 264);
|
|
||||||
config.addIosDevice("IPAD_AIR_4G_WIFI_CELLULAR", "iPad13,2", 264);
|
|
||||||
config.addIosDevice("IPAD_PRO_11_3G", "iPad13,4", 264);
|
|
||||||
config.addIosDevice("IPAD_PRO_11_3G", "iPad13,5", 264);
|
|
||||||
config.addIosDevice("IPAD_PRO_11_3G", "iPad13,6", 264);
|
|
||||||
config.addIosDevice("IPAD_PRO_11_3G", "iPad13,7", 264);
|
|
||||||
config.addIosDevice("IPAD_PRO_12.8_5G", "iPad13,8", 264);
|
|
||||||
config.addIosDevice("IPAD_PRO_12.8_5G", "iPad13,9", 264);
|
|
||||||
config.addIosDevice("IPAD_PRO_12.8_5G", "iPad13,10", 264);
|
|
||||||
config.addIosDevice("IPAD_PRO_12.8_5G", "iPad13,11", 264);
|
|
||||||
|
|
||||||
return new IOSApplication(new ShatteredPixelDungeon(new IOSPlatformSupport()), config);
|
config.addIosDevice("IPAD_8G_WIFI", "iPad11,6", 264);
|
||||||
}
|
config.addIosDevice("IPAD_8G_WIFI_CELLULAR", "iPad11,7", 264);
|
||||||
|
config.addIosDevice("IPAD_AIR_4G_WIFI", "iPad13,1", 264);
|
||||||
|
config.addIosDevice("IPAD_AIR_4G_WIFI_CELLULAR", "iPad13,2", 264);
|
||||||
|
config.addIosDevice("IPAD_PRO_11_3G", "iPad13,4", 264);
|
||||||
|
config.addIosDevice("IPAD_PRO_11_3G", "iPad13,5", 264);
|
||||||
|
config.addIosDevice("IPAD_PRO_11_3G", "iPad13,6", 264);
|
||||||
|
config.addIosDevice("IPAD_PRO_11_3G", "iPad13,7", 264);
|
||||||
|
config.addIosDevice("IPAD_PRO_12.8_5G", "iPad13,8", 264);
|
||||||
|
config.addIosDevice("IPAD_PRO_12.8_5G", "iPad13,9", 264);
|
||||||
|
config.addIosDevice("IPAD_PRO_12.8_5G", "iPad13,10", 264);
|
||||||
|
config.addIosDevice("IPAD_PRO_12.8_5G", "iPad13,11", 264);
|
||||||
|
|
||||||
public static void main(String[] argv) {
|
return new IOSApplication(new ShatteredPixelDungeon(new IOSPlatformSupport()), config);
|
||||||
NSAutoreleasePool pool = new NSAutoreleasePool();
|
}
|
||||||
UIApplication.main(argv, null, IOSLauncher.class);
|
|
||||||
pool.close();
|
public static void main(String[] argv) {
|
||||||
}
|
NSAutoreleasePool pool = new NSAutoreleasePool();
|
||||||
|
UIApplication.main(argv, null, IOSLauncher.class);
|
||||||
|
pool.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,113 +21,113 @@ import java.util.HashMap;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class IOSPlatformSupport extends PlatformSupport {
|
public class IOSPlatformSupport extends PlatformSupport {
|
||||||
@Override
|
@Override
|
||||||
public void updateDisplaySize() {
|
public void updateDisplaySize() {
|
||||||
//non-zero safe insets on left/top/right means device has a notch, show status bar
|
//non-zero safe insets on left/top/right means device has a notch, show status bar
|
||||||
if (Gdx.graphics.getSafeInsetTop() != 0
|
if (Gdx.graphics.getSafeInsetTop() != 0
|
||||||
|| Gdx.graphics.getSafeInsetLeft() != 0
|
|| Gdx.graphics.getSafeInsetLeft() != 0
|
||||||
|| Gdx.graphics.getSafeInsetRight() != 0){
|
|| Gdx.graphics.getSafeInsetRight() != 0){
|
||||||
UIApplication.getSharedApplication().setStatusBarHidden(false);
|
UIApplication.getSharedApplication().setStatusBarHidden(false);
|
||||||
} else {
|
} else {
|
||||||
UIApplication.getSharedApplication().setStatusBarHidden(true);
|
UIApplication.getSharedApplication().setStatusBarHidden(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SPDSettings.fullscreen()) {
|
if (!SPDSettings.fullscreen()) {
|
||||||
Game.bottomInset = Gdx.graphics.getSafeInsetBottom();
|
Game.bottomInset = Gdx.graphics.getSafeInsetBottom();
|
||||||
Game.height -= Game.bottomInset;
|
Game.height -= Game.bottomInset;
|
||||||
Game.dispHeight = Game.height;
|
Game.dispHeight = Game.height;
|
||||||
} else {
|
} else {
|
||||||
Game.height += Game.bottomInset;
|
Game.height += Game.bottomInset;
|
||||||
Game.dispHeight = Game.height;
|
Game.dispHeight = Game.height;
|
||||||
Game.bottomInset = 0;
|
Game.bottomInset = 0;
|
||||||
}
|
}
|
||||||
Gdx.gl.glViewport(0, Game.bottomInset, Game.width, Game.height);
|
Gdx.gl.glViewport(0, Game.bottomInset, Game.width, Game.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateSystemUI() {
|
public void updateSystemUI() {
|
||||||
updateDisplaySize();
|
updateDisplaySize();
|
||||||
ShatteredPixelDungeon.seamlessResetScene();
|
ShatteredPixelDungeon.seamlessResetScene();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean connectedToUnmeteredNetwork() {
|
public boolean connectedToUnmeteredNetwork() {
|
||||||
SCNetworkReachability test = new SCNetworkReachability("www.apple.com");
|
SCNetworkReachability test = new SCNetworkReachability("www.apple.com");
|
||||||
return !test.getFlags().contains(SCNetworkReachabilityFlags.IsWWAN);
|
return !test.getFlags().contains(SCNetworkReachabilityFlags.IsWWAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void vibrate( int millis ){
|
public void vibrate( int millis ){
|
||||||
//gives a short vibrate on iPhone 6+, no vibration otherwise
|
//gives a short vibrate on iPhone 6+, no vibration otherwise
|
||||||
AudioServices.playSystemSound(1520);
|
AudioServices.playSystemSound(1520);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FONT SUPPORT */
|
/* FONT SUPPORT */
|
||||||
|
|
||||||
//custom pixel font, for use with Latin and Cyrillic languages
|
//custom pixel font, for use with Latin and Cyrillic languages
|
||||||
private static FreeTypeFontGenerator basicFontGenerator;
|
private static FreeTypeFontGenerator basicFontGenerator;
|
||||||
//droid sans fallback, for asian fonts
|
//droid sans fallback, for asian fonts
|
||||||
private static FreeTypeFontGenerator asianFontGenerator;
|
private static FreeTypeFontGenerator asianFontGenerator;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setupFontGenerators(int pageSize, boolean systemfont) {
|
public void setupFontGenerators(int pageSize, boolean systemfont) {
|
||||||
//don't bother doing anything if nothing has changed
|
//don't bother doing anything if nothing has changed
|
||||||
if (fonts != null && this.pageSize == pageSize && this.systemfont == systemfont){
|
if (fonts != null && this.pageSize == pageSize && this.systemfont == systemfont){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.pageSize = pageSize;
|
this.pageSize = pageSize;
|
||||||
this.systemfont = systemfont;
|
this.systemfont = systemfont;
|
||||||
|
|
||||||
resetGenerators(false);
|
resetGenerators(false);
|
||||||
fonts = new HashMap<>();
|
fonts = new HashMap<>();
|
||||||
|
|
||||||
if (systemfont) {
|
if (systemfont) {
|
||||||
basicFontGenerator = asianFontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/droid_sans.ttf"));
|
basicFontGenerator = asianFontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/droid_sans.ttf"));
|
||||||
} else {
|
} else {
|
||||||
basicFontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/pixel_font.ttf"));
|
basicFontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/pixel_font.ttf"));
|
||||||
asianFontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/droid_sans.ttf"));
|
asianFontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/droid_sans.ttf"));
|
||||||
}
|
}
|
||||||
|
|
||||||
fonts.put(basicFontGenerator, new HashMap<>());
|
fonts.put(basicFontGenerator, new HashMap<>());
|
||||||
fonts.put(asianFontGenerator, new HashMap<>());
|
fonts.put(asianFontGenerator, new HashMap<>());
|
||||||
|
|
||||||
packer = new PixmapPacker(pageSize, pageSize, Pixmap.Format.RGBA8888, 1, false);
|
packer = new PixmapPacker(pageSize, pageSize, Pixmap.Format.RGBA8888, 1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Pattern asianMatcher = Pattern.compile("\\p{InHangul_Syllables}|" +
|
private static Pattern asianMatcher = Pattern.compile("\\p{InHangul_Syllables}|" +
|
||||||
"\\p{InCJK_Unified_Ideographs}|\\p{InCJK_Symbols_and_Punctuation}|\\p{InHalfwidth_and_Fullwidth_Forms}|" +
|
"\\p{InCJK_Unified_Ideographs}|\\p{InCJK_Symbols_and_Punctuation}|\\p{InHalfwidth_and_Fullwidth_Forms}|" +
|
||||||
"\\p{InHiragana}|\\p{InKatakana}");
|
"\\p{InHiragana}|\\p{InKatakana}");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FreeTypeFontGenerator getGeneratorForString( String input ){
|
protected FreeTypeFontGenerator getGeneratorForString( String input ){
|
||||||
if (asianMatcher.matcher(input).find()){
|
if (asianMatcher.matcher(input).find()){
|
||||||
return asianFontGenerator;
|
return asianFontGenerator;
|
||||||
} else {
|
} else {
|
||||||
return basicFontGenerator;
|
return basicFontGenerator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//splits on newlines, underscores, and chinese/japaneses characters
|
//splits on newlines, underscores, and chinese/japaneses characters
|
||||||
private Pattern regularsplitter = Pattern.compile(
|
private Pattern regularsplitter = Pattern.compile(
|
||||||
"(?<=\n)|(?=\n)|(?<=_)|(?=_)|" +
|
"(?<=\n)|(?=\n)|(?<=_)|(?=_)|" +
|
||||||
"(?<=\\p{InHiragana})|(?=\\p{InHiragana})|" +
|
"(?<=\\p{InHiragana})|(?=\\p{InHiragana})|" +
|
||||||
"(?<=\\p{InKatakana})|(?=\\p{InKatakana})|" +
|
"(?<=\\p{InKatakana})|(?=\\p{InKatakana})|" +
|
||||||
"(?<=\\p{InCJK_Unified_Ideographs})|(?=\\p{InCJK_Unified_Ideographs})|" +
|
"(?<=\\p{InCJK_Unified_Ideographs})|(?=\\p{InCJK_Unified_Ideographs})|" +
|
||||||
"(?<=\\p{InCJK_Symbols_and_Punctuation})|(?=\\p{InCJK_Symbols_and_Punctuation})");
|
"(?<=\\p{InCJK_Symbols_and_Punctuation})|(?=\\p{InCJK_Symbols_and_Punctuation})");
|
||||||
|
|
||||||
//additionally splits on words, so that each word can be arranged individually
|
//additionally splits on words, so that each word can be arranged individually
|
||||||
private Pattern regularsplitterMultiline = Pattern.compile(
|
private Pattern regularsplitterMultiline = Pattern.compile(
|
||||||
"(?<= )|(?= )|(?<=\n)|(?=\n)|(?<=_)|(?=_)|" +
|
"(?<= )|(?= )|(?<=\n)|(?=\n)|(?<=_)|(?=_)|" +
|
||||||
"(?<=\\p{InHiragana})|(?=\\p{InHiragana})|" +
|
"(?<=\\p{InHiragana})|(?=\\p{InHiragana})|" +
|
||||||
"(?<=\\p{InKatakana})|(?=\\p{InKatakana})|" +
|
"(?<=\\p{InKatakana})|(?=\\p{InKatakana})|" +
|
||||||
"(?<=\\p{InCJK_Unified_Ideographs})|(?=\\p{InCJK_Unified_Ideographs})|" +
|
"(?<=\\p{InCJK_Unified_Ideographs})|(?=\\p{InCJK_Unified_Ideographs})|" +
|
||||||
"(?<=\\p{InCJK_Symbols_and_Punctuation})|(?=\\p{InCJK_Symbols_and_Punctuation})");
|
"(?<=\\p{InCJK_Symbols_and_Punctuation})|(?=\\p{InCJK_Symbols_and_Punctuation})");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] splitforTextBlock(String text, boolean multiline) {
|
public String[] splitforTextBlock(String text, boolean multiline) {
|
||||||
if (multiline) {
|
if (multiline) {
|
||||||
return regularsplitterMultiline.split(text);
|
return regularsplitterMultiline.split(text);
|
||||||
} else {
|
} else {
|
||||||
return regularsplitter.split(text);
|
return regularsplitter.split(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user