Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS Sim: Allow for dragging main.lua file on Sim #531

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion external/remdebug-1.0/src/controller.lua
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ while true do
print("")
print("Corona Debugger")
print("version 1.1")
print("Copyright © 2008-2021 Solar2D. All rights reserved.")
print("Copyright © 2008-2023 Solar2D. All rights reserved.")
print("")
print("Portions contain:")
print(" Lua, Copyright © 1994-2008 Lua.org, PUC-Rio.")
Expand Down
2 changes: 1 addition & 1 deletion platform/apple/CoronaResources-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
<key>CFPlugInUnloadFunction</key>
<string></string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2020-2021 Solar2D. All rights reserved.</string>
<string>Copyright © 2020-2023 Solar2D. All rights reserved.</string>
</dict>
</plist>
15 changes: 13 additions & 2 deletions platform/mac/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ @interface ExtensionParams : NSObject
@property (nonatomic, readonly) bool showWindowTitle;
@property (nonatomic, readwrite, retain) CoronaWindowController *view;


- (id) initParams:(NSString *)title path:(NSString *)path width:(int)w height:(int)h resizable:(bool) resizable showWindowTitle:(bool) showWindowTitle;

@end
Expand Down Expand Up @@ -1073,6 +1074,7 @@ -(void)applicationDidFinishLaunching:(NSNotification*)aNotification
}
}


// Calling this makes the Welcome window fail to appear (the subsequent call seems to work without it)
//[[NSProcessInfo processInfo] setAutomaticTerminationSupportEnabled:YES];
[[NSProcessInfo processInfo] disableSuddenTermination];
Expand Down Expand Up @@ -1277,6 +1279,10 @@ - (void) loadExtension:(ExtensionParams *) extParams
if ([extParams.path hasSuffix:[builtinExtDirectory stringByAppendingPathComponent:@"welcome"]])
{
fHomeScreen = extView;
//Allow for Dragging Main.lua file on Sim
if (@available(macOS 10.13, *)) {
[[fHomeScreen window] registerForDraggedTypes:@[NSPasteboardTypeFileURL]];
}
}

// Save the fact that this extension is running in the user's defaults
Expand Down Expand Up @@ -1322,7 +1328,6 @@ - (void) runExtension:(NSString *) extName
NSMenuItem *windowMenuItem = [appMenu itemWithTitle:kWindowMenuItemName];
NSMenu *windowMenu = [windowMenuItem submenu];
long welcomeItemIdx = [windowMenu indexOfItemWithTitle:@"Welcome to Solar2D"];

if (welcomeItemIdx == -1)
{
// for some reason we can't find the Welcome menuitem, bail
Expand Down Expand Up @@ -1393,6 +1398,8 @@ -(void)applicationWillFinishLaunching:(NSNotification*)aNotification
#endif
}



- (void) startDebugAndOpenPanel
{
using namespace Rtt;
Expand Down Expand Up @@ -1646,7 +1653,6 @@ -(BOOL)isRelaunchable
-(BOOL) isRunning
{
NSWindow *mainWindow = [NSApp mainWindow];

if (nil != mainWindow)
{
if (mainWindow == [fHomeScreen window])
Expand Down Expand Up @@ -3879,10 +3885,15 @@ - (void)applicationWillBecomeActive:(NSNotification *)aNotification
[self consoleMenuitem:nil];
}


// -----------------------------------------------------------------------------
// END: Simulator UI
// -----------------------------------------------------------------------------





@end

//
Expand Down
2 changes: 1 addition & 1 deletion platform/mac/CoronaConsole/CoronaConsole/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<key>LSUIElement</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2020-2021 Solar2D. All rights reserved.</string>
<string>Copyright © 2020-2023 Solar2D. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
Expand Down
2 changes: 1 addition & 1 deletion platform/mac/CoronaWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Rtt

//typedef void (^windowCloseCompletionBlock)(void);

@interface CoronaWindowController : NSWindowController< CoronaViewControllerDelegate
@interface CoronaWindowController : NSWindowController< NSDraggingDestination,CoronaViewControllerDelegate
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
, CAAnimationDelegate
#endif
Expand Down
39 changes: 39 additions & 0 deletions platform/mac/CoronaWindowController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
#include "Rtt_LuaContext.h"
#include "Rtt_Runtime.h"
#include "Rtt_RuntimeDelegate.h"
#include "Rtt_MacSimulatorServices.h"
#include "HomeScreenRuntimeDelegate.h"


// ----------------------------------------------------------------------------

#define ENABLE_WINDOW_FADE_ANIMATIONS 1
Expand Down Expand Up @@ -780,6 +782,43 @@ - (void)windowDidChangeOcclusionState:(NSNotification *)notification
}
}


//Support Dragging main.lua for Sim Only projects only at the moment
#if Rtt_AUTHORING_SIMULATOR
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender {
NSPasteboard *pboard;
pboard = [sender draggingPasteboard];
if (@available(macOS 10.13, *)) {
if ( [[pboard types] containsObject:NSPasteboardTypeFileURL] ) {
NSString *fileURL = [[NSURL URLFromPasteboard:pboard] path];
NSArray *splitPath = [fileURL componentsSeparatedByString:@"/"];
if([splitPath.lastObject isEqualToString:@"main.lua"] ){
return NSDragOperationLink;
}

}
}
return NSDragOperationNone;
}
//Support for Drag a main.lua on to Welcome Screen
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender {
NSPasteboard *pboard;
pboard = [sender draggingPasteboard];
if (@available(macOS 10.13, *)) {
if ( [[pboard types] containsObject:NSPasteboardTypeFileURL] ) {
NSString *fileURL = [[NSURL URLFromPasteboard:pboard] path];
NSArray *splitPath = [fileURL componentsSeparatedByString:@"/"];

if([splitPath.lastObject isEqualToString:@"main.lua"] ){
AppDelegate * appDelegate = (AppDelegate*)[NSApp delegate];
Rtt::MacSimulatorServices * simulatorServices = new Rtt::MacSimulatorServices(appDelegate, (CoronaWindowController *)self, nil);
simulatorServices->OpenProject( [[fileURL stringByReplacingOccurrencesOfString:@"main.lua" withString:@""] UTF8String] );
}
}
}
return YES;
}
#endif
@end

// ----------------------------------------------------------------------------
9 changes: 5 additions & 4 deletions platform/mac/Credits.rtfd/TXT.rtf
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf470
{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;}
{\rtf1\ansi\ansicpg1252\cocoartf2708
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 HelveticaNeue-Bold;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\margl1440\margr1440\vieww12600\viewh10200\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\qc\partightenfactor0

\f0\b\fs24 \cf0 Copyright \'a9 2020-2021 Solar2D.\
All rights reserved.}
\f0\b\fs24 \cf0 Copyright \'a9 2020-2023 Solar2D.\
All rights reserved.}
2 changes: 1 addition & 1 deletion platform/mac/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<key>NSHighResolutionCapable</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2020-2021 Solar2D. All rights reserved.</string>
<string>Copyright © 2020-2023 Solar2D. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
Expand Down
1 change: 1 addition & 0 deletions platform/mac/Rtt_MacSimulator.mm
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@
NSWindowController *windowController = [[NSWindowController alloc] initWithWindow:instanceWindow];

[instanceWindow setDelegate:(id <NSWindowDelegate>)windowController];


fWindow = instanceWindow;
fWindowController = windowController;
Expand Down