mirror of
https://github.com/love2d/love-android.git
synced 2026-08-20 04:31:26 +02:00
Updated to latest LÖVE code 2f5d329b07d7 (android: disable JIT by default as it may cause performance problems)
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest package="org.love2d.android"
|
<manifest package="org.love2d.android"
|
||||||
android:versionCode="17"
|
android:versionCode="19"
|
||||||
android:versionName="0.10.0-alpha2"
|
android:versionName="0.10.0"
|
||||||
android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
|
android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2006-2015 LOVE Development Team
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef LOVE_OSX_H
|
|
||||||
#define LOVE_OSX_H
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#ifdef LOVE_MACOSX
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace love
|
|
||||||
{
|
|
||||||
namespace osx
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the filepath of the first detected love file in the Resources folder
|
|
||||||
* in the main bundle (love.app.)
|
|
||||||
* Returns an empty string if no love file is found.
|
|
||||||
**/
|
|
||||||
std::string getLoveInResources();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks for drop-file events. Returns the filepath if an event occurred, or
|
|
||||||
* an empty string otherwise.
|
|
||||||
**/
|
|
||||||
std::string checkDropEvents();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the full path to the executable.
|
|
||||||
**/
|
|
||||||
std::string getExecutablePath();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bounce the dock icon, if the app isn't in the foreground.
|
|
||||||
**/
|
|
||||||
void requestAttention(bool continuous);
|
|
||||||
|
|
||||||
} // osx
|
|
||||||
} // love
|
|
||||||
|
|
||||||
#endif // LOVE_MACOSX
|
|
||||||
|
|
||||||
#endif // LOVE_OSX_H
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2006-2015 LOVE Development Team
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
|
||||||
**/
|
|
||||||
|
|
||||||
#include "OSX.h"
|
|
||||||
|
|
||||||
#ifdef LOVE_MACOSX
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#import <Cocoa/Cocoa.h>
|
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
|
|
||||||
namespace love
|
|
||||||
{
|
|
||||||
namespace osx
|
|
||||||
{
|
|
||||||
|
|
||||||
std::string getLoveInResources()
|
|
||||||
{
|
|
||||||
std::string path;
|
|
||||||
|
|
||||||
@autoreleasepool
|
|
||||||
{
|
|
||||||
// Check to see if there are any .love files in Resources.
|
|
||||||
NSString *lovepath = [[NSBundle mainBundle] pathForResource:nil ofType:@"love"];
|
|
||||||
|
|
||||||
if (lovepath != nil)
|
|
||||||
path = lovepath.UTF8String;
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string checkDropEvents()
|
|
||||||
{
|
|
||||||
std::string dropstr;
|
|
||||||
SDL_Event event;
|
|
||||||
|
|
||||||
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
|
||||||
|
|
||||||
SDL_PumpEvents();
|
|
||||||
if (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_DROPFILE, SDL_DROPFILE) > 0)
|
|
||||||
{
|
|
||||||
if (event.type == SDL_DROPFILE)
|
|
||||||
{
|
|
||||||
dropstr = std::string(event.drop.file);
|
|
||||||
SDL_free(event.drop.file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
|
||||||
|
|
||||||
return dropstr;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getExecutablePath()
|
|
||||||
{
|
|
||||||
@autoreleasepool
|
|
||||||
{
|
|
||||||
return std::string([NSBundle mainBundle].executablePath.UTF8String);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void requestAttention(bool continuous)
|
|
||||||
{
|
|
||||||
@autoreleasepool
|
|
||||||
{
|
|
||||||
if (continuous)
|
|
||||||
[NSApp requestUserAttention:NSCriticalRequest];
|
|
||||||
else
|
|
||||||
[NSApp requestUserAttention:NSInformationalRequest];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // osx
|
|
||||||
} // love
|
|
||||||
|
|
||||||
#endif // LOVE_MACOSX
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2006-2015 LOVE Development Team
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef LOVE_IOS_H
|
|
||||||
#define LOVE_IOS_H
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#ifdef LOVE_IOS
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace love
|
|
||||||
{
|
|
||||||
namespace ios
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the filepath of the first detected love file. The main .app Bundle is
|
|
||||||
* searched first, and then the app's Documents folder.
|
|
||||||
**/
|
|
||||||
std::string getLoveInResources(bool &fused);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the directory path where files should be stored.
|
|
||||||
**/
|
|
||||||
std::string getAppdataDirectory();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the home directory (on iOS, this really means the app's sandbox dir.)
|
|
||||||
**/
|
|
||||||
std::string getHomeDirectory();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Opens the specified URL with the default program associated with the URL's
|
|
||||||
* scheme.
|
|
||||||
**/
|
|
||||||
bool openURL(const std::string &url);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the full path to the executable.
|
|
||||||
**/
|
|
||||||
std::string getExecutablePath();
|
|
||||||
|
|
||||||
} // ios
|
|
||||||
} // love
|
|
||||||
|
|
||||||
#endif // LOVE_IOS
|
|
||||||
#endif // LOVE_IOS_H
|
|
||||||
@@ -1,327 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2006-2015 LOVE Development Team
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
|
||||||
**/
|
|
||||||
|
|
||||||
#include "iOS.h"
|
|
||||||
|
|
||||||
#ifdef LOVE_IOS
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <SDL_events.h>
|
|
||||||
|
|
||||||
static NSArray *getLovesInDocuments();
|
|
||||||
static bool deleteFileInDocuments(NSString *filename);
|
|
||||||
|
|
||||||
@interface LOVETableViewController : UITableViewController
|
|
||||||
|
|
||||||
- (instancetype)initWithGameList:(NSArray *)list;
|
|
||||||
|
|
||||||
@property (nonatomic) NSMutableArray *gameList;
|
|
||||||
@property (nonatomic, readonly, copy) NSString *selectedGame;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation LOVETableViewController
|
|
||||||
|
|
||||||
- (instancetype)initWithGameList:(NSArray *)list
|
|
||||||
{
|
|
||||||
if ((self = [super init]))
|
|
||||||
{
|
|
||||||
_gameList = [[NSMutableArray alloc] initWithArray:list copyItems:YES];
|
|
||||||
|
|
||||||
self.title = @"LÖVE Games";
|
|
||||||
self.navigationItem.rightBarButtonItem = self.editButtonItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
|
||||||
{
|
|
||||||
#pragma unused(tableView)
|
|
||||||
#pragma unused(section)
|
|
||||||
// We want to list all games plus the no-game screen.
|
|
||||||
return self.gameList.count + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
||||||
{
|
|
||||||
static NSString *cellIdentifier = @"LOVETableCell";
|
|
||||||
|
|
||||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
|
|
||||||
if (cell == nil)
|
|
||||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
|
|
||||||
|
|
||||||
if (indexPath.row < (NSInteger) self.gameList.count)
|
|
||||||
cell.textLabel.text = self.gameList[indexPath.row];
|
|
||||||
else
|
|
||||||
cell.textLabel.text = @"No-game screen";
|
|
||||||
|
|
||||||
return cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
|
||||||
{
|
|
||||||
#pragma unused(tableView)
|
|
||||||
if (indexPath.row < (NSInteger) self.gameList.count)
|
|
||||||
_selectedGame = [(NSString *)(self.gameList[indexPath.row]) copy];
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// We test against nil to check if a game has been selected, so we'll
|
|
||||||
// just use an empty string instead to represent the no-game screen.
|
|
||||||
_selectedGame = @"";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
|
|
||||||
{
|
|
||||||
if (editingStyle != UITableViewCellEditingStyleDelete)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (indexPath.row >= (NSInteger) self.gameList.count)
|
|
||||||
return;
|
|
||||||
|
|
||||||
NSString *filename = self.gameList[indexPath.row];
|
|
||||||
|
|
||||||
// Delete the file.
|
|
||||||
if (deleteFileInDocuments(filename))
|
|
||||||
{
|
|
||||||
[self.gameList removeObjectAtIndex:indexPath.row];
|
|
||||||
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath;
|
|
||||||
{
|
|
||||||
#pragma unused(tableView)
|
|
||||||
// The no-game screen isn't removable.
|
|
||||||
return indexPath.row < (NSInteger) self.gameList.count;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
static NSString *getDocumentsDirectory()
|
|
||||||
{
|
|
||||||
NSArray *docdirs = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
||||||
return docdirs[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
static NSArray *getLovesInDocuments()
|
|
||||||
{
|
|
||||||
NSString *documents = getDocumentsDirectory();
|
|
||||||
NSArray *filepaths = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:documents error:nil];
|
|
||||||
return [filepaths pathsMatchingExtensions:@[@"love"]];
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool deleteFileInDocuments(NSString *filename)
|
|
||||||
{
|
|
||||||
NSString *documents = getDocumentsDirectory();
|
|
||||||
|
|
||||||
NSString *file = [documents stringByAppendingPathComponent:filename];
|
|
||||||
bool success = [[NSFileManager defaultManager] removeItemAtPath:file error:nil];
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
NSLog(@"Deleted file %@ in Documents folder.", filename);
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dropFileEventFilter(void *userdata, SDL_Event *event)
|
|
||||||
{
|
|
||||||
@autoreleasepool
|
|
||||||
{
|
|
||||||
if (event->type != SDL_DROPFILE)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
NSString *fname = @(event->drop.file);
|
|
||||||
NSFileManager *fmanager = [NSFileManager defaultManager];
|
|
||||||
|
|
||||||
if ([fmanager fileExistsAtPath:fname] && [fname.pathExtension isEqual:@"love"])
|
|
||||||
{
|
|
||||||
NSString *documents = getDocumentsDirectory();
|
|
||||||
|
|
||||||
documents = documents.stringByStandardizingPath.stringByResolvingSymlinksInPath;
|
|
||||||
fname = fname.stringByStandardizingPath.stringByResolvingSymlinksInPath;
|
|
||||||
|
|
||||||
// Is the file inside the Documents directory?
|
|
||||||
if ([fname hasPrefix:documents])
|
|
||||||
{
|
|
||||||
LOVETableViewController *vc = (__bridge LOVETableViewController *) userdata;
|
|
||||||
|
|
||||||
// Update the game list.
|
|
||||||
NSArray *games = getLovesInDocuments();
|
|
||||||
vc.gameList = [[NSMutableArray alloc] initWithArray:games copyItems:YES];
|
|
||||||
[vc.tableView reloadData];
|
|
||||||
|
|
||||||
SDL_free(event->drop.file);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace love
|
|
||||||
{
|
|
||||||
namespace ios
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays a full-screen list of available LOVE games for the user to choose.
|
|
||||||
* Returns the index of the selected game from the list. The list of games
|
|
||||||
* includes the no-game screen, and the function will return an index outside
|
|
||||||
* of the array's range if that is selected.
|
|
||||||
**/
|
|
||||||
static NSString *showGameList(NSArray *filenames)
|
|
||||||
{
|
|
||||||
// Game list view controller.
|
|
||||||
LOVETableViewController *tablecontroller = [[LOVETableViewController alloc] initWithGameList:filenames];
|
|
||||||
|
|
||||||
// Navigation view controller (only used for the header bar right now.)
|
|
||||||
// Contains the game list view/controller.
|
|
||||||
UINavigationController *navcontroller = [[UINavigationController alloc] initWithRootViewController:tablecontroller];
|
|
||||||
|
|
||||||
UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
|
||||||
window.rootViewController = navcontroller;
|
|
||||||
|
|
||||||
SDL_EventFilter oldfilter = nullptr;
|
|
||||||
void *oldudata = nullptr;
|
|
||||||
SDL_GetEventFilter(&oldfilter, &oldudata);
|
|
||||||
|
|
||||||
// Manually retain the table VC and use it for the event filter userdata.
|
|
||||||
// We need to set a custom event filter to update the table when .love files
|
|
||||||
// are opened by the user.
|
|
||||||
void *tableudata = (void *) CFBridgingRetain(tablecontroller);
|
|
||||||
SDL_SetEventFilter(dropFileEventFilter, tableudata);
|
|
||||||
|
|
||||||
[window makeKeyAndVisible];
|
|
||||||
|
|
||||||
// Process events until a game in the list is selected.
|
|
||||||
NSRunLoop *runloop = [NSRunLoop currentRunLoop];
|
|
||||||
while (tablecontroller.selectedGame == nil)
|
|
||||||
{
|
|
||||||
[runloop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]];
|
|
||||||
[runloop runMode:UITrackingRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:1.0/60.0]];
|
|
||||||
}
|
|
||||||
|
|
||||||
// The window will get released and cleaned up once we go out of scope.
|
|
||||||
window.hidden = YES;
|
|
||||||
|
|
||||||
SDL_SetEventFilter(oldfilter, oldudata);
|
|
||||||
CFBridgingRelease(tableudata);
|
|
||||||
|
|
||||||
return tablecontroller.selectedGame;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getLoveInResources(bool &fused)
|
|
||||||
{
|
|
||||||
fused = false;
|
|
||||||
std::string path;
|
|
||||||
|
|
||||||
@autoreleasepool
|
|
||||||
{
|
|
||||||
// Start by looking in the main bundle (.app) folder for .love files.
|
|
||||||
NSArray *bundlepaths = [[NSBundle mainBundle] pathsForResourcesOfType:@"love" inDirectory:nil];
|
|
||||||
|
|
||||||
if (bundlepaths.count > 0)
|
|
||||||
{
|
|
||||||
// The game should be fused if we have something here.
|
|
||||||
fused = true;
|
|
||||||
return [bundlepaths[0] UTF8String];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise look in the app's Documents directory. The game won't be
|
|
||||||
// fused.
|
|
||||||
NSArray *filepaths = getLovesInDocuments();
|
|
||||||
|
|
||||||
// Let the user select a game from the un-fused list.
|
|
||||||
NSString *selectedfile = showGameList(filepaths);
|
|
||||||
|
|
||||||
// The string length might be 0 if the no-game screen was selected.
|
|
||||||
if (selectedfile != nil && selectedfile.length > 0)
|
|
||||||
{
|
|
||||||
NSString *documents = getDocumentsDirectory();
|
|
||||||
path = [documents stringByAppendingPathComponent:selectedfile].UTF8String;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getAppdataDirectory()
|
|
||||||
{
|
|
||||||
NSSearchPathDirectory searchdir = NSApplicationSupportDirectory;
|
|
||||||
std::string path;
|
|
||||||
|
|
||||||
@autoreleasepool
|
|
||||||
{
|
|
||||||
NSArray *dirs = NSSearchPathForDirectoriesInDomains(searchdir, NSUserDomainMask, YES);
|
|
||||||
|
|
||||||
if (dirs.count > 0)
|
|
||||||
path = [dirs[0] UTF8String];
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getHomeDirectory()
|
|
||||||
{
|
|
||||||
std::string path;
|
|
||||||
|
|
||||||
@autoreleasepool
|
|
||||||
{
|
|
||||||
path = [NSHomeDirectory() UTF8String];
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool openURL(const std::string &url)
|
|
||||||
{
|
|
||||||
bool success = false;
|
|
||||||
|
|
||||||
@autoreleasepool
|
|
||||||
{
|
|
||||||
UIApplication *app = [UIApplication sharedApplication];
|
|
||||||
NSURL *nsurl = [NSURL URLWithString:@(url.c_str())];
|
|
||||||
|
|
||||||
if ([app canOpenURL:nsurl])
|
|
||||||
success = [app openURL:nsurl];
|
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getExecutablePath()
|
|
||||||
{
|
|
||||||
@autoreleasepool
|
|
||||||
{
|
|
||||||
return std::string([NSBundle mainBundle].executablePath.UTF8String);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // ios
|
|
||||||
} // love
|
|
||||||
|
|
||||||
#endif // LOVE_IOS
|
|
||||||
@@ -46,6 +46,10 @@ extern "C" {
|
|||||||
|
|
||||||
#ifdef LOVE_ANDROID
|
#ifdef LOVE_ANDROID
|
||||||
#include "common/android.h"
|
#include "common/android.h"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#include "luajit.h"
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LOVE_WINDOWS
|
#ifdef LOVE_WINDOWS
|
||||||
@@ -252,6 +256,7 @@ int main(int argc, char **argv)
|
|||||||
luaL_openlibs(L);
|
luaL_openlibs(L);
|
||||||
|
|
||||||
#ifdef LOVE_ANDROID
|
#ifdef LOVE_ANDROID
|
||||||
|
luaJIT_setmode(L, 0, LUAJIT_MODE_ENGINE| LUAJIT_MODE_OFF);
|
||||||
lua_register(L, "print", l_print_sdl_log);
|
lua_register(L, "print", l_print_sdl_log);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -901,13 +901,13 @@ void Font::getWrap(const ColoredCodepoints &codepoints, float wraplimit, std::ve
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Font::getWrap(const std::string &text, float wraplimit, std::vector<std::string> &lines, std::vector<int> *linewidths)
|
void Font::getWrap(const std::vector<ColoredString> &text, float wraplimit, std::vector<std::string> &lines, std::vector<int> *linewidths)
|
||||||
{
|
{
|
||||||
ColoredCodepoints codepoints;
|
ColoredCodepoints cps;
|
||||||
getCodepointsFromString(text, codepoints.cps);
|
getCodepointsFromString(text, cps);
|
||||||
|
|
||||||
std::vector<ColoredCodepoints> codepointlines;
|
std::vector<ColoredCodepoints> codepointlines;
|
||||||
getWrap(codepoints, wraplimit, codepointlines, linewidths);
|
getWrap(cps, wraplimit, codepointlines, linewidths);
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ public:
|
|||||||
* @param max_width Optional output of the maximum width
|
* @param max_width Optional output of the maximum width
|
||||||
* Returns a vector with the lines.
|
* Returns a vector with the lines.
|
||||||
**/
|
**/
|
||||||
void getWrap(const std::string &text, float wraplimit, std::vector<std::string> &lines, std::vector<int> *line_widths = nullptr);
|
void getWrap(const std::vector<ColoredString> &text, float wraplimit, std::vector<std::string> &lines, std::vector<int> *line_widths = nullptr);
|
||||||
void getWrap(const ColoredCodepoints &codepoints, float wraplimit, std::vector<ColoredCodepoints> &lines, std::vector<int> *line_widths = nullptr);
|
void getWrap(const ColoredCodepoints &codepoints, float wraplimit, std::vector<ColoredCodepoints> &lines, std::vector<int> *line_widths = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
// LOVE
|
// LOVE
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
#include "wrap_Font.h"
|
#include "wrap_Font.h"
|
||||||
|
#include "wrap_Text.h"
|
||||||
|
|
||||||
// C++
|
// C++
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -56,13 +57,16 @@ int w_Font_getWidth(lua_State *L)
|
|||||||
int w_Font_getWrap(lua_State *L)
|
int w_Font_getWrap(lua_State *L)
|
||||||
{
|
{
|
||||||
Font *t = luax_checkfont(L, 1);
|
Font *t = luax_checkfont(L, 1);
|
||||||
const char *str = luaL_checkstring(L, 2);
|
|
||||||
|
std::vector<Font::ColoredString> text;
|
||||||
|
luax_checkcoloredstring(L, 2, text);
|
||||||
|
|
||||||
float wrap = (float) luaL_checknumber(L, 3);
|
float wrap = (float) luaL_checknumber(L, 3);
|
||||||
int max_width = 0;
|
int max_width = 0;
|
||||||
std::vector<std::string> lines;
|
std::vector<std::string> lines;
|
||||||
std::vector<int> widths;
|
std::vector<int> widths;
|
||||||
|
|
||||||
luax_catchexcept(L, [&]() { t->getWrap(str, wrap, lines, &widths); });
|
luax_catchexcept(L, [&]() { t->getWrap(text, wrap, lines, &widths); });
|
||||||
|
|
||||||
for (int width : widths)
|
for (int width : widths)
|
||||||
max_width = std::max(max_width, width);
|
max_width = std::max(max_width, width);
|
||||||
|
|||||||
@@ -368,7 +368,7 @@ StringMap<Keyboard::Scancode, Keyboard::SCANCODE_MAX_ENUM>::Entry Keyboard::scan
|
|||||||
{"nonusbackslash", SCANCODE_NONUSBACKSLASH},
|
{"nonusbackslash", SCANCODE_NONUSBACKSLASH},
|
||||||
{"application", SCANCODE_APPLICATION},
|
{"application", SCANCODE_APPLICATION},
|
||||||
{"power", SCANCODE_POWER},
|
{"power", SCANCODE_POWER},
|
||||||
{"=", SCANCODE_KP_EQUALS},
|
{"kp=", SCANCODE_KP_EQUALS},
|
||||||
{"f13", SCANCODE_F13},
|
{"f13", SCANCODE_F13},
|
||||||
{"f14", SCANCODE_F14},
|
{"f14", SCANCODE_F14},
|
||||||
{"f15", SCANCODE_F15},
|
{"f15", SCANCODE_F15},
|
||||||
|
|||||||
Reference in New Issue
Block a user