public static string[] BuildCmdLine(PanelItemBase panelItem, AddonMenuItem menuItem) { var programFileName = menuItem.ProgramValue.ExpandedFileName; var programArgs = AddonProgram.ExpandCmdLine(menuItem.ProgramArgs); programArgs = MacroHelper.ExpandPublicProperties(programArgs, panelItem); return(ProtocolHelper.IsProtocol(menuItem.ProgramRef.Id) ? new[] { menuItem.ProgramRef.Id + programArgs } : new[] { programFileName, programArgs }); }
public override string Name() { // Used for greeting messages only: 7215, 7216, 7217 if (!string.IsNullOrEmpty(GameManager.Instance.TalkManager.GreetingNameNPC)) { return(GameManager.Instance.TalkManager.GreetingNameNPC); } return(MacroHelper.GetRandomFullName()); }
public static CSharpCompilation Run( CSharpCompilation compilation, ImmutableArray <SyntaxTree> trees, Dictionary <string, SyntaxTree> sourceMap, List <Diagnostic> diagnostic, GenerationSettings settings, List <CodeGeneration.GeneratedCsFile> generatedFiles, Action <string>?logTime = null ) { // return compilation; var referencedAssemblies = compilation.Assembly.GetReferencedAssembliesAndSelf(); var maybeMacrosAssembly = referencedAssemblies.FirstOrDefault(_ => _.Name == "Macros"); if (maybeMacrosAssembly == null) // skip this step if macros dll is not referenced { return(compilation); } var macrosAssembly = maybeMacrosAssembly; // GetTypeByMetadataName searches in assembly and its direct references only var macrosClass = macrosAssembly.GetTypeByMetadataName(typeof(Macros).FullName !); if (macrosClass == null) { diagnostic.Add(Diagnostic.Create(new DiagnosticDescriptor( "ER0003", "Error", "Macros.dll assembly must be referenced directly.", "Error", DiagnosticSeverity.Error, true ), compilation.Assembly.Locations[0])); return(compilation); } // var ss = Stopwatch.StartNew(); // compilation.Emit(new MemoryStream()); // Console.Out.WriteLine("ss " + ss.Elapsed); var helper = new MacroHelper(macrosAssembly, diagnostic, referencedAssemblies, trees, compilation); var simpleMethodMacroType = helper.getTypeSymbol <SimpleMethodMacro>(); var statementMethodMacroType = helper.getTypeSymbol <StatementMethodMacro>(); var varMethodMacroType = helper.getTypeSymbol <VarMethodMacro>(); #pragma warning disable 618 var inlineType = helper.getTypeSymbol <Inline>(); #pragma warning restore 618 var lazyPropertyType = helper.getTypeSymbol <LazyProperty>(); logTime?.Invoke("a1"); ISymbol macroSymbol(string name) => macrosClass.GetMembers(name).First(); helper.builderInvocations.Add( macroSymbol(nameof(Macros.className)), (ctx, op) => { var enclosingSymbol = ctx.Model.GetEnclosingSymbol(op.Syntax.SpanStart); ctx.ChangedNodes.Add(op.Syntax, enclosingSymbol !.ContainingType.ToDisplayString().StringLiteral()); });
private void PlayerGPS_OnEnterLocationRect(DFLocation dfLocation) { if (!string.IsNullOrEmpty(DestinationName) && locationPause == LocPauseEnter) { if (travelControlUI.isShowing) { travelControlUI.CloseWindow(); } DaggerfallUI.MessageBox(string.Format(MsgEnterLocation, MacroHelper.LocationTypeName(), dfLocation.Name)); } }
public override string GuildTitle() { if (parent.guild != null) { return(parent.guild.GetTitle()); } else { return(MacroHelper.GetFirstname(GameManager.Instance.PlayerEntity.Name)); } }
protected override void Setup() { if (IsSetup) { return; } // Initialise the video panel. playerPanel = new FLCPlayer() { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Middle, Size = new Vector2(320, 200), BottomMargin = 13 }; NativePanel.Components.Add(playerPanel); // Start video playing. playerPanel.Load(daedraSummoned.vidFile); if (playerPanel.FLCFile.ReadyToPlay) { playerPanel.Start(); } // Add text message area. messageLabel = new MultiFormatTextLabel() { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Bottom, ExtraLeading = 3, }; playerPanel.Components.Add(messageLabel); playerPanel.OnMouseClick += PlayerPanel_OnMouseClick; textCursor = new TextCursor(); textCursor.Enabled = false; playerPanel.Components.Add(textCursor); // Initialise message to display, if (daedraQuest != null) { // with the quest offer message. Message message = daedraQuest.GetMessage((int)QuestMachine.QuestMessages.QuestorOffer); messageTokens = message.GetTextTokens(); } else { // with the textId message evaluated with mcp provided. messageTokens = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(textId); MacroHelper.ExpandMacros(ref messageTokens, mcp); } idx = 0; DisplayNextTextChunk(); }
public void SetTextTokens(TextFile.Token[] tokens, IMacroContextProvider mcp = null, bool expandMacros = true) { if (!IsSetup) { Setup(); } if (expandMacros) { MacroHelper.ExpandMacros(ref tokens, mcp); } label.SetText(tokens); UpdatePanelSizes(); }
protected override object PollDecompiler(List <ReadMacroResultItemModel> res, DecompReadMacroItemModel deModel) { double data = 0; var ret_dec = new MacroHelper().DecompilerReadMacroInfo(datas, deModel, ref data); if (string.IsNullOrEmpty(ret_dec)) { res.Add(new ReadMacroResultItemModel() { Id = deModel.Id, Value = data }); } return(ret_dec); }
private string ReadMacroHandle(ref ushort flib, string para) { string message = null; var paraModel = JsonConvert.DeserializeObject <ReadMacroModel>(para); var res = new List <ReadMacroResultItemModel>(); foreach (var item in paraModel.Readers) { var datas = new double[item.Quantity]; var ret = new MacroHelper().ReadMacroRange(flib, item.StartNum, item.Quantity, ref datas); if (ret.Item1 == -16) { var ret_conn = ConnectHelper.BuildConnect(ref flib, m_ip, m_port, m_timeout); if (ret_conn == 0) { ret = new MacroHelper().ReadMacroRange(flib, item.StartNum, item.Quantity, ref datas); } } } //foreach (var item in paraModel.Decompilers) //{ // double[] data = ; // var ret_dec = MacroHelper.DecompilerReadMacroInfo(datas, item, ref data); // if (ret_dec != null) // { // message = ret_dec; // } // else // { // res.Add(new ReadMacroResultItemModel() // { // Id = item.Id, // Value = data // }); // } //} GetResultEvent?.Invoke(new BaseCNCResultModel <ReadMacroResultItemModel>() { Value = res, Id = "" }); return(message); }
string LocationTypeString() { switch (GameManager.Instance.PlayerGPS.CurrentLocationType) { case DFRegion.LocationTypes.DungeonKeep: return("Keep"); case DFRegion.LocationTypes.DungeonLabyrinth: return("Labyrinth"); case DFRegion.LocationTypes.DungeonRuin: return("Ruin"); default: return(MacroHelper.LocationTypeName()); } }
private void InternalStart() { var cmdLine = BuildCmdLine(m_PanelItem, m_MenuItem); try { ProcessStartInfo startInfo; switch (cmdLine.Length) { case 1: startInfo = new ProcessStartInfo(cmdLine[0]); break; case 2: startInfo = new ProcessStartInfo(cmdLine[0], cmdLine[1]); break; default: return; } if (!string.IsNullOrEmpty(m_MenuItem.WorkingDirectory)) { var path = MacroHelper.ExpandPublicProperties(m_MenuItem.WorkingDirectory, m_PanelItem); // get parent directory if file was selected if (File.Exists(path)) { path = Path.GetDirectoryName(path); } if (!string.IsNullOrEmpty(path) && Directory.Exists(path)) { startInfo.WorkingDirectory = path; } } Process.Start(startInfo); } catch (Exception ex) { MessageBoxHelper.ShowRunCmdError(string.Format(CultureInfo.InvariantCulture, "{0}\n{1}", string.Join(" ", cmdLine), ex.Message)); } }
protected override Tuple <short, string> PollRead(ReadMacroTypeModel inputModel) { var qty = inputModel.EndNum - inputModel.StartNum + 1; var temp_data = new double[qty]; var ret = new MacroHelper().ReadMacroRange(flib, inputModel.StartNum, qty, ref temp_data); if (ret.Item1 == 0) { if (datas.ContainsKey(inputModel.Type)) { datas[inputModel.Type] = temp_data; } else { datas.Add(inputModel.Type, temp_data); } } return(ret); }
private void RandomNameButton_OnMouseClick(BaseScreenComponent sender, Vector2 position) { // Generate name based on race NameHelper.BankTypes bankType = MacroHelper.GetNameBank((Races)raceTemplate.ID); textBox.Text = nameHelper.FullName(bankType, gender); }
public void SetTextTokens(TextFile.Token[] tokens, IMacroContextProvider mcp = null) { MacroHelper.ExpandMacros(ref tokens, mcp); multiLineLabel.SetText(tokens); }
public override string GuildTitle() { return(MacroHelper.GetFirstname(GameManager.Instance.PlayerEntity.Name)); }
private string expandRandomTextRecord(int recordIndex) { TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(recordIndex); MacroHelper.ExpandMacros(ref tokens); return(tokens[0].text); }
void Update() { if (uiCloseWhenTop && DaggerfallUI.UIManager.TopWindow == travelControlUI) { uiCloseWhenTop = false; travelControlUI.CloseWindow(); } if (playerAutopilot != null) { // Ensure only the travel UI is showing, stop travel if not, but allow registered window and travel map to not halt travel. if (GameManager.Instance.IsPlayerOnHUD || (DaggerfallUI.UIManager.TopWindow != travelControlUI && DaggerfallUI.UIManager.TopWindow != noStopForUIWindow && DaggerfallUI.UIManager.TopWindow != DaggerfallUI.Instance.DfTravelMapWindow)) { Debug.Log("Other UI activity detected, stopping travel."); InterruptTravel(); uiCloseWhenTop = travelControlUI.isShowing; return; } // Run updates for playerAutopilot and HUD playerAutopilot.Update(); DaggerfallUI.Instance.DaggerfallHUD.HUDVitals.Update(); if (DestinationName == null && followKeyCode != KeyCode.None && InputManager.Instance.GetKeyDown(followKeyCode)) { if (travelControlUI.isShowing) { travelControlUI.CloseWindow(); } } // If circumnavigating a location, check for path crossings PlayerGPS playerGPS = GameManager.Instance.PlayerGPS; if (circumnavigatePathsDataPt != 0) { byte crossed = IsPlayerOnPath(playerGPS, circumnavigatePathsDataPt); if (crossed != 0 && crossed != lastCrossed) { lastCrossed = crossed; if (travelControlUI.isShowing) { travelControlUI.CloseWindow(); } return; } lastCrossed = crossed; } // If travelling cautiously, check health and fatigue levels if (DestinationCautious) { if (GameManager.Instance.PlayerEntity.CurrentHealthPercent * 100 < CautiousHealthMinPc) { StopTravelWithMessage(MsgLowHealth); return; } if (GameManager.Instance.PlayerEntity.CurrentFatigue < DaggerfallEntity.FatigueMultiplier * CautiousFatigueMin) { StopTravelWithMessage(MsgLowFatigue); return; } } // If location pause set to nearby and travelling to destination, check for a nearby location and stop if found if (locationPause == LocPauseNear && DestinationName != null && playerGPS.HasCurrentLocation && !playerGPS.CurrentLocation.Equals(lastLocation)) { lastLocation = playerGPS.CurrentLocation; StopTravelWithMessage(string.Format(MsgNearLocation, MacroHelper.LocationTypeName(), playerGPS.CurrentLocation.Name)); return; } // Check for ocean climate. if (playerGPS.CurrentClimateIndex == (int)MapsFile.Climates.Ocean) { StopTravelWithMessage(MsgOcean); return; } // Handle encounters. if (ignoreEncounters && Time.unscaledTime >= ignoreEncountersTime) { ignoreEncounters = false; } if (!ignoreEncounters && GameManager.Instance.AreEnemiesNearby()) { // This happens when DFU spawns enemies nearby, however quest trigger encounters fire the OnEncounter event first so this code is never reached. Debug.Log("Enountered enemies during travel."); travelControlUI.CloseWindow(); if (DestinationCautious) { AttemptAvoidEncounter(); } else { DaggerfallUI.MessageBox(MsgEnemies); } return; } // Check for diseases. var currentDiseaseCount = GameManager.Instance.PlayerEffectManager.DiseaseCount; if (currentDiseaseCount != diseaseCount) { if (currentDiseaseCount > diseaseCount) { Debug.Log("New disease detected, interrupting travel!"); InterruptTravel(); DaggerfallUI.Instance.CreateHealthStatusBox(DaggerfallUI.Instance.UserInterfaceManager.TopWindow).Show(); } diseaseCount = currentDiseaseCount; } } else if (followKeyCode != KeyCode.None && InputManager.Instance.GetKeyDown(followKeyCode) && GameManager.Instance.IsPlayerOnHUD) { if (GameManager.Instance.AreEnemiesNearby()) { DaggerfallUI.MessageBox(TextManager.Instance.GetLocalizedText("cannotTravelWithEnemiesNearby")); } else { FollowPath(); } } }
private static List <TextFile.Token> CreateNote() { List <TextFile.Token> note = new List <TextFile.Token>(); note.Add(new TextFile.Token() { text = string.Format(TextManager.Instance.GetText(textDatabase, "noteHeader"), DaggerfallUnity.Instance.WorldTime.Now.DateTimeString(), MacroHelper.CityName(null)), formatting = TextFile.Formatting.TextHighlight, }); note.Add(NothingToken); return(note); }
public List <string> GenerateBackstory(int classIndex) { const int tokensStart = 4116; #region Parse answer tokens List <int>[] tokenLists = new List <int> [questionCount * 2]; tokenLists[0] = Q1Tokens; tokenLists[1] = Q2Tokens; tokenLists[2] = Q3Tokens; tokenLists[3] = Q4Tokens; tokenLists[4] = Q5Tokens; tokenLists[5] = Q6Tokens; tokenLists[6] = Q7Tokens; tokenLists[7] = Q8Tokens; tokenLists[8] = Q9Tokens; tokenLists[9] = Q10Tokens; tokenLists[10] = Q11Tokens; tokenLists[11] = Q12Tokens; // Setup tokens for macro handler foreach (string effect in answerEffects) { char prefix = effect[0]; if (prefix == '#' || prefix == '!' || prefix == '?') { int questionInd; string[] effectSplit = effect.Split(' '); string command = effectSplit[0]; string index = effectSplit[1]; if (!int.TryParse(index, out questionInd)) { Debug.LogError("GenerateBackstory: Invalid question index."); continue; } string[] splitStr = command.Split(prefix); if (splitStr.Length > 1) { tokenLists[questionInd].Add(int.Parse(splitStr[1])); } } } #endregion TextFile.Token lastToken = new TextFile.Token(); GameManager.Instance.PlayerEntity.BirthRaceTemplate = characterDocument.raceTemplate; // Need correct race set when parsing %ra macro List <string> backStory = new List <string>(); TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(tokensStart + classIndex); MacroHelper.ExpandMacros(ref tokens, (IMacroContextProvider)this); foreach (TextFile.Token token in tokens) { if (token.formatting == TextFile.Formatting.Text) { backStory.Add(token.text); } else if (token.formatting == TextFile.Formatting.JustifyLeft) { if (lastToken.formatting == TextFile.Formatting.JustifyLeft) { backStory.Add("\n"); } } lastToken = token; } return(backStory); }
//_________________________________________________________________________________________________________ //_________________________________________________________________________________________________________ public static void Init(fFIMSyncTest pf, DataGridView pdg) { mh = new MacroHelper(pf, pdg); Init(); }
void Update() { if (playerAutopilot != null) { // Ensure UI is showing if (!travelControlUI.isShowing) { DaggerfallUI.UIManager.PushWindow(travelControlUI); } // Run updates for playerAutopilot and HUD playerAutopilot.Update(); DaggerfallUI.Instance.DaggerfallHUD.HUDVitals.Update(); // If travelling cautiously, check health and fatigue levels if (DestinationCautious) { if (GameManager.Instance.PlayerEntity.CurrentHealthPercent * 100 < CautiousHealthMinPc) { StopTravelWithMessage(MsgLowHealth); return; } if (GameManager.Instance.PlayerEntity.CurrentFatigue < DaggerfallEntity.FatigueMultiplier * CautiousFatigueMin) { StopTravelWithMessage(MsgLowFatigue); return; } } // If location pause set to nearby, check for a near location PlayerGPS playerGPS = GameManager.Instance.PlayerGPS; if (locationPause == LocPauseNear && playerGPS.HasCurrentLocation && !playerGPS.CurrentLocation.Equals(lastLocation)) { lastLocation = playerGPS.CurrentLocation; StopTravelWithMessage(string.Format(MsgNearLocation, MacroHelper.LocationTypeName(), playerGPS.CurrentLocation.Name)); return; } // Check for ocean climate. if (playerGPS.CurrentClimateIndex == (int)MapsFile.Climates.Ocean) { StopTravelWithMessage(MsgOcean); return; } // Handle encounters. if (ignoreEncounters && Time.unscaledTime >= ignoreEncountersTime) { ignoreEncounters = false; } if (!ignoreEncounters && GameManager.Instance.AreEnemiesNearby()) { // This happens when DFU spawns enemies nearby, however quest trigger encounters fire the OnEncounter event first so this code is never reached. Debug.Log("Enountered enemies during travel."); travelControlUI.CloseWindow(); if (DestinationCautious) { AttemptAvoidEncounter(); } else { DaggerfallUI.MessageBox(MsgEnemies); } return; } // Check for diseases. var currentDiseaseCount = GameManager.Instance.PlayerEffectManager.DiseaseCount; if (currentDiseaseCount != diseaseCount) { if (currentDiseaseCount > diseaseCount) { Debug.Log("New disease detected, interrupting travel!"); InterruptTravel(); DaggerfallUI.Instance.CreateHealthStatusBox(DaggerfallUI.Instance.UserInterfaceManager.TopWindow).Show(); } diseaseCount = currentDiseaseCount; } } }
protected bool ItemPassesFilter(DaggerfallUnityItem item) { bool iterationPass = false; bool isRecipe = false; string recipeName = string.Empty; string str = string.Empty; str = GetSearchTags(item); if (String.IsNullOrEmpty(filterString)) { return(true); } if (item.LongName.ToLower().Contains("recipe")) { TextFile.Token[] tokens = ItemHelper.GetItemInfo(item, DaggerfallUnity.TextProvider); MacroHelper.ExpandMacros(ref tokens, item); recipeName = tokens[0].text; isRecipe = true; } foreach (string word in filterString.Split(' ')) { if (word.Trim().Length > 0) { if (word[0] == '-') { string wordLessFirstChar = word.Remove(0, 1); iterationPass = true; if (item.LongName.IndexOf(wordLessFirstChar, StringComparison.OrdinalIgnoreCase) != -1) { iterationPass = false; } else if (isRecipe && recipeName.IndexOf(wordLessFirstChar, StringComparison.OrdinalIgnoreCase) != -1) { iterationPass = false; } else if (itemGroupNames[(int)item.ItemGroup].IndexOf(wordLessFirstChar, StringComparison.OrdinalIgnoreCase) != -1) { iterationPass = false; } else if (str != null && str.IndexOf(wordLessFirstChar, StringComparison.OrdinalIgnoreCase) != -1) { iterationPass = false; } } else { iterationPass = false; if (item.LongName.IndexOf(word, StringComparison.OrdinalIgnoreCase) != -1) { iterationPass = true; } else if (isRecipe && recipeName.IndexOf(word, StringComparison.OrdinalIgnoreCase) != -1) { iterationPass = true; } else if (itemGroupNames[(int)item.ItemGroup].IndexOf(word, StringComparison.OrdinalIgnoreCase) != -1) { iterationPass = true; } else if (str != null && str.IndexOf(word, StringComparison.OrdinalIgnoreCase) != -1) { iterationPass = true; } } if (!iterationPass) { return(false); } } } return(true); }
public override string MaleName() { // %mn DFRandom.Seed = (uint)parent.GetHashCode() + 9543; NameHelper.BankTypes nameBank = MacroHelper.GetNameBank((Races)parent.characterDocument.raceTemplate.ID); return(DaggerfallUnity.Instance.NameHelper.FullName(nameBank, Genders.Male)); }
public override string Name() { // %n %nam DFRandom.Seed = (uint)parent.UID; return(MacroHelper.GetRandomFullName()); }