private static string BuildDefinition(CoreDetails coreDetails, DetailManager[] managers) //rewrite { DefinitionLua definitionLua = new DefinitionLua(); string questCompleteLangId = coreDetails.progressLangID; definitionLua.AddDefinition($"locationId = {coreDetails.locationID}"); definitionLua.AddDefinition($@"areaName = ""{coreDetails.loadArea}"""); if (LoadAreas.isMtbs(coreDetails.locationID)) { definitionLua.AddDefinition($@"clusterName = ""{coreDetails.loadArea.Substring(4)}"""); } definitionLua.AddDefinition($"iconPos = Vector3({coreDetails.coords.xCoord},{coreDetails.coords.yCoord},{coreDetails.coords.zCoord})"); definitionLua.AddDefinition($"radius = {coreDetails.radius}"); definitionLua.AddDefinition($"category = TppQuest.QUEST_CATEGORIES_ENUM.{coreDetails.category}"); definitionLua.AddDefinition($@"questCompleteLangId = ""{questCompleteLangId}"""); definitionLua.AddDefinition("canOpenQuest=InfQuest.AllwaysOpenQuest"); definitionLua.AddDefinition($"questRank = TppDefine.QUEST_RANK.{coreDetails.reward}"); definitionLua.AddDefinition("disableLzs = {}"); foreach (DetailManager manager in managers) { manager.AddToDefinitionLua(definitionLua); } definitionLua.AddPackPath($"/Assets/tpp/pack/mission2/quest/ih/{coreDetails.FpkName}.fpk"); return(definitionLua.GetDefinitionLuaFormatted()); }
public override void SetDetailsFromSetup(Detail detail, CoreDetails core) { // Routes List <string> heliRoutes = new List <string>(); if (core.routeName != "NONE") { heliRoutes = new RouteManager().GetRouteNames(core.routeName); } heliRoutes.AddRange(EnemyInfo.GetCP(core.CPName).CPheliRoutes); routes = heliRoutes; List <Helicopter> qObjects = detail.GetQuestObjects().Cast <Helicopter>().ToList(); int heliCount = (routes.Count > 0 ? 1 : 0); int objectCount = qObjects.Count; for (int i = 0; i < heliCount; i++) { if (i >= objectCount) // add { qObjects.Add(new Helicopter(i)); } } for (int i = objectCount - 1; i >= heliCount; i--) //remove { qObjects.RemoveAt(i); } detail.SetQuestObjects(qObjects.Cast <QuestObject>().ToList()); }
public override void SetDetailsFromSetup(Detail detail, CoreDetails core) { List <Position> stubPositions = detailStub.GetStubLocations().GetPositions(); List <QuestObject> qObjects = detail.GetQuestObjects().ToList(); int positionCount = stubPositions.Count; int objectCount = qObjects.Count; for (int i = 0; i < positionCount; i++) { if (i >= objectCount) // add { qObjects.Add(NewObject(stubPositions[i], i)); } else // modify { qObjects[i].SetPosition(stubPositions[i]); } } for (int i = objectCount - 1; i >= positionCount; i--) //remove { qObjects.RemoveAt(i); } detail.SetQuestObjects(qObjects); }
public void RefreshAllPanels(CoreDetails core) { foreach (DetailManager manager in managerArray.GetManagers()) { manager.UpdateDetailFromSetup(core); manager.RefreshPanel(core); } }
public void SetForm(CoreDetails core) { textBoxQuestTitle.Text = core.QuestTitle; textBoxQuestDesc.Text = core.QuestDesc; textBoxFPKName.Text = core.FpkName; textBoxQuestNum.Text = core.QuestNum; locationID = core.locationID; switch (locationID) { case 10: comboBoxRegion.Text = "Afghanistan"; break; case 20: comboBoxRegion.Text = "Central Africa"; break; case 50: comboBoxRegion.Text = "Mother Base"; break; } comboBoxLoadArea.Text = core.loadArea; textBoxXCoord.Text = core.coords.xCoord; textBoxYCoord.Text = core.coords.yCoord; textBoxZCoord.Text = core.coords.zCoord; comboBoxRadius.Text = core.radius; comboBoxCategory.Text = core.category; comboBoxReward.Text = core.reward; comboBoxCP.Text = core.CPName; refreshNotifsList(); string displayNotification = UpdateNotifsManager.GetDisplayNotification(core.progressLangID); if (displayNotification != null) { comboBoxProgressNotifs.Text = displayNotification; } else if (comboBoxProgressNotifs.Items.Count > 0) { comboBoxProgressNotifs.SelectedIndex = 0; } refreshRoutesList(); if (!string.IsNullOrEmpty(core.routeName) && comboBoxRoute.Items.Contains(core.routeName)) { comboBoxRoute.SelectedItem = core.routeName; } else { comboBoxRoute.SelectedItem = "NONE"; } }
public static void WriteMainQuestLua(string dir, CoreDetails coreDetails, DetailManager[] managers) { string LuaScriptPath = $@"{dir}/Assets/tpp/pack/mission2/quest/ih/{coreDetails.FpkName}_fpkd/Assets/tpp/level/mission2/quest/ih"; string LuaScriptFile = Path.Combine(LuaScriptPath, coreDetails.FpkName + ".lua"); Directory.CreateDirectory(LuaScriptPath); File.WriteAllText(LuaScriptFile, BuildMain(coreDetails, managers)); }
public override void SetDetailsFromSetup(Detail detail, CoreDetails core) { // Routes RouteManager router = new RouteManager(); List <string> uavRoutes = router.GetRouteNames(core.routeName); uavRoutes.AddRange(EnemyInfo.GetCP(core.CPName).CPsoldierRoutes); routes = uavRoutes; base.SetDetailsFromSetup(detail, core); }
public static void WriteDefinitionLua(string dir, CoreDetails coreDetails, DetailManager[] managers) { string DefinitionLuaPath = $@"{dir}/GameDir/mod/quests/"; string DefinitionLuaFile = Path.Combine(DefinitionLuaPath, $"ih_quest_q{coreDetails.QuestNum}.lua"); Directory.CreateDirectory(DefinitionLuaPath); using (StreamWriter defFile = new StreamWriter(DefinitionLuaFile)) { defFile.Write(BuildDefinition(coreDetails, managers)); } }
private static string BuildMain(CoreDetails coreDetails, DetailManager[] managers) { MainLua mainLua = new MainLua(); mainLua.AddToOpeningVariables("this", "{}"); mainLua.AddToOpeningVariables("quest_step", "{}"); mainLua.AddToOpeningVariables("StrCode32", "Fox.StrCode32"); mainLua.AddToOpeningVariables("StrCode32Table", "Tpp.StrCode32Table"); mainLua.AddToOpeningVariables("GetGameObjectId", "GameObject.GetGameObjectId"); mainLua.AddToOpeningVariables("ELIMINATE", "TppDefine.QUEST_TYPE.ELIMINATE"); mainLua.AddToOpeningVariables("RECOVERED", "TppDefine.QUEST_TYPE.RECOVERED"); mainLua.AddToOpeningVariables("KILLREQUIRED", "9"); string cpNameString = coreDetails.CPName; if (coreDetails.CPName == "NONE") { /* * if (LoadAreas.isAfgh(coreDetails.locationID)) * { * cpNameString = @"""afgh_plantSouth_ob"""; // empty ob for afgh. doesn't trigger interrogations? * } * else if (LoadAreas.isMafr(coreDetails.locationID)) * { * cpNameString = @"""mafr_factory_cp"""; // empty cp for mafr * } * else * { */ cpNameString = $"InfMain.GetClosestCp{{{coreDetails.coords.xCoord},{coreDetails.coords.yCoord},{coreDetails.coords.zCoord}}}"; //} } else { cpNameString = $@"""{coreDetails.CPName}"""; } mainLua.AddToOpeningVariables("CPNAME", cpNameString); mainLua.AddToOpeningVariables("DISTANTCP", $@"""{QuestObjects.Enemy.EnemyInfo.ChooseDistantCP(coreDetails.CPName, coreDetails.locationID)}"""); mainLua.AddToOpeningVariables("questTrapName", $@"""trap_preDeactiveQuestArea_{coreDetails.loadArea}"""); mainLua.AddToQuestTable("questType = ELIMINATE"); mainLua.AddToQuestTable("soldierSubType = SUBTYPE"); mainLua.AddToQuestTable(BuildCpList(coreDetails)); foreach (DetailManager manager in managers) { manager.AddToMainLua(mainLua); } return(mainLua.GetMainLuaFormatted()); }
public void RefreshPanel(CoreDetails core) { if (detail.GetQuestObjects().Count > 0) { detailVisualizer.ShowDetail(); } else { detailVisualizer.HideDetail(); } detailVisualizer.VisualizeDetail(detail); }
internal static void BuildAssets(string dir, CoreDetails coreDetails, DetailManager[] managers) { FileAssets fileAssets = new FileAssets(dir, coreDetails.FpkName); RouteAssets.BuildRouteAssets(coreDetails.routeName, fileAssets); foreach (DetailManager manager in managers) { manager.AddToAssets(fileAssets); } fileAssets.SendAssets(); }
public override void SetDetailsFromSetup(Detail detail, CoreDetails core) { base.SetDetailsFromSetup(detail, core); if (LoadAreas.isMtbs(core.locationID)) { bodyNames = NPCBodyInfo.BodyInfoArray.Where(bodyEntry => bodyEntry.hasface).Select(BodyEntry => BodyEntry.Name).ToArray(); } else { bodyNames = NPCBodyInfo.BodyInfoArray.Select(bodyEntry => bodyEntry.Name).ToArray(); } cpName = core.CPName; }
public override void SetDetailsFromSetup(Detail detail, CoreDetails core) { // Routes RouteManager router = new RouteManager(); List <string> eneRoutes = router.GetRouteNames(core.routeName); eneRoutes.AddRange(EnemyInfo.GetCP(core.CPName).CPsoldierRoutes); routes = eneRoutes; // Bodies List <string> eneBodies = NPCBodyInfo.GetRegionBodies(core.locationID).ToList(); bodies = eneBodies; // SubTypes List <string> eneSubTypes = NPCBodyInfo.GetRegionSubTypes(core.locationID).ToList(); subtypes = eneSubTypes; // Add/remove/modify detail soldiers string[] soldiers = new string[0]; if (core.CPName != "NONE" || core.routeName != "NONE") { soldiers = EnemyInfo.GetQuestSoldierNames(core.CPName, core.locationID); } List <Enemy> qObjects = detail.GetQuestObjects().Cast <Enemy>().ToList(); int soldierCount = soldiers.Length; int objectCount = qObjects.Count; for (int i = 0; i < soldierCount; i++) { if (i >= objectCount) // add { qObjects.Add(new Enemy(soldiers[i])); } else // modify { qObjects[i].name = soldiers[i]; } } for (int i = objectCount - 1; i >= soldierCount; i--) //remove { qObjects.RemoveAt(i); } detail.SetQuestObjects(qObjects.Cast <QuestObject>().ToList()); EnemyBox.ResetFovaCounts(); }
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); var rxtLogger = new RxtLogger(); var config = new RxtSettings(); var telemLogger = TelemetryAccessor.Create(rxtLogger, config.TelemetryKey); Logger = new RxtLoggerWithTelemtry(rxtLogger, telemLogger); try { // Set the ServiceProvider of CodeParserBase as it's needed to get settings CodeParserBase.ServiceProvider = this; Logger.RecordInfo(StringRes.Info_ProblemsInstructionsAndLink); Logger.RecordInfo(StringRes.Info_IntializingCommands.WithParams(CoreDetails.GetVersion())); await CreateViewCommand.InitializeAsync(this, Logger); await CopyToClipboardCommand.InitializeAsync(this, Logger); await SendToToolboxCommand.InitializeAsync(this, Logger); await OpenOptionsCommand.InitializeAsync(this, Logger); await SetDatacontextCommand.InitializeAsync(this, Logger); await MoveAllHardCodedStringsToResourceFileCommand.InitializeAsync(this, Logger); await RapidXamlDropHandlerProvider.InitializeAsync(this, Logger); await this.SetUpRunningDocumentTableEventsAsync(cancellationToken); RapidXamlDocumentCache.Initialize(this); } catch (Exception exc) { Logger.RecordException(exc); throw; // Remove for launch. see issue #90 } }
private void Save() { CoreDetails core = setupPage.GetCoreDetails(); SaveFileDialog saveFile = new SaveFileDialog(); saveFile.Filter = "Xml File|*.xml"; saveFile.FileName = core.FpkName; DialogResult saveResult = saveFile.ShowDialog(); if (saveResult != DialogResult.OK) { return; } if (pageNum != 0) { pageNum = 0; GoToPanel(); } Quest quest = new Quest(core, managerMaster.GetQuestObjectDetails()); quest.Save(saveFile.FileName); }
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); var rxtLogger = new RxtLogger(); var telemKey = string.Empty; var telemLogger = TelemetryAccessor.Create(rxtLogger, telemKey); Logger = new RxtLoggerWithTelemtry(rxtLogger, telemLogger); try { // Set the ServiceProvider of AnalyzerBase as it's needed to get settings AnalyzerBase.ServiceProvider = this; Logger.RecordInfo(StringRes.Info_IntializingCommands.WithParams(CoreDetails.GetVersion())); await CreateViewCommand.InitializeAsync(this, Logger); await CopyToClipboardCommand.InitializeAsync(this, Logger); await SendToToolboxCommand.InitializeAsync(this, Logger); await OpenOptionsCommand.InitializeAsync(this, Logger); await SetDatacontextCommand.InitializeAsync(this, Logger); await InsertGridRowDefinitionCommand.InitializeAsync(this, Logger); await RapidXamlDropHandlerProvider.InitializeAsync(this, Logger); } catch (Exception exc) { Logger.RecordException(exc); throw; // Remove for launch. see issue #90 } }
internal static bool Build(params Quest[] quests) { string buildDir; if (quests.Length > 1) { buildDir = BATCHBUILDDIR; ClearBatchFolder(); } else { buildDir = SINGLEBUILDDIR; } Lang.LangBuilder.WriteQuestLangs(buildDir, quests.Select(singleQuest => singleQuest.coreDetails).ToArray()); foreach (Quest quest in quests) { CoreDetails coreDetails = quest.coreDetails; DetailManager[] managers = new ManagerArray(quest.questObjectDetails).GetManagers(); ClearQuestFolders(buildDir, coreDetails.FpkName); Lua.LuaBuilder.WriteDefinitionLua(buildDir, coreDetails, managers); Lua.LuaBuilder.WriteMainQuestLua(buildDir, coreDetails, managers); Fox2.Fox2Builder.WriteQuestFox2(buildDir, coreDetails.FpkName, managers); Assets.AssetsBuilder.BuildAssets(buildDir, coreDetails, managers); } /* * steps to building a quest: * 1. Clear possible existing fpk directories * 2. Write lang files (preferably all custom quest langs would be stored in a single file) * 3. write definition lua * 4. write main quest lua * 5. write fox2 file * 6. Add necessary asset files */ return(true); }
private static string BuildCpList(CoreDetails coreDetails) { StringBuilder cpListBuilder = new StringBuilder("cpList = {"); //if (coreDetails.CPName != "NONE") cpListBuilder.Append(@" nil");/* * else * { * cpListBuilder.Append($@" * {{ * cpName = ""quest_cp"", * cpPosition_x = {coreDetails.coords.xCoord}, cpPosition_y = {coreDetails.coords.yCoord}, cpPosition_z = {coreDetails.coords.zCoord}, cpPosition_r = {70}, * isOuterBaseCp = true, * gtName = ""gt_quest_0000"", * gtPosition_x = {coreDetails.coords.xCoord}, gtPosition_y = {coreDetails.coords.yCoord}, gtPosition_z = {coreDetails.coords.zCoord}, gtPosition_r = {70}, * }},"); * }*/ cpListBuilder.Append(@" }"); return(cpListBuilder.ToString()); }
#pragma warning disable CS0628 // New protected member declared in sealed class protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) #pragma warning restore CS0628 // New protected member declared in sealed class { // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); try { await SharedRapidXamlPackage.InitializeAsync(cancellationToken, this); SharedRapidXamlPackage.Logger.RecordNotice(StringRes.Info_LaunchVersionGeneration.WithParams(CoreDetails.GetVersion())); SharedRapidXamlPackage.Logger.RecordNotice(string.Empty); await CopyToClipboardCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger); await SendToToolboxCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger); await OpenOptionsCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger); await RapidXamlDropHandlerProvider.InitializeAsync(this, SharedRapidXamlPackage.Logger); // Set the ServiceProvider of CodeParserBase as it's needed to get settings CodeParserBase.ServiceProvider = this; if (SharedRapidXamlPackage.Logger != null) { SharedRapidXamlPackage.Logger.UseExtendedLogging = CodeParserBase.GetSettings().ExtendedOutputEnabled; } var ass = Assembly.GetExecutingAssembly().GetName(); SharedRapidXamlPackage.Logger.RecordFeatureUsage(StringRes.Info_PackageLoad.WithParams(ass.Name, ass.Version), quiet: true); } catch (Exception exc) { SharedRapidXamlPackage.Logger?.RecordException(exc); } }
#pragma warning disable CS0628 // New protected member declared in sealed class protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) #pragma warning restore CS0628 // New protected member declared in sealed class { // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); try { await SharedRapidXamlPackage.InitializeAsync(cancellationToken, this); SharedRapidXamlPackage.Logger?.RecordNotice(StringRes.Info_LaunchVersionAnalysis.WithParams(CoreDetails.GetVersion())); SharedRapidXamlPackage.Logger?.RecordNotice(string.Empty); await FeedbackCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger); await MoveAllHardCodedStringsToResourceFileCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger); await AnalyzeCurrentDocumentCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger); await OpenAnalysisOptionsCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger); await this.SetUpRunningDocumentTableEventsAsync(cancellationToken); RapidXamlDocumentCache.Initialize(this, SharedRapidXamlPackage.Logger); Microsoft.VisualStudio.Shell.Events.SolutionEvents.OnAfterCloseSolution += this.HandleCloseSolution; // Handle the ability to resolve assemblies when loading custom analyzers. // Hat-tip: https://weblog.west-wind.com/posts/2016/dec/12/loading-net-assemblies-out-of-seperate-folders AppDomain.CurrentDomain.AssemblyResolve += (object sender, ResolveEventArgs args) => { // Ignore missing resources if (args.Name.Contains(".resources")) { return(null); } if (args.RequestingAssembly == null) { return(null); } // check for assemblies already loaded var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.FullName == args.Name); if (assembly != null) { return(assembly); } // Try to load by filename - split out the filename of the full assembly name // and append the base path of the original assembly (ie. look in the same dir) string filename = args.Name.Split(',')[0] + ".dll".ToLower(); var asmFile = Path.Combine(Path.GetDirectoryName(args.RequestingAssembly.CodeBase), filename); if (asmFile.StartsWith("file:\\")) { asmFile = asmFile.Substring(6); } try { return(Assembly.LoadFrom(asmFile)); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); return(null); } }; // Track this so don't try and load CustomAnalyzers while VS is still starting up. RapidXamlAnalysisPackage.IsLoaded = true; RapidXamlAnalysisPackage.Options = (AnalysisOptionsGrid)this.GetDialogPage(typeof(AnalysisOptionsGrid)); var ass = Assembly.GetExecutingAssembly().GetName(); SharedRapidXamlPackage.Logger?.RecordFeatureUsage(StringRes.Info_PackageLoad.WithParams(ass.Name, ass.Version), quiet: true); } catch (Exception exc) { SharedRapidXamlPackage.Logger?.RecordException(exc); } }
#pragma warning disable CS0628 // New protected member declared in sealed class protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) #pragma warning restore CS0628 // New protected member declared in sealed class { // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); try { await SharedRapidXamlPackage.InitializeAsync(cancellationToken, this); SharedRapidXamlPackage.Logger?.RecordNotice(StringRes.Info_LaunchVersionAnalysis.WithParams(CoreDetails.GetVersion())); SharedRapidXamlPackage.Logger?.RecordNotice(string.Empty); await FeedbackCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger); await MoveAllHardCodedStringsToResourceFileCommand.InitializeAsync(this, SharedRapidXamlPackage.Logger); await this.SetUpRunningDocumentTableEventsAsync(cancellationToken); RapidXamlDocumentCache.Initialize(this, SharedRapidXamlPackage.Logger); Microsoft.VisualStudio.Shell.Events.SolutionEvents.OnAfterCloseSolution += this.HandleCloseSolution; } catch (Exception exc) { SharedRapidXamlPackage.Logger?.RecordException(exc); } }
public abstract void UpdateDetailFromSetup(CoreDetails core);
public override void UpdateDetailFromSetup(CoreDetails core) { detailVisualizer.SetDetailsFromSetup(detail, core); }
public abstract void SetDetailsFromSetup(Detail detail, CoreDetails core);
public void RefreshObjectPanels(CoreDetails core) { managerMaster.RefreshAllPanels(core); }
#pragma warning disable CS0628 // New protected member declared in sealed class protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) #pragma warning restore CS0628 // New protected member declared in sealed class { // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); try { await SharedRapidXamlPackage.InitializeAsync(cancellationToken, this); SharedRapidXamlPackage.Logger?.RecordNotice(StringRes.Info_LaunchVersionRoslynAnalyzers.WithParams(CoreDetails.GetVersion())); SharedRapidXamlPackage.Logger?.RecordNotice(string.Empty); var ass = Assembly.GetExecutingAssembly().GetName(); SharedRapidXamlPackage.Logger?.RecordFeatureUsage(StringRes.Info_PackageLoad.WithParams(ass.Name, ass.Version), quiet: true); } catch (Exception exc) { SharedRapidXamlPackage.Logger?.RecordException(exc); } }