/*
* Copyright 2007-2022 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#import <Cocoa/Cocoa.h>
#include <dlfcn.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <mach/machine.h>
#define SYSTEM_MONO_PATH @"/Library/Frameworks/Mono.framework/Versions/Current/"
#define SYSTEM_MONO_MIN_VERSION @"6.4"
#define DOTNET_MIN_MACOS_VERSION 10.15
@interface OpenRALauncher : NSObject <NSApplicationDelegate>
- (void)launchGameWithArgs: (NSArray *)gameArgs;
@end
@implementation OpenRALauncher
BOOL launched = NO;
NSTask *gameTask;
- (NSString *)modName
{
NSDictionary *plist = [[NSBundle mainBundle] infoDictionary];
if (plist)
{
NSString *title = [plist objectForKey:@"CFBundleDisplayName"];
if (title && [title length] > 0)
return title;
}
return @"OpenRA";
}
- (void)exitWithMonoPrompt
{
[NSApp setActivationPolicy: NSApplicationActivationPolicyRegular];
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
NSString *modName = [self modName];
NSString *title = [NSString stringWithFormat: @"Cannot launch %@", modName];
NSString *message = [NSString stringWithFormat: @"%@ requires Mono %@ or later. Please install Mono and try again.", modName, SYSTEM_MONO_MIN_VERSION];
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:title];
[alert setInformativeText:message];
[alert addButtonWithTitle:@"Download Mono"];
[alert addButtonWithTitle:@"Quit"];
NSInteger answer = [alert runModal];
[alert release];
if (answer == NSAlertFirstButtonReturn)
[[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString:@"https://www.mono-project.com/download/"]];
exit(1);
}
- (void)exitWithCrashPrompt
{
[NSApp setActivationPolicy: NSApplicationActivationPolicyRegular];
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
NSString *modName = [self modName];
NSString *message = [NSString stringWithFormat: @"%@ has encountered a fatal error and must close.\nPlease refer to the crash logs and FAQ for more information.", modName];
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:@"Fatal Error"];
[alert setInformativeText:message];
[alert addButtonWithTitle:@"View Logs"];
[alert addButtonWithTitle:@"View FAQ"];
[alert addButtonWithTitle:@"Quit"];
NSInteger answer = [alert runModal];
[alert release];
if (answer == NSAlertFirstButtonReturn)
{
NSString *logDir = [@"~/Library/Application Support/OpenRA/Logs/" stringByExpandingTildeInPath];
[[NSWorkspace sharedWorkspace] openFile: logDir withApplication:@"Finder"];
}
else if (answer == NSAlertSecondButtonReturn)
{
NSDictionary *plist = [[NSBundle mainBundle] infoDictionary];
if (plist)
{
NSString *faqUrl = [plist objectForKey:@"FaqUrl"];
if (faqUrl && [faqUrl length] > 0)
[[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString:faqUrl]];
}
}
exit(1);
}
// Application was launched via a URL handler
- (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
NSMutableArray *gameArgs = [[[NSProcessInfo processInfo] arguments] mutableCopy];
NSDictionary *plist = [[NSBundle mainBundle] infoDictionary];
NSString *url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
if (plist)
{
NSString *joinServerUrl = [plist objectForKey:@"JoinServerUrlScheme"];
if (joinServerUrl && [joinServerUrl length] > 0)
{
NSString *prefix = [joinServerUrl stringByAppendingString: @"://"];
if ([url hasPrefix: prefix])
{
NSString *trimmed = [url substringFromIndex:[prefix length]];
NSArray *parts = [trimmed componentsSeparatedByString:@":"];
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
if ([parts count] == 2 && [formatter numberFromString: [parts objectAtIndex:1]] != nil)
[gameArgs addObject: [NSString stringWithFormat: @"Launch.Connect=%@", trimmed]];
[formatter release];
}
}
}
[self launchGameWithArgs: gameArgs];
[gameArgs release];
}
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
// Register for url events
NSDictionary *plist = [[NSBundle mainBundle] infoDictionary];
if (plist)
{
NSString *joinServerUrl = [plist objectForKey:@"JoinServerUrlScheme"];
NSString *bundleIdentifier = [plist objectForKey:@"CFBundleIdentifier"];
if (joinServerUrl && [joinServerUrl length] > 0 && bundleIdentifier)
{
LSSetDefaultHandlerForURLScheme((CFStringRef)joinServerUrl, (CFStringRef)bundleIdentifier);
[[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(getUrl:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
}
}
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[self launchGameWithArgs: [[NSProcessInfo processInfo] arguments]];
}
- (BOOL)applicationShouldTerminateAfterLastWindowClosed: (NSApplication *)theApplication
{
return YES;
}
- (int)hasValidMono
{
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath: [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent: @"Contents/MacOS/checkmono"]];
[task launch];
[task waitUntilExit];
return [task terminationStatus] == 0;
}
- (void)launchGameWithArgs: (NSArray *)gameArgs
{
if (launched)
{
NSLog(@"launchgame is already running... ignoring request.");
return;
}
launched = YES;
BOOL useMono = NO;
if (@available(macOS 10.15, *))
useMono = [[[NSProcessInfo processInfo] environment]objectForKey:@"OPENRA_PREFER_MONO"] != nil;
else
useMono = YES;
if (useMono && ![self hasValidMono])
[self exitWithMonoPrompt];
// Default values - can be overriden by setting certain keys Info.plist
NSString *modId = nil;
NSDictionary *plist = [[NSBundle mainBundle] infoDictionary];
if (plist)
{
NSString *modIdValue = [plist objectForKey:@"ModId"];
if (modIdValue && [modIdValue length] > 0)
modId = modIdValue;
}
NSString *exePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent: @"Contents/MacOS/"];
NSString *gamePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent: @"Contents/Resources/"];
NSString *launchPath;
NSString *dllPath;
NSString *hostPath;
if (useMono)
{
launchPath = [exePath stringByAppendingPathComponent: @"apphost-mono"];
hostPath = [SYSTEM_MONO_PATH stringByAppendingPathComponent: @"lib/libmonosgen-2.0.dylib"];;
dllPath = [exePath stringByAppendingPathComponent: @"mono/OpenRA.dll"];
}
else
{
size_t size;
cpu_type_t type;
size = sizeof(type);
if (sysctlbyname("hw.cputype", &type, &size, NULL, 0) == 0 && (type & 0xFF) == CPU_TYPE_ARM)
{
launchPath = [exePath stringByAppendingPathComponent: @"apphost-arm64"];
hostPath = [exePath stringByAppendingPathComponent: @"arm64/libhostfxr.dylib"];;
dllPath = [exePath stringByAppendingPathComponent: @"arm64/OpenRA.dll"];
}
else
{
launchPath = [exePath stringByAppendingPathComponent: @"apphost-x86_64"];
hostPath = [exePath stringByAppendingPathComponent: @"x86_64/libhostfxr.dylib"];;
dllPath = [exePath stringByAppendingPathComponent: @"x86_64/OpenRA.dll"];
}
}
NSString *appPath = [exePath stringByAppendingPathComponent: @"Launcher"];
NSString *engineLaunchPath = [self resolveTranslocatedPath: appPath];
NSMutableArray *launchArgs = [NSMutableArray arrayWithCapacity: [gameArgs count] + 5];
[launchArgs addObject: hostPath];
[launchArgs addObject: dllPath];
[launchArgs addObject: [NSString stringWithFormat:@"Engine.LaunchPath=\"%@\"", engineLaunchPath]];
[launchArgs addObject: [NSString stringWithFormat:@"Engine.EngineDir=../../Resources"]];
if (modId)
[launchArgs addObject: [NSString stringWithFormat:@"Game.Mod=%@", modId]];
[launchArgs addObjectsFromArray: gameArgs];
NSLog(@"Running OpenRA with arguments:");
for (size_t i = 0; i
open-ra-3-d-bleed.zip
《OpenRA 3D Bleed:开启实时战略游戏的新维度》 OpenRA,全称Open Red Alert,是一款开源的游戏引擎,旨在复刻经典的西木工作室(Westwood Studios)的即时战略游戏,如《命令与征服:红色警戒》。而"open-ra-3-d-bleed.zip"这个压缩包则为我们带来了一个特别的版本——OpenRA 3D Bleed,它在原有的基础上增加了3D渲染和素材支持,进一步提升了游戏体验,为玩家带来了更为逼真的视觉效果。 OpenRA 3D Bleed的主要亮点在于其3D化渲染技术。传统的OpenRA采用的是等轴测(isometric)视角,这种视角虽然能提供良好的空间感,但与现代游戏相比,视觉效果略显单一。3D Bleed扩展则引入了更先进的图形处理技术,使得单位、建筑和地形都具备了更多的三维细节。这不仅增强了游戏的视觉冲击力,也使游戏场景更加生动,增加了玩家的沉浸感。 此外,3D Bleed还提供了丰富的素材支持。这意味着玩家可以自定义游戏中的模型、贴图和动画,打造自己独特的游戏世界。开发者或MOD制作者可以利用这些工具创造出更具个性化的单位和环境,进一步丰富游戏的内容和策略性。这对于游戏的可玩性和社区的活跃度都有极大的促进作用。 在游戏开发领域,OpenRA 3D Bleed作为一个开源项目,为独立开发者和爱好者提供了宝贵的资源和学习平台。通过研究和修改其源代码,开发者可以深入了解游戏引擎的设计原理,掌握游戏开发的核心技术,包括图形渲染、物理模拟、AI设计等。这为有志于投身游戏行业的学习者提供了实战演练的机会,同时也推动了游戏制作技术的进步。 "open-ra-3-d-bleed.zip"所包含的OpenRA 3D Bleed版本,不仅是对经典游戏的现代化改造,也是游戏开发领域的一个创新实践。它展示了如何通过开源社区的力量,将旧有的游戏体验提升到新的层次,同时也为学习和探索游戏开发技术提供了宝贵的资源。无论是对玩家还是开发者,这都是一个值得深入研究和体验的项目。
- 1
- 2
- 3
- 4
- 5
- 6
- 20
- #完美解决问题
- #运行顺畅
- #内容详尽
- #全网独家
- #注释完整
- 粉丝: 4
- 资源: 1829
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- aspose-cad-24.4.jar
- mysql安装配置教程.txt
- aspose-cad-24.2.jar
- win32汇编环境,窗口程序中基础列表框的应用举例
- Mahou.PDMReader64Setup.2.0.239免安装.zip
- 西电《机器学习》课程笔记pdf
- Thinkphp+Uniapp开发的多端商城系统源码H5小程序APP支持DIY模板直播分销.zip
- jdk-23_windows-x64_bin.msi
- Mysql安装与配置PDF
- WordPress子比搜索关键词编辑插件.zip
- 结构体-test.c-4.25a-master.zip
- 结构体-c-struct-test-8-19.rar
- 结构体变量和结构体数组PDF
- 结构体-struct-test-8-20.rar
- 测试用例 和冒烟测试用例模板
- 基于微信小程序的报刊订阅小程序设计与实现.docx