void BuildIOS::Build(const String& buildPath) { buildPath_ = buildPath + "/IOS-Build"; Initialize(); FileSystem* fileSystem = GetSubsystem<FileSystem>(); if (fileSystem->DirExists(buildPath_)) fileSystem->RemoveDir(buildPath_, true); #ifdef ATOMIC_PLATFORM_WINDOWS String buildSourceDir = fileSystem->GetProgramDir(); #else String buildSourceDir = fileSystem->GetAppBundleResourceFolder(); #endif String buildAppSourceDir = buildSourceDir + "Deployment/IOS/AtomicPlayer.app"; fileSystem->CreateDir(buildPath_); String buildDestDist = buildPath_ + "/AtomicPlayer.app"; fileSystem->CreateDir(buildDestDist); String resourcePackagePath = buildDestDist + "/AtomicResources.pak"; GenerateResourcePackage(resourcePackagePath); fileSystem->Copy(buildAppSourceDir + "/AtomicPlayer", buildDestDist + "/AtomicPlayer"); fileSystem->Copy(buildAppSourceDir + "/PkgInfo", buildDestDist + "/PkgInfo"); BuildSystem* buildSystem = GetSubsystem<BuildSystem>(); IOSBuildSettings settings = buildSystem->GetBuildSettings()->GetIOSSettings(); fileSystem->Copy(settings.provisionFile, buildDestDist + "/embedded.mobileprovision"); String entitlements = GenerateEntitlements(); String plist = GenerateInfoPlist(); File file(context_, buildPath_ + "/AtomicPlayer.app.xcent", FILE_WRITE); if (file.IsOpen()) { file.Write(entitlements.CString(), entitlements.Length()); file.Close(); } File pfile(context_, buildDestDist + "/Info.plist", FILE_WRITE); if (pfile.IsOpen()) { pfile.Write(plist.CString(), plist.Length()); pfile.Close(); } RunConvertPList(); }
EditorData::EditorData(Context* context, Editor* editor) : Object(context), editor_(editor) { FileSystem* fileSystem = GetSubsystem<FileSystem>(); uiSceneFilters.Push("*.xml"); uiSceneFilters.Push("*.bin"); uiSceneFilters.Push("*.*"); uiElementFilters.Push("*.xml"); uiAllFilters.Push("*.*"); uiScriptFilters.Push("*.*"); uiScriptFilters.Push("*.as"); uiScriptFilters.Push("*.lua"); uiParticleFilters.Push("*.xml"); uiRenderPathFilters.Push("*.xml"); uiSceneFilter = 0; uiElementFilter = 0; uiNodeFilter = 0; uiImportFilter = 0; uiScriptFilter = 0; uiParticleFilter = 0; uiRenderPathFilter = 0; uiScenePath = fileSystem->GetProgramDir() + "Data/Scenes"; uiElementPath = fileSystem->GetProgramDir() + "Data/UI"; uiNodePath = fileSystem->GetProgramDir() + "Data/Objects"; uiScriptPath = fileSystem->GetProgramDir() + "Data/Scripts"; uiParticlePath = fileSystem->GetProgramDir() + "Data/Particles"; uiRenderPathPath = fileSystem->GetProgramDir() + "CoreData/RenderPaths"; screenshotDir = fileSystem->GetProgramDir() + "Screenshots"; }
void NETAtomicPlayer::ReadEngineConfig() { FileSystem* fileSystem = GetSubsystem<FileSystem>(); #ifdef ATOMIC_PLATFORM_OSX String filename = fileSystem->GetProgramDir() + "../Resources/Settings/Engine.json"; #else String filename = fileSystem->GetProgramDir() + "Settings/Engine.json"; #endif if (!fileSystem->FileExists(filename)) return; if (EngineConfig::LoadFromFile(context_, filename)) { EngineConfig::ApplyConfig(engineParameters_, true); } }
void AEEditorApp::Setup() { context_->SetEditorContext(true); ToolEnvironment* env = new ToolEnvironment(context_); context_->RegisterSubsystem(env); ToolSystem* system = new ToolSystem(context_); context_->RegisterSubsystem(system); #ifdef ATOMIC_DEV_BUILD if (!env->InitFromJSON()) { ErrorExit(ToString("Unable to initialize tool environment from %s", env->GetDevConfigFilename().CString())); return; } #else env->InitFromPackage(); #endif engineParameters_["WindowTitle"] = "AtomicEditor"; engineParameters_["WindowResizable"] = true; engineParameters_["FullScreen"] = false; engineParameters_["LogLevel"] = LOG_DEBUG; FileSystem* filesystem = GetSubsystem<FileSystem>(); engineParameters_["LogName"] = filesystem->GetAppPreferencesDir("AtomicEditor", "Logs") + "AtomicEditor.log"; #ifdef ATOMIC_PLATFORM_OSX engineParameters_["WindowIcon"] = "Images/AtomicLogo32.png"; #endif #ifdef ATOMIC_DEV_BUILD engineParameters_["ResourcePrefixPath"] = ""; String ScriptPath = env->GetRootSourceDir() + "Script"; String resourcePaths = env->GetCoreDataDir() + ";" + env->GetEditorDataDir() + ";" + ScriptPath; engineParameters_["ResourcePaths"] = resourcePaths; #else #ifdef ATOMIC_PLATFORM_OSX engineParameters_["ResourcePrefixPath"] = "../Resources"; #else engineParameters_["ResourcePrefixPath"] = filesystem->GetProgramDir() + "Resources"; #endif engineParameters_["ResourcePaths"] = "CoreData;EditorData;Script"; #endif // ATOMIC_DEV_BUILD }
void GameEconomicGameClientStateSplash::SplashStatInit(void) { /// Get Needed SubSystems ResourceCache* cache = GetSubsystem<ResourceCache>(); Renderer* renderer = GetSubsystem<Renderer>(); Graphics* graphics = GetSubsystem<Graphics>(); UI* ui = GetSubsystem<UI>(); FileSystem * filesystem = GetSubsystem<FileSystem>(); /// Create variables (urho3d) String InputDataFile; InputDataFile.Append(filesystem->GetProgramDir().CString()); InputDataFile.Append("Resources/Scenes/"); InputDataFile.Append("Login1.xml"); bool success; /// Check if the input data file exist if(filesystem->FileExists(InputDataFile)) { /// Open file as a Urho3d Datafile dataFile = new File(context_, InputDataFile, FILE_READ); if (dataFile -> IsOpen()) { /// Get File Extension String extension = GetExtension(InputDataFile); /// Determine file extension if (extension != ".xml") { ///success= Existence-> scene_ -> Load(dataFile); success = Existence-> scene_ -> LoadAsync(dataFile); } else { success= Existence-> scene_ ->LoadAsyncXML(dataFile); } } else { /// set is error success=false; } } /// on update SubscribeToEvent(E_UPDATE, HANDLER(GameEconomicGameClientStateSplash, HandlerSplashUpdate)); // Keep visible until rendering of the scene return; }
/// Save account information to a file void GameEconomicGameClient::SaveConfiguration(Configuration &configuration) { /// Get Resource ResourceCache * cache = GetSubsystem<ResourceCache>(); FileSystem * fileSystem = GetSubsystem<FileSystem>(); String configFileName; /// Set directory and path for network file configFileName.Append(fileSystem->GetProgramDir().CString()); configFileName.Append(""); configFileName.Append("Configuration.xml"); /// Check if the account file information exist if(fileSystem->FileExists(configFileName.CString())) { fileSystem->Delete(configFileName.CString()); } cout << "It got here "<<endl; File saveFile(context_, configFileName.CString(), FILE_WRITE); XMLFile * preferencefileconfig = new XMLFile(context_); XMLElement configElem = preferencefileconfig -> CreateRoot("Configuration"); XMLElement GameModeConfigurationElement = configElem.CreateChild("GameModeConfiguration"); XMLElement VideoConfigurationElement= configElem.CreateChild("VideoConfiguration"); /// Set true false if(configuration.GameModeForceTablet==true) { GameModeConfigurationElement.SetAttribute("GameModeForceTablet", "true"); } else { GameModeConfigurationElement.SetAttribute("GameModeForceTablet", "false"); } /// Convert video bloom to float String VideoBloomParamValue1String(configuration.VideoBloomParam1); String VideoBloomParamValue2String(configuration.VideoBloomParam2); /// Copy values testing VideoConfigurationElement.SetAttribute("BloomParam1",VideoBloomParamValue1String); VideoConfigurationElement.SetAttribute("BloomParam2",VideoBloomParamValue2String); preferencefileconfig->Save(saveFile); return; }
void NETAtomicPlayer::ReadEngineConfig() { FileSystem* fileSystem = GetSubsystem<FileSystem>(); String filename = fileSystem->GetProgramDir() + "Settings/Engine.json"; if (!fileSystem->FileExists(filename)) return; if (EngineConfig::LoadFromFile(context_, filename)) { EngineConfig::ApplyConfig(engineParameters_, true); } }
void Player::Setup() { #if DESKTOP FileSystem* fs = GetFileSystem(); engineParameters_[EP_RESOURCE_PREFIX_PATHS] = fs->GetProgramDir() + ";" + fs->GetCurrentDir(); #endif engineParameters_[EP_RESOURCE_PATHS] = "Cache;Resources"; JSONFile file(context_); if (!file.LoadFile(ToString("%s%s", APK, "Settings.json"))) return; for (auto& pair : file.GetRoot().GetObject()) engineParameters_[pair.first] = pair.second.GetVariant(); }
bool UINewProject::Create2DProject(const String& projectPath, const String& filename) { FileSystem* fileSystem = GetSubsystem<FileSystem>(); #ifdef ATOMIC_PLATFORM_OSX String templateSourceDir = fileSystem->GetAppBundleResourceFolder(); #else String templateSourceDir = fileSystem->GetProgramDir(); #endif templateSourceDir += "/ProjectTemplates/Project2D"; fileSystem->CopyDir(templateSourceDir + "/Resources", projectPath + "/Resources"); File file(context_, projectPath + "/" + filename + ".atomic", FILE_WRITE); file.Close(); return true; }
void AEEditorApp::Setup() { context_->SetEditorContext(true); AEEditorCommon::Setup(); ToolEnvironment* env = GetSubsystem<ToolEnvironment>(); engineParameters_["WindowTitle"] = "AtomicEditor"; engineParameters_["WindowResizable"] = true; engineParameters_["FullScreen"] = false; engineParameters_["LogLevel"] = LOG_DEBUG; FileSystem* filesystem = GetSubsystem<FileSystem>(); engineParameters_["LogName"] = filesystem->GetAppPreferencesDir("AtomicEditor", "Logs") + "AtomicEditor.log"; #ifdef ATOMIC_PLATFORM_OSX engineParameters_["WindowIcon"] = "Images/AtomicLogo32.png"; #endif #ifdef ATOMIC_DEV_BUILD engineParameters_["ResourcePrefixPath"] = ""; String resourcePaths = env->GetCoreDataDir() + ";" + env->GetEditorDataDir(); // for dev builds, add the compile editor scripts from artifacts resourcePaths += ";" + env->GetRootSourceDir() + "Artifacts/Build/Resources/EditorData/"; engineParameters_["ResourcePaths"] = resourcePaths; #else #ifdef ATOMIC_PLATFORM_OSX engineParameters_["ResourcePrefixPath"] = "../Resources"; #else engineParameters_["ResourcePrefixPath"] = filesystem->GetProgramDir() + "Resources"; #endif engineParameters_["ResourcePaths"] = "CoreData;EditorData"; #endif // ATOMIC_DEV_BUILD ReadPreferences(); }
void BuildIOS::Initialize() { Editor* editor = GetSubsystem<Editor>(); Project* project = editor->GetProject(); FileSystem* fileSystem = GetSubsystem<FileSystem>(); #ifdef ATOMIC_PLATFORM_WINDOWS String bundleResources = fileSystem->GetProgramDir(); #else String bundleResources = fileSystem->GetAppBundleResourceFolder(); #endif String projectResources = project->GetResourcePath(); String coreDataFolder = bundleResources + "CoreData/"; AddResourceDir(coreDataFolder); AddResourceDir(projectResources); BuildResourceEntries(); }
bool ToolEnvironment::InitFromDistribution() { toolPrefs_->Load(); FileSystem* fileSystem = GetSubsystem<FileSystem>(); #ifdef ATOMIC_PLATFORM_WINDOWS editorBinary_ = fileSystem->GetProgramDir() + "AtomicEditor.exe"; String resourcesDir = fileSystem->GetProgramDir() + "Resources/"; playerBinary_ = resourcesDir + "ToolData/Deployment/Windows/x64/AtomicPlayer.exe"; #elif ATOMIC_PLATFORM_LINUX editorBinary_ = fileSystem->GetProgramDir() + "AtomicEditor"; String resourcesDir = fileSystem->GetProgramDir() + "Resources/"; playerBinary_ = resourcesDir + "ToolData/Deployment/Linux/AtomicPlayer"; #else editorBinary_ = fileSystem->GetProgramDir() + "AtomicEditor"; String resourcesDir = GetPath(RemoveTrailingSlash(fileSystem->GetProgramDir())) + "Resources/"; playerAppFolder_ = resourcesDir + "ToolData/Deployment/MacOS/AtomicPlayer.app/"; #endif resourceCoreDataDir_ = resourcesDir + "CoreData"; resourcePlayerDataDir_ = resourcesDir + "PlayerData"; toolDataDir_ = resourcesDir + "ToolData/"; // AtomicNET #ifdef ATOMIC_DEBUG String config = "Debug"; #else String config = "Release"; #endif atomicNETRootDir_ = resourcesDir + "ToolData/AtomicNET/"; atomicNETCoreAssemblyDir_ = atomicNETRootDir_ + config + "/"; #ifdef ATOMIC_PLATFORM_OSX monoExecutableDir_ = "/Library/Frameworks/Mono.framework/Versions/Current/Commands/"; atomicNETNuGetBinary_ = monoExecutableDir_ + "nuget"; #endif return true; }
/// Load Communication Logs bool GameEconomicGameClient::LoadCommunicationLogs(LogFormatType LogType, Vector<CommunicationLog> * TargetLogs) { /// Grab resources FileSystem * fileSystem = GetSubsystem<FileSystem>(); bool success=false; /// Create String String configFileName; /// Set directory and path for network file configFileName.Append(fileSystem->GetProgramDir().CString()); configFileName.Append("CommunicationLogs/DefaultLogs.xml"); /// If file does not exist exit function with null structure if (!fileSystem->FileExists(configFileName)) { cout << "No file found communication log" << endl; return false; } /// Flag file for loading and load File loadFile(context_, configFileName, FILE_READ); XMLFile * communicationXML = new XMLFile(context_); communicationXML -> Load(loadFile); XMLElement communicationRootElement = communicationXML->GetRoot(); /// If no configuration is set or no root if (communicationRootElement.IsNull()) { return false; } /// Setupload data XMLElement TempLogElement; String FormatText; /// Log log format Personal if(LogType == LogFormat_Personal) { FormatText.Append(String("PersonalLog")); TempLogElement = communicationRootElement.GetChild(FormatText); } else { return false; } /// If no network server element return false; while(!TempLogElement.IsNull()) { /// Create a temporary log CommunicationLog TempLog; if (TempLogElement.HasAttribute("LogCreation")) TempLog.Creation= TempLogElement.GetInt("LogCreation"); if (TempLogElement.HasAttribute("LogTitle")) TempLog.Title = TempLogElement.GetAttribute("LogTitle"); if (TempLogElement.HasAttribute("LogText")) TempLog.Text = TempLogElement.GetAttribute("LogText"); TargetLogs->Push(TempLog); cout << "Adding" << TempLog.Title.CString()<<endl; /// Get next TempLogElement=communicationRootElement.GetNext(FormatText); } return success; }
bool EditorMode::PlayProject(String addArgs, bool debug) { FileSystem* fileSystem = GetSubsystem<FileSystem>(); ToolSystem* tsystem = GetSubsystem<ToolSystem>(); Project* project = tsystem->GetProject(); if (!project) return false; ToolEnvironment* env = GetSubsystem<ToolEnvironment>(); String playerBinary = env->GetEditorBinary(); // TODO: We need to configure project as managed bool managed = false; if (fileSystem->FileExists(project->GetResourcePath() + "AtomicProject.dll")) { managed = true; playerBinary = env->GetAtomicNETManagedIPCPlayerBinary(); } Vector<String> paths; paths.Push(env->GetCoreDataDir()); paths.Push(env->GetPlayerDataDir()); paths.Push(project->GetResourcePath()); // fixme: this is for loading from cache paths.Push(project->GetProjectPath()); paths.Push(project->GetProjectPath() + "Cache"); String resourcePaths; resourcePaths.Join(paths, "!"); Vector<String> vargs; String args = ToString("--player --project \"%s\"", AddTrailingSlash(project->GetProjectPath()).CString()); vargs = args.Split(' '); if (managed) { vargs.Insert(0, ToString("\"%s\"", (fileSystem->GetProgramDir() + "Resources/").CString())); vargs.Insert(0, "--resourcePrefix"); } if (debug) vargs.Insert(0, "--debug"); if (addArgs.Length() > 0) vargs.Insert(0, addArgs.Split(' ')); String dump; dump.Join(vargs, " "); ATOMIC_LOGINFOF("Launching Broker %s %s", playerBinary.CString(), dump.CString()); IPC* ipc = GetSubsystem<IPC>(); playerBroker_ = ipc->SpawnWorker(playerBinary, vargs); if (playerBroker_) { SubscribeToEvent(playerBroker_, E_IPCWORKERSTART, ATOMIC_HANDLER(EditorMode, HandleIPCWorkerStarted)); SubscribeToEvent(E_IPCPLAYERPAUSERESUMEREQUEST, ATOMIC_HANDLER(EditorMode, HandleIPCPlayerPauseResumeRequest)); SubscribeToEvent(E_IPCPLAYERUPDATESPAUSEDRESUMED, ATOMIC_HANDLER(EditorMode, HandleIPCPlayerUpdatesPausedResumed)); SubscribeToEvent(E_IPCPLAYERPAUSESTEPREQUEST, ATOMIC_HANDLER(EditorMode, HandleIPCPlayerPauseStepRequest)); SubscribeToEvent(E_IPCPLAYEREXITREQUEST, ATOMIC_HANDLER(EditorMode, HandleIPCPlayerExitRequest)); SubscribeToEvent(playerBroker_, E_IPCJSERROR, ATOMIC_HANDLER(EditorMode, HandleIPCJSError)); SubscribeToEvent(playerBroker_, E_IPCWORKEREXIT, ATOMIC_HANDLER(EditorMode, HandleIPCWorkerExit)); SubscribeToEvent(playerBroker_, E_IPCWORKERLOG, ATOMIC_HANDLER(EditorMode, HandleIPCWorkerLog)); } return playerBroker_.NotNull(); }
Sprite* Sample::CreateSVGSprite(const String& file) { FileSystem* fileSystem = GetSubsystem<FileSystem>(); String exePath = fileSystem->GetProgramDir(); String svgfile = exePath + file; if (!fileSystem->FileExists(svgfile)) return NULL; NSVGimage *image = NULL; NSVGrasterizer *rast = NULL; int w, h; LOGINFOF("parsing %s\n", svgfile.CString()); image = nsvgParseFromFile(svgfile.CString(), "px", 128.0f); if (image == NULL) { LOGERROR("Could not open SVG image.\n"); } w = image->width; h = image->height; rast = nsvgCreateRasterizer(); if (rast == NULL) { LOGERROR("Could not init rasterizer.\n"); } rast->tessTol = 2.25f; rast->distTol = 2.1f; SharedPtr<Image> saveimage(new Image(context_)); saveimage->SetSize(w, h, 4); LOGINFOF("rasterizing image %d x %d\n", w, h); nsvgRasterize(rast, image, 0.0f, 0.0f, 1, saveimage->GetData(), w, h, w * 4); nsvgDeleteRasterizer(rast); nsvgDelete(image); // Get logo texture ResourceCache* cache = GetSubsystem<ResourceCache>(); Texture2D* logoTexture = new Texture2D(context_); logoTexture->SetData(saveimage); Sprite* logoSprite_ = new Sprite(context_); // Set logo sprite texture logoSprite_->SetTexture(logoTexture); int textureWidth = logoTexture->GetWidth(); int textureHeight = logoTexture->GetHeight(); // Set logo sprite scale logoSprite_->SetScale(256.0f / textureWidth); // Set logo sprite size logoSprite_->SetSize(textureWidth, textureHeight); // Set logo sprite hot spot logoSprite_->SetHotSpot(textureWidth / 2, textureHeight / 2); // Set logo sprite alignment logoSprite_->SetAlignment(HA_CENTER, VA_CENTER); return logoSprite_; }
void BuildMac::Build(const String& buildPath) { buildPath_ = buildPath + "/Mac-Build"; Initialize(); BuildSystem* buildSystem = GetSubsystem<BuildSystem>(); // BEGIN LICENSE MANAGEMENT LicenseSystem *licenseSystem = GetSubsystem<LicenseSystem>(); if (licenseSystem->IsStandardLicense()) { if (containsMDL_) { buildSystem->BuildComplete(CE_PLATFORM_MAC, buildPath_, false, true); return; } } // END LICENSE MANAGEMENT FileSystem* fileSystem = GetSubsystem<FileSystem>(); if (fileSystem->DirExists(buildPath_)) fileSystem->RemoveDir(buildPath_, true); #ifdef CLOCKWORK_PLATFORM_WINDOWS String buildSourceDir = fileSystem->GetProgramDir(); #else String buildSourceDir = fileSystem->GetAppBundleResourceFolder(); #endif buildSourceDir += "Deployment/MacOS/ClockworkPlayer.app"; fileSystem->CreateDir(buildPath_); buildPath_ += "/ClockworkPlayer.app"; fileSystem->CreateDir(buildPath_); fileSystem->CreateDir(buildPath_ + "/Contents"); fileSystem->CreateDir(buildPath_ + "/Contents/MacOS"); fileSystem->CreateDir(buildPath_ + "/Contents/Resources"); String resourcePackagePath = buildPath_ + "/Contents/Resources/ClockworkResources.pak"; GenerateResourcePackage(resourcePackagePath); fileSystem->Copy(buildSourceDir + "/Contents/Resources/Clockwork.icns", buildPath_ + "/Contents/Resources/Clockwork.icns"); fileSystem->Copy(buildSourceDir + "/Contents/Info.plist", buildPath_ + "/Contents/Info.plist"); fileSystem->Copy(buildSourceDir + "/Contents/MacOS/ClockworkPlayer", buildPath_ + "/Contents/MacOS/ClockworkPlayer"); #ifdef CLOCKWORK_PLATFORM_OSX Vector<String> args; args.Push("+x"); args.Push(buildPath_ + "/Contents/MacOS/ClockworkPlayer"); fileSystem->SystemRun("chmod", args); #endif buildPath_ = buildPath + "/Mac-Build"; buildSystem->BuildComplete(CE_PLATFORM_MAC, buildPath_); }
bool Engine::Initialize(const VariantMap& parameters) { if (initialized_) return true; PROFILE(InitEngine); // Set headless mode headless_ = GetParameter(parameters, "Headless", false).GetBool(); // Register the rest of the subsystems if (!headless_) { context_->RegisterSubsystem(new Graphics(context_)); context_->RegisterSubsystem(new Renderer(context_)); } else { // Register graphics library objects explicitly in headless mode to allow them to work without using actual GPU resources RegisterGraphicsLibrary(context_); } // In debug mode, check now that all factory created objects can be created without crashing #ifdef _DEBUG const HashMap<ShortStringHash, SharedPtr<ObjectFactory> >& factories = context_->GetObjectFactories(); for (HashMap<ShortStringHash, SharedPtr<ObjectFactory> >::ConstIterator i = factories.Begin(); i != factories.End(); ++i) SharedPtr<Object> object = i->second_->CreateObject(); #endif // Start logging Log* log = GetSubsystem<Log>(); if (log) { if (HasParameter(parameters, "LogLevel")) log->SetLevel(GetParameter(parameters, "LogLevel").GetInt()); log->SetQuiet(GetParameter(parameters, "LogQuiet", false).GetBool()); log->Open(GetParameter(parameters, "LogName", "Urho3D.log").GetString()); } // Set maximally accurate low res timer GetSubsystem<Time>()->SetTimerPeriod(1); // Configure max FPS if (GetParameter(parameters, "FrameLimiter", true) == false) SetMaxFps(0); // Set amount of worker threads according to the available physical CPU cores. Using also hyperthreaded cores results in // unpredictable extra synchronization overhead. Also reserve one core for the main thread unsigned numThreads = GetParameter(parameters, "WorkerThreads", true).GetBool() ? GetNumPhysicalCPUs() - 1 : 0; if (numThreads) { GetSubsystem<WorkQueue>()->CreateThreads(numThreads); LOGINFO(ToString("Created %u worker thread%s", numThreads, numThreads > 1 ? "s" : "")); } // Add resource paths ResourceCache* cache = GetSubsystem<ResourceCache>(); FileSystem* fileSystem = GetSubsystem<FileSystem>(); String exePath = fileSystem->GetProgramDir(); Vector<String> resourcePaths = GetParameter(parameters, "ResourcePaths", "CoreData;Data").GetString().Split(';'); Vector<String> resourcePackages = GetParameter(parameters, "ResourcePackages").GetString().Split(';'); for (unsigned i = 0; i < resourcePaths.Size(); ++i) { bool success = false; // If path is not absolute, prefer to add it as a package if possible if (!IsAbsolutePath(resourcePaths[i])) { String packageName = exePath + resourcePaths[i] + ".pak"; if (fileSystem->FileExists(packageName)) { SharedPtr<PackageFile> package(new PackageFile(context_)); if (package->Open(packageName)) { cache->AddPackageFile(package); success = true; } } if (!success) { String pathName = exePath + resourcePaths[i]; if (fileSystem->DirExists(pathName)) success = cache->AddResourceDir(pathName); } } else { String pathName = resourcePaths[i]; if (fileSystem->DirExists(pathName)) success = cache->AddResourceDir(pathName); } if (!success) { LOGERROR("Failed to add resource path " + resourcePaths[i]); return false; } } // Then add specified packages for (unsigned i = 0; i < resourcePackages.Size(); ++i) { bool success = false; String packageName = exePath + resourcePackages[i]; if (fileSystem->FileExists(packageName)) { SharedPtr<PackageFile> package(new PackageFile(context_)); if (package->Open(packageName)) { cache->AddPackageFile(package); success = true; } } if (!success) { LOGERROR("Failed to add resource package " + resourcePackages[i]); return false; } } // Initialize graphics & audio output if (!headless_) { Graphics* graphics = GetSubsystem<Graphics>(); Renderer* renderer = GetSubsystem<Renderer>(); if (HasParameter(parameters, "ExternalWindow")) graphics->SetExternalWindow(GetParameter(parameters, "ExternalWindow").GetPtr()); graphics->SetForceSM2(GetParameter(parameters, "ForceSM2", false).GetBool()); graphics->SetWindowTitle(GetParameter(parameters, "WindowTitle", "Urho3D").GetString()); if (!graphics->SetMode( GetParameter(parameters, "WindowWidth", 0).GetInt(), GetParameter(parameters, "WindowHeight", 0).GetInt(), GetParameter(parameters, "FullScreen", true).GetBool(), GetParameter(parameters, "WindowResizable", false).GetBool(), GetParameter(parameters, "VSync", false).GetBool(), GetParameter(parameters, "TripleBuffer", false).GetBool(), GetParameter(parameters, "MultiSample", 1).GetInt() )) return false; if (HasParameter(parameters, "RenderPath")) renderer->SetDefaultRenderPath(cache->GetResource<XMLFile>(GetParameter(parameters, "RenderPath").GetString())); renderer->SetDrawShadows(GetParameter(parameters, "Shadows", true).GetBool()); if (renderer->GetDrawShadows() && GetParameter(parameters, "LowQualityShadows", false).GetBool()) renderer->SetShadowQuality(SHADOWQUALITY_LOW_16BIT); if (GetParameter(parameters, "Sound", true).GetBool()) { GetSubsystem<Audio>()->SetMode( GetParameter(parameters, "SoundBuffer", 100).GetInt(), GetParameter(parameters, "SoundMixRate", 44100).GetInt(), GetParameter(parameters, "SoundStereo", true).GetBool(), GetParameter(parameters, "SoundInterpolation", true).GetBool() ); } } // Init FPU state of main thread InitFPU(); frameTimer_.Reset(); initialized_ = true; return true; }
void AEPlayerApplication::Setup() { AEEditorCommon::Setup(); // Read the engine configuration ReadEngineConfig(); engine_->SetAutoExit(false); engineParameters_.InsertNew("WindowTitle", "AtomicPlayer"); #if (ATOMIC_PLATFORM_ANDROID) engineParameters_["FullScreen"] = true; engineParameters_["ResourcePaths"] = "CoreData;AtomicResources"; #elif ATOMIC_PLATFORM_WEB engineParameters_["FullScreen"] = false; engineParameters_["ResourcePaths"] = "AtomicResources"; // engineParameters_["WindowWidth"] = 1280; // engineParameters_["WindowHeight"] = 720; #elif ATOMIC_PLATFORM_IOS engineParameters_["FullScreen"] = false; engineParameters_["ResourcePaths"] = "AtomicResources"; #else engineParameters_["FullScreen"] = false; engineParameters_["WindowWidth"] = 1280; engineParameters_["WindowHeight"] = 720; #endif engineParameters_.InsertNew("LogLevel", LOG_DEBUG); #if ATOMIC_PLATFORM_WINDOWS || ATOMIC_PLATFORM_LINUX engineParameters_["WindowIcon"] = "Images/AtomicLogo32.png"; engineParameters_["ResourcePrefixPath"] = "AtomicPlayer_Resources"; #elif ATOMIC_PLATFORM_ANDROID //engineParameters_["ResourcePrefixPath"] = "assets"; #elif ATOMIC_PLATFORM_OSX engineParameters_["ResourcePrefixPath"] = "../Resources"; #endif FileSystem* filesystem = GetSubsystem<FileSystem>(); const Vector<String>& arguments = GetArguments(); for (unsigned i = 0; i < arguments.Size(); ++i) { if (arguments[i].Length() > 1) { String argument = arguments[i].ToLower(); String value = i + 1 < arguments.Size() ? arguments[i + 1] : String::EMPTY; if (argument == "--log-std") { SubscribeToEvent(E_LOGMESSAGE, HANDLER(AEPlayerApplication, HandleLogMessage)); } else if (argument == "--debug") { debugPlayer_ = true; } else if (argument == "--project" && value.Length()) { engineParameters_["ResourcePrefixPath"] = ""; value = AddTrailingSlash(value); // check that cache exists if (!filesystem->DirExists(value + "Cache")) { ErrorExit("Project cache folder does not exist, projects must be loaded into the Atomic Editor at least once before using the --player command line mode"); return; } #ifdef ATOMIC_DEV_BUILD String resourcePaths = ToString("%s/Resources/CoreData;%s/Resources/PlayerData;%sResources;%s;%sCache", ATOMIC_ROOT_SOURCE_DIR, ATOMIC_ROOT_SOURCE_DIR, value.CString(), value.CString(), value.CString()); #else #ifdef __APPLE__ engineParameters_["ResourcePrefixPath"] = "../Resources"; #else engineParameters_["ResourcePrefixPath"] = filesystem->GetProgramDir() + "Resources"; #endif String resourcePaths = ToString("CoreData;PlayerData;%s/;%s/Resources;%s;%sCache", value.CString(), value.CString(), value.CString(), value.CString()); #endif LOGINFOF("Adding ResourcePaths: %s", resourcePaths.CString()); engineParameters_["ResourcePaths"] = resourcePaths; #ifdef ATOMIC_DOTNET NETCore* netCore = GetSubsystem<NETCore>(); String assemblyLoadPath = GetNativePath(ToString("%sResources/Assemblies/", value.CString())); netCore->AddAssemblyLoadPath(assemblyLoadPath); #endif } else if (argument == "--windowposx" && value.Length()) { engineParameters_["WindowPositionX"] = atoi(value.CString()); } else if (argument == "--windowposy" && value.Length()) { engineParameters_["WindowPositionY"] = atoi(value.CString()); } else if (argument == "--windowwidth" && value.Length()) { engineParameters_["WindowWidth"] = atoi(value.CString()); } else if (argument == "--windowheight" && value.Length()) { engineParameters_["WindowHeight"] = atoi(value.CString()); } else if (argument == "--resizable") { engineParameters_["WindowResizable"] = true; } else if (argument == "--maximize") { engineParameters_["WindowMaximized"] = true; } } } // Use the script file name as the base name for the log file engineParameters_["LogName"] = filesystem->GetAppPreferencesDir("AtomicPlayer", "Logs") + "AtomicPlayer.log"; }
void IPCPlayerApp::ProcessArguments() { PlayerApp::ProcessArguments(); FileSystem* fileSystem = GetSubsystem<FileSystem>(); if (!fileSystem) { ErrorExit("IPCPlayerApp::ProcessArguments FileSystem subsystem does not exist"); } for (unsigned i = 0; i < arguments_.Size(); ++i) { if (arguments_[i].Length() > 1) { String argument = arguments_[i].ToLower(); String value = i + 1 < arguments_.Size() ? arguments_[i + 1] : String::EMPTY; if (argument.StartsWith("--ipc-server=") || argument.StartsWith("--ipc-client=")) { subprocess_ = true; } else if (argument == "--debug") { debugPlayer_ = true; } else if (argument == "--project" && value.Length()) { engineParameters_["ResourcePrefixPath"] = ""; value = AddTrailingSlash(value); AddEngineConfigSearchPath(value + "Settings/"); // check that cache exists if (!fileSystem->DirExists(value + "Cache")) { ErrorExit("Project cache folder does not exist, projects must be loaded into the Atomic Editor at least once before using the --player command line mode"); return; } #ifdef ATOMIC_DEV_BUILD String resourcePaths = ToString("%s/Resources/CoreData;%s/Resources/PlayerData;%sResources;%s;%sCache", ATOMIC_ROOT_SOURCE_DIR, ATOMIC_ROOT_SOURCE_DIR, value.CString(), value.CString(), value.CString()); #else #ifdef __APPLE__ engineParameters_["ResourcePrefixPath"] = "../Resources"; #else engineParameters_["ResourcePrefixPath"] = fileSystem->GetProgramDir() + "Resources"; #endif String resourcePaths = ToString("CoreData;PlayerData;%s/;%s/Resources;%s;%sCache", value.CString(), value.CString(), value.CString(), value.CString()); #endif LOGINFOF("Adding ResourcePaths: %s", resourcePaths.CString()); engineParameters_["ResourcePaths"] = resourcePaths; } } } // IPC client player should not auto exit if a subprocess if (subprocess_) engine_->SetAutoExit(false); }
/// Main program execution code void GameEconomicGameClient::Start() { /// Initialize Init(context_); /// Execute base class startup GameEconomicApp::Start(); ResourceCache* cache = GetSubsystem<ResourceCache>(); XMLFile* style = cache->GetResource<XMLFile>("UI/DefaultStyle.xml"); FileSystem * filesystem = GetSubsystem<FileSystem>(); GameStateHandlerComponent * gamestatehandlercomponent_ = GetSubsystem<GameStateHandlerComponent>(); /// Set aApplication gamestatehandlercomponent_->SetApplication(applicationPtr); /// Get ui UI* ui = GetSubsystem<UI>(); /// create variables (urho3d) String additionresourcePath; /// Append Resource path additionresourcePath.Append(filesystem->GetProgramDir().CString()); additionresourcePath.Append("Resources/"); /// add resource path to last cache -> AddResourceDir(additionresourcePath); /// Load COnfiguration GameConfig = new Configuration(); LoadConfiguration(*GameConfig); /// Turn on networking if(LoadNetworkConfig(NetConfig)==false) { /// Set up network configuration NetConfig.hostport = 3632; NetConfig.hostserver = String("127.0.0.1"); NetConfig.hostidentity = Unauthenticated; } /// Set up default network status NetOnline = NetDisconnected; NetStats = NetworkOffline; /// Set the loaded style as default style uiRoot_->SetDefaultStyle(style); CreateCursor(); ui->GetCursor()->SetVisible(true); /// Initialize Console InitializeConsole(); GetSubsystem<Input>()->Update(); /// Enable OS cursor /// Configure rudimentary state handler gamestatehandlercomponent_ ->SetUIState(UI_NONE); GetSubsystem<Input>()->SetMouseVisible(true); /// load account ///LoadAccount(); /// Create test value testvalue=121; /// Debug output context and testvalue cout << "Debug: ExistenceClient Class Test Value " << testvalue << " context_ " << &context_ << endl; /// Finally subscribe to the update event. Note that by subscribing events at this point we have already missed some events /// like the ScreenMode event sent by the Graphics subsystem when opening the application window. To catch those as well we /// could subscribe in the constructor instead. SubscribeToEvents(); /// Randomize timer srand (time(NULL)); cout << "Debig: Existence App Existence " << applicationPtr ->GetTestString()<< endl; /// Create test value cout << "Debig: Existence App Existence " << applicationPtr ->GetTestString()<< endl; touchenabled_=false; /// Network related SubscribeToEvent(E_NETWORKMESSAGE, HANDLER(GameEconomicGameClient, HandleNetworkMessage)); SubscribeToEvent(E_SERVERCONNECTED, HANDLER(GameEconomicGameClient, HandlerServerConnected)); SubscribeToEvent(E_SERVERDISCONNECTED, HANDLER(GameEconomicGameClient, HandlerServerDisconnected)); SubscribeToEvent(E_CONNECTFAILED, HANDLER(GameEconomicGameClient, HandlerServerConnectionFailed)); ResourcesManager = new ResourceManager(context_); ActivitiesManager = new ActivityManager(context_); gamestatehandlercomponent_->Start(); return; }
void Urho3DPlayer::Setup() { FileSystem* filesystem = GetSubsystem<FileSystem>(); // Read command line from a file if no arguments given. This is primarily intended for mobile platforms. // Note that the command file name uses a hardcoded path that does not utilize the resource system // properly (including resource path prefix), as the resource system is not yet initialized at this point const String commandFileName = filesystem->GetProgramDir() + "Data/CommandLine.txt"; if (GetArguments().Empty() && filesystem->FileExists(commandFileName)) { SharedPtr<File> commandFile(new File(context_, commandFileName)); String commandLine = commandFile->ReadLine(); commandFile->Close(); ParseArguments(commandLine, false); // Reparse engine startup parameters now engineParameters_ = Engine::ParseParameters(GetArguments()); } // Check for script file name const Vector<String>& arguments = GetArguments(); String scriptFileName; if (arguments.Size() && arguments[0][0] != '-') scriptFileName_ = GetInternalPath(arguments[0]); // Show usage if not found if (scriptFileName_.Empty()) { ErrorExit("Usage: Urho3DPlayer <scriptfile> [options]\n\n" "The script file should implement the function void Start() for initializing the " "application and subscribing to all necessary events, such as the frame update.\n" #ifndef WIN32 "\nCommand line options:\n" "-x <res> Horizontal resolution\n" "-y <res> Vertical resolution\n" "-m <level> Enable hardware multisampling\n" "-v Enable vertical sync\n" "-t Enable triple buffering\n" "-w Start in windowed mode\n" "-s Enable resizing when in windowed mode\n" "-q Enable quiet mode which does not log to standard output stream\n" "-b <length> Sound buffer length in milliseconds\n" "-r <freq> Sound mixing frequency in Hz\n" "-p <paths> Resource path(s) to use, separated by semicolons\n" "-ap <paths> Autoload resource path(s) to use, seperated by semicolons\n" "-log <level> Change the log level, valid 'level' values are 'debug', 'info', 'warning', 'error'\n" "-ds <file> Dump used shader variations to a file for precaching\n" "-mq <level> Material quality level, default 2 (high)\n" "-tq <level> Texture quality level, default 2 (high)\n" "-tf <level> Texture filter mode, default 2 (trilinear)\n" "-af <level> Texture anisotropy level, default 4. Also sets anisotropic filter mode\n" "-gl2 Force OpenGL 2 use even if OpenGL 3 is available\n" "-flushgpu Flush GPU command queue each frame. Effective only on Direct3D\n" "-borderless Borderless window mode\n" "-headless Headless mode. No application window will be created\n" "-landscape Use landscape orientations (iOS only, default)\n" "-portrait Use portrait orientations (iOS only)\n" "-prepass Use light pre-pass rendering\n" "-deferred Use deferred rendering\n" "-renderpath <name> Use the named renderpath (must enter full resource name)\n" "-lqshadows Use low-quality (1-sample) shadow filtering\n" "-noshadows Disable shadow rendering\n" "-nolimit Disable frame limiter\n" "-nothreads Disable worker threads\n" "-nosound Disable sound output\n" "-noip Disable sound mixing interpolation\n" "-touch Touch emulation on desktop platform\n" #endif ); } else { // Use the script file name as the base name for the log file engineParameters_["LogName"] = filesystem->GetAppPreferencesDir("urho3d", "logs") + GetFileNameAndExtension(scriptFileName_) + ".log"; } // Construct a search path to find the resource prefix with two entries: // The first entry is an empty path which will be substituted with program/bin directory -- this entry is for binary when it is still in build tree // The second and third entries are possible relative paths from the installed program/bin directory to the asset directory -- these entries are for binary when it is in the Urho3D SDK installation location if (!engineParameters_.Contains("ResourcePrefixPaths")) engineParameters_["ResourcePrefixPaths"] = ";../share/Resources;../share/Urho3D/Resources"; }
void GameEconomicGameClient::LoadConfiguration(Configuration &configuration) { /// Grab resources FileSystem * fileSystem = GetSubsystem<FileSystem>(); /// Set all defaults bool success=false; configuration.GameModeForceTablet=false; configuration.VideoBloomParam1=0.9f; configuration.VideoBloomParam2=0.6f; /// Create String String configFileName; /// Set directory and path for network file configFileName.Append(fileSystem->GetProgramDir().CString()); configFileName.Append(""); configFileName.Append("Configuration.xml"); /// If file does not exist exit function with null structure if (!fileSystem->FileExists(configFileName)) { cout << "Configuration file not found.. Using defaults.. " << endl; return; } /// Flag file for loading and load File loadFile(context_, configFileName, FILE_READ); XMLFile * configurationXML = new XMLFile(context_); configurationXML -> Load(loadFile); XMLElement configElem = configurationXML->GetRoot(); /// If no configuration is set or no root if (configElem.IsNull()) { cout << "Configuration file not found.. Using defaults.. " << endl; return; } /// Basic Config XMLElement GameModeConfigurationElem = configElem.GetChild("GameModeConfiguration"); /// If no network server element return false; if (!GameModeConfigurationElem.IsNull()) { if (GameModeConfigurationElem.HasAttribute("GameModeForceTablet")) configuration.GameModeForceTablet = GameModeConfigurationElem.GetBool("GameModeForceTablet"); } /// Basic Config XMLElement VideoConfigurationElem = configElem.GetChild("VideoConfiguration"); /// If no network server element return false; if (!VideoConfigurationElem.IsNull()) { if (VideoConfigurationElem.HasAttribute("BloomParam1")) configuration.VideoBloomParam1= VideoConfigurationElem.GetFloat("BloomParam1"); if (VideoConfigurationElem.HasAttribute("BloomParam2")) configuration.VideoBloomParam2= VideoConfigurationElem.GetFloat("BloomParam2"); } return; }
void Urho3DPlayer::Setup() { FileSystem* filesystem = GetSubsystem<FileSystem>(); // On Android and iOS, read command line from a file as parameters can not otherwise be easily given #if defined(ANDROID) || defined(IOS) SharedPtr<File> commandFile(new File(context_, filesystem->GetProgramDir() + "Data/CommandLine.txt", FILE_READ)); String commandLine = commandFile->ReadLine(); commandFile->Close(); ParseArguments(commandLine, false); // Reparse engine startup parameters now engineParameters_ = Engine::ParseParameters(GetArguments()); #endif // Check for script file name const Vector<String>& arguments = GetArguments(); String scriptFileName; for (unsigned i = 0; i < arguments.Size(); ++i) { if (arguments[i][0] != '-') { scriptFileName_ = GetInternalPath(arguments[i]); break; } } // Show usage if not found if (scriptFileName_.Empty()) { ErrorExit("Usage: Urho3DPlayer <scriptfile> [options]\n\n" "The script file should implement the function void Start() for initializing the " "application and subscribing to all necessary events, such as the frame update.\n" #ifndef WIN32 "\nCommand line options:\n" "-x <res> Horizontal resolution\n" "-y <res> Vertical resolution\n" "-m <level> Enable hardware multisampling\n" "-v Enable vertical sync\n" "-t Enable triple buffering\n" "-w Start in windowed mode\n" "-s Enable resizing when in windowed mode\n" "-q Enable quiet mode which does not log to standard output stream\n" "-b <length> Sound buffer length in milliseconds\n" "-r <freq> Sound mixing frequency in Hz\n" "-p <paths> Resource path(s) to use, separated by semicolons\n" "-ap <paths> Autoload resource path(s) to use, seperated by semicolons\n" "-log <level> Change the log level, valid 'level' values are 'debug', 'info', 'warning', 'error'\n" "-ds <file> Dump used shader variations to a file for precaching\n" "-mq <level> Material quality level, default 2 (high)\n" "-tq <level> Texture quality level, default 2 (high)\n" "-tf <level> Texture filter mode, default 2 (trilinear)\n" "-af <level> Texture anisotropy level, default 4. Also sets anisotropic filter mode\n" "-flushgpu Flush GPU command queue each frame. Effective only on Direct3D9\n" "-borderless Borderless window mode\n" "-headless Headless mode. No application window will be created\n" "-landscape Use landscape orientations (iOS only, default)\n" "-portrait Use portrait orientations (iOS only)\n" "-prepass Use light pre-pass rendering\n" "-deferred Use deferred rendering\n" "-lqshadows Use low-quality (1-sample) shadow filtering\n" "-noshadows Disable shadow rendering\n" "-nolimit Disable frame limiter\n" "-nothreads Disable worker threads\n" "-nosound Disable sound output\n" "-noip Disable sound mixing interpolation\n" "-sm2 Force SM2.0 rendering\n" "-touch Touch emulation on desktop platform\n" #endif ); } else { // Use the script file name as the base name for the log file //engineParameters_["LogName"] = filesystem->GetAppPreferencesDir("urho3d", "logs") + GetFileNameAndExtension(scriptFileName_) + ".log"; engineParameters_["LogName"]="Urho3D.log"; } }
bool UINewProject::OnEvent(const TBWidgetEvent &ev) { Editor* editor = GetSubsystem<Editor>(); UIModalOps* ops = GetSubsystem<UIModalOps>(); if (ev.type == EVENT_TYPE_CLICK) { if (ev.target->GetID() == TBIDC("cancel")) { ops->Hide(); return true; } int projectType = -1; if (ev.target->GetID() == TBIDC("project_empty")) { projectType = 0; } else if (ev.target->GetID() == TBIDC("project_2d")) { projectType = 1; } else if (ev.target->GetID() == TBIDC("project_3d")) { // BEGIN LICENSE MANAGEMENT LicenseSystem* licenseSystem = GetSubsystem<LicenseSystem>(); if (licenseSystem->IsStandardLicense()) { SharedPtr<UINewProject> keepAlive(this); UIModalOps* ops = GetSubsystem<UIModalOps>(); ops->Hide(); ops->ShowInfoModule3D(); return true; } // END LICENSE MANAGEMENT projectType = 2; } if (projectType != -1) { FileSystem* fileSystem = GetSubsystem<FileSystem>(); #ifdef ATOMIC_PLATFORM_OSX String templateSourceDir = fileSystem->GetAppBundleResourceFolder(); #else String templateSourceDir = fileSystem->GetProgramDir(); #endif if (projectType == 0) templateSourceDir += "/ProjectTemplates/EmptyProject"; else if (projectType == 1) templateSourceDir += "/ProjectTemplates/Project2D"; else templateSourceDir += "/ProjectTemplates/Project3D"; SharedPtr<UINewProject> keepAlive(this); UIModalOps* ops = GetSubsystem<UIModalOps>(); ops->Hide(); ops->ShowCreateProject(templateSourceDir); return true; } } return false; }