-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2,070 changed files
with
6,577,390 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
program AlienInvasion; | ||
|
||
uses | ||
System.StartUpCopy, | ||
FMX.Forms, | ||
uGame in 'uGame.pas' {GameForm}, | ||
uGameOver in 'uGameOver.pas' {FrameGameOver: TFrame}, | ||
uHighScores in 'uHighScores.pas' {FrameHighScores: TFrame}, | ||
uInstructions in 'uInstructions.pas' {FrameInstructions: TFrame}, | ||
uLevelComplete in 'uLevelComplete.pas' {FrameLevelComplete: TFrame}, | ||
uMainMenu in 'uMainMenu.pas' {FrameMainMenu: TFrame}, | ||
uSettings in 'uSettings.pas' {FrameSettings: TFrame}; | ||
|
||
{$R *.res} | ||
|
||
begin | ||
Application.Initialize; | ||
Application.CreateForm(TGameForm, GameForm); | ||
Application.Run; | ||
end. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
//--------------------------------------------------------------------------- | ||
|
||
// This software is Copyright (c) 2016 Embarcadero Technologies, Inc. | ||
// You may only use this software if you are an authorized licensee | ||
// of Delphi, C++Builder or RAD Studio (Embarcadero Products). | ||
// This software is considered a Redistributable as defined under | ||
// the software license agreement that comes with the Embarcadero Products | ||
// and is subject to that software license agreement. | ||
|
||
//--------------------------------------------------------------------------- | ||
|
||
unit AnonThread; | ||
|
||
interface | ||
|
||
uses | ||
System.Classes, System.SysUtils, System.Generics.Collections; | ||
|
||
type | ||
EAnonymousThreadException = class(Exception); | ||
|
||
TAnonymousThread<T> = class(TThread) | ||
private | ||
class var | ||
CRunningThreads:TList<TThread>; | ||
private | ||
FThreadFunc: TFunc<T>; | ||
FOnErrorProc: TProc<Exception>; | ||
FOnFinishedProc: TProc<T>; | ||
FResult: T; | ||
FStartSuspended: Boolean; | ||
private | ||
procedure ThreadTerminate(Sender: TObject); | ||
protected | ||
procedure Execute; override; | ||
public | ||
constructor Create(AThreadFunc: TFunc<T>; AOnFinishedProc: TProc<T>; | ||
AOnErrorProc: TProc<Exception>; ACreateSuspended: Boolean = False; | ||
AFreeOnTerminate: Boolean = True); | ||
|
||
class constructor Create; | ||
class destructor Destroy; | ||
end; | ||
|
||
implementation | ||
|
||
{$IFDEF MACOS} | ||
uses | ||
{$IFDEF IOS} | ||
iOSapi.Foundation | ||
{$ELSE} | ||
MacApi.Foundation | ||
{$ENDIF IOS} | ||
; | ||
{$ENDIF MACOS} | ||
|
||
{ TAnonymousThread } | ||
|
||
class constructor TAnonymousThread<T>.Create; | ||
begin | ||
inherited; | ||
CRunningThreads := TList<TThread>.Create; | ||
end; | ||
|
||
class destructor TAnonymousThread<T>.Destroy; | ||
begin | ||
CRunningThreads.Free; | ||
inherited; | ||
end; | ||
|
||
constructor TAnonymousThread<T>.Create(AThreadFunc: TFunc<T>; AOnFinishedProc: TProc<T>; | ||
AOnErrorProc: TProc<Exception>; ACreateSuspended: Boolean = False; AFreeOnTerminate: Boolean = True); | ||
begin | ||
FOnFinishedProc := AOnFinishedProc; | ||
FOnErrorProc := AOnErrorProc; | ||
FThreadFunc := AThreadFunc; | ||
OnTerminate := ThreadTerminate; | ||
FreeOnTerminate := AFreeOnTerminate; | ||
FStartSuspended := ACreateSuspended; | ||
|
||
//Store a reference to this thread instance so it will play nicely in an ARC | ||
//environment. Failure to do so can result in the TThread.Execute method | ||
//not executing. See http://qc.embarcadero.com/wc/qcmain.aspx?d=113580 | ||
CRunningThreads.Add(Self); | ||
|
||
inherited Create(ACreateSuspended); | ||
end; | ||
|
||
procedure TAnonymousThread<T>.Execute; | ||
{$IFDEF MACOS} | ||
var | ||
lPool: NSAutoreleasePool; | ||
{$ENDIF} | ||
begin | ||
{$IFDEF MACOS} | ||
//Need to create an autorelease pool, otherwise any autorelease objects | ||
//may leak. | ||
//See https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmAutoreleasePools.html#//apple_ref/doc/uid/20000047-CJBFBEDI | ||
lPool := TNSAutoreleasePool.Create; | ||
try | ||
{$ENDIF} | ||
FResult := FThreadFunc; | ||
{$IFDEF MACOS} | ||
finally | ||
lPool.drain; | ||
end; | ||
{$ENDIF} | ||
end; | ||
|
||
procedure TAnonymousThread<T>.ThreadTerminate(Sender: TObject); | ||
var | ||
lException: Exception; | ||
begin | ||
try | ||
if Assigned(FatalException) and Assigned(FOnErrorProc) then | ||
begin | ||
if FatalException is Exception then | ||
lException := Exception(FatalException) | ||
else | ||
lException := EAnonymousThreadException.Create(FatalException.ClassName); | ||
FOnErrorProc(lException) | ||
end | ||
else if Assigned(FOnFinishedProc) then | ||
FOnFinishedProc(FResult); | ||
finally | ||
CRunningThreads.Remove(Self); | ||
end; | ||
end; | ||
|
||
end. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Oops, something went wrong.