Skip to content

Commit a56d22d

Browse files
committed
Merge remote-tracking branch 'upstream/8.3.0-Dev' into cool
2 parents dee6ad5 + 54516f8 commit a56d22d

File tree

9 files changed

+170
-76
lines changed

9 files changed

+170
-76
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ jobs:
117117
rm /usr/local/bin/idle3*
118118
rm /usr/local/bin/pydoc3*
119119
rm /usr/local/bin/python3*
120+
rm /usr/local/bin/pip3*
120121
brew bundle
121122
popd
122123

project/lib/curl-files.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<xml>
2-
<include name="${HXCPP}/project/thirdparty/mbedtls_files.xml" noerror="true" if="static_link"/>
2+
<include name="${HXCPP}/project/thirdparty/mbedtls-files.xml" noerror="true" if="static_link" />
33
<set name="HAS_HXCPP_MBEDTLS_FLAGS" value="1" if="MBEDTLS_DIR" />
44
<include name="${HXCPP}/src/hx/libs/ssl/Build.xml" unless="MBEDTLS_DIR"/>
55

@@ -30,7 +30,7 @@
3030
<compilerflag value="-I${NATIVE_TOOLKIT_PATH}/mbedtls/include" if="NATIVE_TOOLKIT_HAVE_MBEDTLS" unless="static_link"/>
3131
<section if="static_link">
3232

33-
<include name="${HXCPP}/project/thirdparty/mbedtls_flags.xml" if="HAS_HXCPP_MBEDTLS_FLAGS" />
33+
<include name="${HXCPP}/project/thirdparty/mbedtls-flags.xml" if="HAS_HXCPP_MBEDTLS_FLAGS" />
3434

3535
<section unless="HAS_HXCPP_MBEDTLS_FLAGS">
3636

project/src/backend/sdl/SDLSystem.cpp

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@
3939
#include <SDL.h>
4040
#include <string>
4141

42-
#ifdef HX_WINDOWS
4342
#include <locale>
4443
#include <codecvt>
45-
#endif
44+
45+
using wstring_convert = std::wstring_convert<std::codecvt_utf8<wchar_t>>;
4646

4747

4848
namespace lime {
@@ -111,27 +111,31 @@ namespace lime {
111111
case APPLICATION: {
112112

113113
char* path = SDL_GetBasePath ();
114-
#ifdef HX_WINDOWS
115-
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
116-
result = new std::wstring (converter.from_bytes(path));
117-
#else
118-
result = new std::wstring (path, path + strlen (path));
119-
#endif
120-
SDL_free (path);
114+
115+
if (path != nullptr) {
116+
117+
wstring_convert converter;
118+
result = new std::wstring (converter.from_bytes(path));
119+
SDL_free (path);
120+
121+
}
122+
121123
break;
122124

123125
}
124126

125127
case APPLICATION_STORAGE: {
126128

127129
char* path = SDL_GetPrefPath (company, title);
128-
#ifdef HX_WINDOWS
129-
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
130-
result = new std::wstring (converter.from_bytes(path));
131-
#else
132-
result = new std::wstring (path, path + strlen (path));
133-
#endif
134-
SDL_free (path);
130+
131+
if (path != nullptr) {
132+
133+
wstring_convert converter;
134+
result = new std::wstring (converter.from_bytes(path));
135+
SDL_free (path);
136+
137+
}
138+
135139
break;
136140

137141
}
@@ -145,11 +149,9 @@ namespace lime {
145149

146150
#elif defined (HX_WINDOWS)
147151

148-
char folderPath[MAX_PATH] = "";
149-
SHGetFolderPath (NULL, CSIDL_DESKTOPDIRECTORY, NULL, SHGFP_TYPE_CURRENT, folderPath);
150-
//WIN_StringToUTF8 (folderPath);
151-
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
152-
result = new std::wstring (converter.from_bytes (folderPath));
152+
WCHAR folderPath[MAX_PATH] = L"";
153+
SHGetFolderPathW (NULL, CSIDL_DESKTOPDIRECTORY, NULL, SHGFP_TYPE_CURRENT, folderPath);
154+
result = new std::wstring (folderPath);
153155

154156
#elif defined (IPHONE)
155157

@@ -159,15 +161,14 @@ namespace lime {
159161

160162
char const* home = getenv ("HOME");
161163

162-
if (home == NULL) {
164+
if (home != NULL) {
163165

164-
return 0;
166+
std::string path = std::string (home) + std::string ("/Desktop");
167+
wstring_convert converter;
168+
result = new std::wstring (converter.from_bytes(path));
165169

166170
}
167171

168-
std::string path = std::string (home) + std::string ("/Desktop");
169-
result = new std::wstring (path.begin (), path.end ());
170-
171172
#endif
172173
break;
173174

@@ -182,11 +183,9 @@ namespace lime {
182183

183184
#elif defined (HX_WINDOWS)
184185

185-
char folderPath[MAX_PATH] = "";
186-
SHGetFolderPath (NULL, CSIDL_MYDOCUMENTS, NULL, SHGFP_TYPE_CURRENT, folderPath);
187-
//WIN_StringToUTF8 (folderPath);
188-
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
189-
result = new std::wstring (converter.from_bytes (folderPath));
186+
WCHAR folderPath[MAX_PATH] = L"";
187+
SHGetFolderPathW (NULL, CSIDL_MYDOCUMENTS, NULL, SHGFP_TYPE_CURRENT, folderPath);
188+
result = new std::wstring (folderPath);
190189

191190
#elif defined (IPHONE)
192191

@@ -203,7 +202,8 @@ namespace lime {
203202
if (home != NULL) {
204203

205204
std::string path = std::string (home) + std::string ("/Documents");
206-
result = new std::wstring (path.begin (), path.end ());
205+
wstring_convert converter;
206+
result = new std::wstring (converter.from_bytes(path));
207207

208208
}
209209

@@ -220,11 +220,9 @@ namespace lime {
220220

221221
#elif defined (HX_WINDOWS)
222222

223-
char folderPath[MAX_PATH] = "";
224-
SHGetFolderPath (NULL, CSIDL_FONTS, NULL, SHGFP_TYPE_CURRENT, folderPath);
225-
//WIN_StringToUTF8 (folderPath);
226-
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
227-
result = new std::wstring (converter.from_bytes (folderPath));
223+
WCHAR folderPath[MAX_PATH] = L"";
224+
SHGetFolderPathW (NULL, CSIDL_FONTS, NULL, SHGFP_TYPE_CURRENT, folderPath);
225+
result = new std::wstring (folderPath);
228226

229227
#elif defined (HX_MACOS)
230228

@@ -260,11 +258,9 @@ namespace lime {
260258

261259
#elif defined (HX_WINDOWS)
262260

263-
char folderPath[MAX_PATH] = "";
264-
SHGetFolderPath (NULL, CSIDL_PROFILE, NULL, SHGFP_TYPE_CURRENT, folderPath);
265-
//WIN_StringToUTF8 (folderPath);
266-
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
267-
result = new std::wstring (converter.from_bytes (folderPath));
261+
WCHAR folderPath[MAX_PATH] = L"";
262+
SHGetFolderPathW (NULL, CSIDL_PROFILE, NULL, SHGFP_TYPE_CURRENT, folderPath);
263+
result = new std::wstring (folderPath);
268264

269265
#elif defined (IPHONE)
270266

@@ -281,7 +277,8 @@ namespace lime {
281277
if (home != NULL) {
282278

283279
std::string path = std::string (home);
284-
result = new std::wstring (path.begin (), path.end ());
280+
wstring_convert converter;
281+
result = new std::wstring (converter.from_bytes(path));
285282

286283
}
287284

@@ -909,4 +906,4 @@ namespace lime {
909906
}
910907

911908

912-
}
909+
}

src/lime/_internal/graphics/ImageCanvasUtil.hx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,10 @@ class ImageCanvasUtil
189189

190190
if (!image.transparent)
191191
{
192-
if (!image.transparent) buffer.__srcCanvas.setAttribute("moz-opaque", "true");
193-
buffer.__srcContext = untyped #if haxe4 js.Syntax.code #else __js__ #end ('buffer.__srcCanvas.getContext ("2d", { alpha: false })');
194-
}
195-
else
196-
{
197-
buffer.__srcContext = buffer.__srcCanvas.getContext("2d");
192+
buffer.__srcCanvas.setAttribute("moz-opaque", "true");
198193
}
194+
195+
buffer.__srcContext = buffer.__srcCanvas.getContext("2d", {alpha: image.transparent});
199196
}
200197
#end
201198
}

src/lime/tools/IOSHelper.hx

Lines changed: 72 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -360,39 +360,68 @@ class IOSHelper
360360
applicationPath = workingDirectory + "/build/" + configuration + "-iphoneos/" + project.app.file + ".app";
361361
}
362362

363+
var requireIPad = project.config.getString("ios.device", "universal") == "ipad";
364+
var requireIPhone = project.config.getString("ios.device", "universal") == "iphone";
365+
363366
var xcodeVersion = Std.parseFloat(getXcodeVersion());
364367
if (!Math.isNaN(xcodeVersion) && xcodeVersion >= 16) {
365368
// ios-deploy doesn't work with newer iOS SDKs where it can't
366369
// find DeveloperDiskImage.dmg. however, Xcode 16 adds new
367370
// commands for installing and launching apps on connected
368371
// devices, so we'll prefer those, if available.
372+
369373
var deviceUUID:String = null;
370-
// prefer an iOS device with State == 'connected'
371-
// Note: Platform == 'iOS' includes iPadOS
372-
var listDevicesOutput = System.runProcess("", "xcrun", ["devicectl", "list", "devices", "--hide-default-columns", "--columns", "Identifier", "--filter", "Platform == 'iOS' AND State == 'connected'"]);
373-
var ready = false;
374-
for (line in listDevicesOutput.split("\n")) {
375-
if (!ready) {
376-
ready = StringTools.startsWith(line, "----");
377-
continue;
378-
}
379-
deviceUUID = line;
380-
break;
374+
375+
// we'll try various combinations of the following filters to
376+
// select an iOS device. there may be multiple devices to choose
377+
// from, so these filters help us figure out the best one.
378+
379+
var filterPlatformIOS = "Platform == 'iOS'"; // includes iPadOS
380+
var filterDeveloperModeEnabled = "deviceProperties.developerModeStatus == 'enabled'";
381+
var filterStateConnected = "State == 'connected'";
382+
var filterStateAvailable = "State == 'available (paired)'";
383+
var filterTransportTypeWired = "connectionProperties.transportType == 'wired'";
384+
var filterTransportTypeLocalNetwork = "connectionProperties.transportType == 'localNetwork'";
385+
var filterDeviceTypeIPhone = "hardwareProperties.deviceType == 'iPhone'";
386+
var filterDeviceTypeIPad = "hardwareProperties.deviceType == 'iPad'";
387+
388+
// first, some strictly required filters:
389+
// 1. the platform must always be iOS (which includes iPadOS).
390+
// 2. the device must be in developer mode.
391+
// 3. if required by the project config, limit to iPhone or iPad only
392+
var baseFilters = [
393+
filterPlatformIOS,
394+
filterDeveloperModeEnabled,
395+
];
396+
if (requireIPad)
397+
{
398+
baseFilters.push(filterDeviceTypeIPad);
381399
}
382-
if (deviceUUID == null || deviceUUID.length == 0) {
383-
// preferred fallback is an iOS device that is both
384-
// available and wired
385-
var listDevicesOutput = System.runProcess("", "xcrun", ["devicectl", "list", "devices", "--hide-default-columns", "--columns", "Identifier", "--filter", "Platform == 'iOS' AND State == 'available (paired)' AND connectionProperties.transportType == 'wired'"]);
386-
ready = false;
387-
for (line in listDevicesOutput.split("\n")) {
388-
if (!ready) {
389-
ready = StringTools.startsWith(line, "----");
390-
continue;
400+
else if (requireIPhone)
401+
{
402+
baseFilters.push(filterDeviceTypeIPhone);
403+
}
404+
405+
// after that, we have the following preferences, in order:
406+
// 1. state: "connected" preferred over "available (paired)"
407+
// 2. transportType: "wired" preferred over "localNetwork"
408+
var stateFilters = [filterStateConnected, filterStateAvailable];
409+
var transportTypeFilters = [filterTransportTypeWired, filterTransportTypeLocalNetwork];
410+
for (stateFilter in stateFilters)
411+
{
412+
for (transportTypeFilter in transportTypeFilters)
413+
{
414+
deviceUUID = findDeviceUUIDWithFilters(baseFilters.concat([
415+
stateFilter,
416+
transportTypeFilter
417+
]));
418+
if (deviceUUID != null && deviceUUID.length > 0)
419+
{
420+
break;
391421
}
392-
deviceUUID = line;
393-
break;
394422
}
395423
}
424+
396425
if (deviceUUID == null || deviceUUID.length == 0) {
397426
// devices running iOS 16 and older don't support
398427
// xcrun devicectl, so if no device was found, try falling
@@ -416,6 +445,27 @@ class IOSHelper
416445
}
417446
}
418447

448+
private static function findDeviceUUIDWithFilters(filters:Array<String>):String
449+
{
450+
var listDevicesOutput = System.runProcess("", "xcrun",
451+
[
452+
"devicectl", "list", "devices",
453+
"--hide-default-columns", "--columns", "Identifier",
454+
"--filter", filters.join(" AND ")
455+
]);
456+
var ready = false;
457+
for (line in listDevicesOutput.split("\n"))
458+
{
459+
if (!ready)
460+
{
461+
ready = StringTools.startsWith(line, "----");
462+
continue;
463+
}
464+
return line;
465+
}
466+
return null;
467+
}
468+
419469
private static function fallbackLaunch(project:HXProject, applicationPath:String):Void
420470
{
421471
var templatePaths = [

src/lime/ui/FileDialog.hx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import hl.Bytes as HLBytes;
1414
import hl.NativeArray;
1515
#end
1616
#if sys
17+
import sys.FileSystem;
1718
import sys.io.File;
1819
#end
1920
#if (js && html5)
@@ -98,6 +99,29 @@ class FileDialog
9899
{
99100
if (type == null) type = FileDialogType.OPEN;
100101

102+
#if sys
103+
if (defaultPath != null && defaultPath.length > 0
104+
&& FileSystem.exists(defaultPath)
105+
&& FileSystem.isDirectory(defaultPath))
106+
{
107+
// if the default path is a directory, and the default path doesn't
108+
// end with a separator, tiny file dialogs may open its parent
109+
// directory instead.
110+
var lastChar = defaultPath.charAt(defaultPath.length - 1);
111+
#if windows
112+
if (lastChar != "/" && lastChar != "\\")
113+
{
114+
defaultPath = defaultPath + "\\";
115+
}
116+
#else
117+
if (lastChar != "/")
118+
{
119+
defaultPath = defaultPath + "/";
120+
}
121+
#end
122+
}
123+
#end
124+
101125
#if desktop
102126
var worker = new ThreadPool(#if windows SINGLE_THREADED #end);
103127

@@ -148,6 +172,7 @@ class FileDialog
148172

149173
var path = null;
150174
#if (!macro && lime_cffi)
175+
trace(defaultPath);
151176
path = CFFI.stringValue(NativeCFFI.lime_file_dialog_open_file(title, filter, defaultPath));
152177
#end
153178

src/lime/utils/Assets.hx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,23 @@ class Assets
181181
}
182182

183183
/**
184-
* Gets an instance of an embedded bitmap
184+
* Gets an instance of an embedded bitmap.
185+
*
186+
* _Note:_ This method may behave differently, depending on the target
187+
* platform. On targets that can quickly create a new image synchronously,
188+
* every call to `Assets.getImage()` with the same ID will return a new
189+
* `Image` instance. However, on other targets where creating images
190+
* synchronously is unacceptably slow, or where images may not be created
191+
* synchronously and must be created asynchronously, every call to
192+
* `Assets.getImage()` with the same ID may return a single, shared `Image`
193+
* instance.
194+
*
195+
* With that in mind, modifying or disposing the contents of the `Image`
196+
* returned by `Assets.getImage()` may affect the results of future calls to
197+
* Assets.getImage()` on some targets. To access an `Image` instance that
198+
* may be modified without affecting future calls to `Assets.getImage()`,
199+
* call the `Image` instance's `clone()` method to manually create a copy.
200+
*
185201
* @usage var bitmap = new Bitmap(Assets.getBitmapData("image.jpg"));
186202
* @param id The ID or asset path for the bitmap
187203
* @param useCache (Optional) Whether to use BitmapData from the cache(Default: true)

0 commit comments

Comments
 (0)