Merge branch '12.0-development' into metal

This commit is contained in:
Alex Szpakowski
2021-01-14 20:33:45 -04:00
40 changed files with 1692 additions and 574 deletions
+15
View File
@@ -197,6 +197,21 @@ bool getConstant(const char *in, type &out) { return name##s.find(in, out); } \
bool getConstant(type in, const char *&out) { return name##s.find(in, out); } \
std::vector<std::string> getConstants(type) { return name##s.getNames(); }
#define STRINGMAP_CLASS_DECLARE(type) \
static bool getConstant(const char *in, type &out); \
static bool getConstant(type in, const char *&out); \
static std::vector<std::string> getConstants(type); \
#define STRINGMAP_CLASS_BEGIN(classname, type, count, name) \
static StringMap<type, count>::Entry name##Entries[] =
#define STRINGMAP_CLASS_END(classname, type, count, name) \
; \
static StringMap<type, count> name##s(name##Entries, sizeof(name##Entries)); \
bool classname::getConstant(const char *in, type &out) { return name##s.find(in, out); } \
bool classname::getConstant(type in, const char *&out) { return name##s.find(in, out); } \
std::vector<std::string> classname::getConstants(type) { return name##s.getNames(); }
} // love
#endif // LOVE_STRING_MAP_H
+8 -1
View File
@@ -148,7 +148,14 @@ bool openURL(const std::string &url)
JNIEnv *env = (JNIEnv*) SDL_AndroidGetJNIEnv();
jclass activity = env->FindClass("org/love2d/android/GameActivity");
jmethodID openURL = env->GetStaticMethodID(activity, "openURL", "(Ljava/lang/String;)Z");
jmethodID openURL = env->GetStaticMethodID(activity, "openURLFromLOVE", "(Ljava/lang/String;)Z");
if (openURL == nullptr)
{
env->ExceptionClear();
openURL = env->GetStaticMethodID(activity, "openURL", "(Ljava/lang/String;)Z");
}
jstring url_jstring = (jstring) env->NewStringUTF(url.c_str());
jboolean result = env->CallStaticBooleanMethod(activity, openURL, url_jstring);
+50
View File
@@ -0,0 +1,50 @@
/**
* Copyright (c) 2006-2020 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.
**/
#pragma once
#include "config.h"
#if defined(LOVE_IOS) || defined(LOVE_MACOS)
#include <string>
namespace love
{
namespace apple
{
enum UserDirectory
{
USER_DIRECTORY_HOME,
USER_DIRECTORY_APPSUPPORT,
USER_DIRECTORY_DOCUMENTS,
USER_DIRECTORY_DESKTOP,
USER_DIRECTORY_CACHES,
USER_DIRECTORY_TEMP,
};
std::string getUserDirectory(UserDirectory dir);
std::string getExecutablePath();
} // apple
} // love
#endif // defined(LOVE_IOS) || defined(LOVE_MACOS)
+79
View File
@@ -0,0 +1,79 @@
/**
* Copyright (c) 2006-2020 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 "apple.h"
#if defined(LOVE_IOS) || defined(LOVE_MACOS)
#import <Foundation/Foundation.h>
namespace love
{
namespace apple
{
std::string getUserDirectory(UserDirectory dir)
{
std::string path;
NSSearchPathDirectory nsdir = NSTrashDirectory;
@autoreleasepool
{
switch (dir)
{
case USER_DIRECTORY_HOME:
return NSHomeDirectory().UTF8String;
case USER_DIRECTORY_APPSUPPORT:
nsdir = NSApplicationSupportDirectory;
break;
case USER_DIRECTORY_DOCUMENTS:
nsdir = NSDocumentDirectory;
break;
case USER_DIRECTORY_DESKTOP:
nsdir = NSDesktopDirectory;
break;
case USER_DIRECTORY_CACHES:
nsdir = NSCachesDirectory;
break;
case USER_DIRECTORY_TEMP:
nsdir = NSItemReplacementDirectory;
break;
}
NSArray<NSURL *> *dirs = [[NSFileManager defaultManager] URLsForDirectory:nsdir inDomains:NSUserDomainMask];
if (dirs.count > 0)
path = [dirs[0].path UTF8String];
}
return path;
}
std::string getExecutablePath()
{
@autoreleasepool
{
return std::string([NSBundle mainBundle].executablePath.UTF8String);
}
}
} // apple
} // love
#endif // defined(LOVE_IOS) || defined(LOVE_MACOS)
-15
View File
@@ -42,27 +42,12 @@ namespace ios
**/
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();
/**
* Causes devices with vibration support to vibrate for about 0.5 seconds.
**/
+1 -46
View File
@@ -19,6 +19,7 @@
**/
#include "ios.h"
#include "apple.h"
#ifdef LOVE_IOS
@@ -127,12 +128,6 @@ static bool deleteFileInDocuments(NSString *filename);
@end
static NSString *getDocumentsDirectory()
{
NSArray *docdirs = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
return docdirs[0];
}
static NSArray *getLovesInDocuments()
{
NSMutableArray *paths = [NSMutableArray new];
@@ -339,38 +334,6 @@ std::string getLoveInResources(bool &fused)
return path;
}
static std::string getUserDirectory(NSSearchPathDirectory dir)
{
std::string path;
@autoreleasepool
{
NSArray<NSURL *> *dirs = [[NSFileManager defaultManager] URLsForDirectory:dir inDomains:NSUserDomainMask];
if (dirs.count > 0)
path = [dirs[0].path UTF8String];
}
return path;
}
std::string getAppdataDirectory()
{
return getUserDirectory(NSApplicationSupportDirectory);
}
std::string getHomeDirectory()
{
std::string path;
@autoreleasepool
{
path = [NSHomeDirectory() UTF8String];
}
return path;
}
bool openURL(const std::string &url)
{
bool success = false;
@@ -387,14 +350,6 @@ bool openURL(const std::string &url)
return success;
}
std::string getExecutablePath()
{
@autoreleasepool
{
return std::string([NSBundle mainBundle].executablePath.UTF8String);
}
}
void vibrate()
{
@autoreleasepool
-7
View File
@@ -31,8 +31,6 @@ namespace love
namespace macos
{
std::string getAppdataDirectory();
/**
* Returns the filepath of the first detected love file in the Resources folder
* in the main bundle (love.app.)
@@ -46,11 +44,6 @@ std::string getLoveInResources();
**/
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.
**/
-28
View File
@@ -36,26 +36,6 @@ namespace love
namespace macos
{
static std::string getUserDirectory(NSSearchPathDirectory dir)
{
std::string path;
@autoreleasepool
{
NSArray<NSURL *> *dirs = [[NSFileManager defaultManager] URLsForDirectory:dir inDomains:NSUserDomainMask];
if (dirs.count > 0)
path = [dirs[0].path UTF8String];
}
return path;
}
std::string getAppdataDirectory()
{
return getUserDirectory(NSApplicationSupportDirectory);
}
std::string getLoveInResources()
{
std::string path;
@@ -94,14 +74,6 @@ std::string checkDropEvents()
return dropstr;
}
std::string getExecutablePath()
{
@autoreleasepool
{
return std::string([NSBundle mainBundle].executablePath.UTF8String);
}
}
void requestAttention(bool continuous)
{
@autoreleasepool