async void ExecuteCommandNameShrineMenuNavi(string option) { switch (option) { case ItemTypes.ALL: await StateManager?.GoToState(MenuStates.Hide); UpdateItem(ItemTypes.ALL); CurrentOption = CurrentOption.ALL; break; case ItemTypes.ACCESSORIES: await StateManager?.GoToState(MenuStates.Hide); UpdateItem(ItemTypes.ACCESSORIES); CurrentOption = CurrentOption.ACCESSORIES; break; case ItemTypes.CLOTHING: await StateManager?.GoToState(MenuStates.Hide); UpdateItem(ItemTypes.CLOTHING); CurrentOption = CurrentOption.CLOTHING; break; case ItemTypes.HOME: await StateManager?.GoToState(MenuStates.Hide); UpdateItem(ItemTypes.HOME); CurrentOption = CurrentOption.HOME; break; } }
private void unFocusCurrentOption() { if (m_CurrentOptionIndex >= 0 && m_CurrentOptionIndex < r_Options.Count) { if (CurrentOption.IsFocused) { CurrentOption.UnFocus(); } } }
public ShrineMenuPageViewModel(INavigationService navigationService) : base(navigationService) { _navigationService = navigationService; Title = "MENU"; _currentOption = CurrentOption.ALL; StateManager.Group <MenuStates>().DefineAllStates(); StateManager.GoToState(MenuStates.Show); }
/// <summary> /// 保存 /// </summary> public void Save() { SaveFileDialog dialog = new SaveFileDialog(); dialog.Title = "保存生成的脚本"; dialog.DefaultExt = ".cs"; dialog.Filter = "C#文件|*.cs"; dialog.AddExtension = true; dialog.FileName = CurrentOption + ".cs"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var path = dialog.FileName; var sourcepath = Path.Combine(OutputPath, CurrentOption + ".cs"); File.Copy(sourcepath, path, true); var finfo = new FileInfo(path); var dpath = finfo.Directory.FullName; var oppath = Path.Combine(dpath, CurrentOption.Replace("Message", "Opcode") + ".cs"); File.WriteAllText(oppath, OpcodeText.Text); System.Diagnostics.Process.Start("Explorer.exe", dpath); Log("保存生成脚本完成"); } }
private void computeThis() { CurrentOption.Compute(); }
public static bool SelectOption(Character character) { ConsoleKey key = Console.ReadKey(true).Key; while (key != ConsoleKey.Escape) { switch (key) { case ConsoleKey.DownArrow: case ConsoleKey.S: { RemoveHighlight(CurrentOption); CurrentOption = (ImproveStatsOption)((int)(CurrentOption + 1) % NumberOfOptions); HighlightOption(CurrentOption, character); } break; case ConsoleKey.UpArrow: case ConsoleKey.W: { RemoveHighlight(CurrentOption); CurrentOption = CurrentOption - 1 < 0 ? ImproveStatsOption.Back : (ImproveStatsOption)(CurrentOption - 1); HighlightOption(CurrentOption, character); } break; case ConsoleKey.Enter: { var ctx = new ConsoleWorldContext(); if (character.Points <= 0 && CurrentOption.ToString() != "Back") { Console.SetCursorPosition(40, 5); Console.WriteLine("You don't have enough points for that!"); key = Console.ReadKey(true).Key; continue; } switch (CurrentOption.ToString()) { case "MaxHp": character.MaxHp += 1; character.Points--; DrawStats(character, "MaxHp"); break; case "MaxMp": character.MaxMp += 1; character.Points--; DrawStats(character, "MaxMp"); break; case "Attack": character.Attack += 1; character.Points--; DrawStats(character, "Attack"); break; case "MagicAttack": character.MagicAttack += 1; character.Points--; DrawStats(character, "MagicAttack"); break; case "Defense": character.Defense += 1; character.Points--; DrawStats(character, "Defense"); break; case "MagicDefense": character.MagicDefense += 1; character.Points--; DrawStats(character, "MagicDefense"); break; case "Accuracy": character.Accuracy += 1; character.Points--; DrawStats(character, "Accuracy"); break; case "Evade": character.Evade += 1; character.Points--; DrawStats(character, "Evaded"); break; case "Back": return(true); } ctx.SaveChanges(); } break; } Console.SetCursorPosition(40, 5); Console.WriteLine(new string(' ', "You don't have enough points for that!".Length)); key = Console.ReadKey(true).Key; } return(false); }
/// <summary> /// 生成Opcode /// </summary> public void GenerateOpcode() { var Index = 0; var NameSpace = "Secode.Network"; var OpcodeClass = CurrentOption.Replace("Message", "Opcode"); var lines = File.ReadAllLines(Path.Combine(SourcesPath, CurrentOption + ".proto")); #region Get Index foreach (var line in lines) { var temp = line.Replace("/", "").Replace(" ", ""); if (temp.Length > 0 && Regex.IsMatch(temp, @"^\d*$")) { Index = int.Parse(temp); break; } } #endregion #region Get NameSpace var NameSpaceRegex = new Regex("package (.*?);"); foreach (var line in lines) { MatchCollection mc = NameSpaceRegex.Matches(line); if (mc != null && mc.Count > 0) { NameSpace = mc[0].Groups[1].Value; break; } } #endregion #region Append Message Start OpcodeText.Text = ""; OpcodeText.AppendText("namespace " + NameSpace); OpcodeText.AppendText(Environment.NewLine); OpcodeText.AppendText("{"); OpcodeText.AppendText(Environment.NewLine); #endregion #region Append Message Content var MessageRegex = new Regex(@"^message\s+(.*?)\s*//\s*(.*?)$"); var MessageRegex2 = new Regex(@"^message\s+(.*?)\s*$"); foreach (var line in lines) { MatchCollection mc = MessageRegex.Matches(line); if (mc == null || mc.Count == 0) { mc = MessageRegex2.Matches(line); } if (mc == null || mc.Count == 0) { continue; } var msgclass = mc[0].Groups[1].Value; var typeclass = mc[0].Groups[2].Value; OpcodeText.AppendText(" [Message(" + OpcodeClass + "." + msgclass + ")]"); OpcodeText.AppendText(Environment.NewLine); if (!string.IsNullOrWhiteSpace(typeclass)) { OpcodeText.AppendText(" public partial class " + msgclass + " : " + typeclass + " { }"); } else { OpcodeText.AppendText(" public partial class " + msgclass + " { }"); } OpcodeText.AppendText(Environment.NewLine); OpcodeText.AppendText(Environment.NewLine); } #endregion #region Append Message End OpcodeText.AppendText("}"); OpcodeText.AppendText(Environment.NewLine); #endregion #region Append Opcode Start OpcodeText.AppendText("namespace " + NameSpace); OpcodeText.AppendText(Environment.NewLine); OpcodeText.AppendText("{"); OpcodeText.AppendText(Environment.NewLine); OpcodeText.AppendText(" public static partial class " + OpcodeClass); OpcodeText.AppendText(Environment.NewLine); OpcodeText.AppendText(" {"); OpcodeText.AppendText(Environment.NewLine); #endregion #region Append Opcode Content foreach (var line in lines) { MatchCollection mc = MessageRegex.Matches(line); if (mc == null || mc.Count == 0) { mc = MessageRegex2.Matches(line); } if (mc == null || mc.Count == 0) { continue; } var msgclass = mc[0].Groups[1].Value; Index += 1; OpcodeText.AppendText(" public const ushort " + msgclass + " = " + Index + ";"); OpcodeText.AppendText(Environment.NewLine); } #endregion #region Append Opcode End OpcodeText.AppendText(" }"); OpcodeText.AppendText(Environment.NewLine); OpcodeText.AppendText("}"); OpcodeText.AppendText(Environment.NewLine); #endregion }