Inheritance: MonoBehaviour
 public TemperatureCntrl(Speech.SpeechMain Speaker)
 {
     Spee = Speaker;
     //initialize all grammar objects
     // this.TempGB = new GrammarBuilder();
     // this.TempChoice = new Choices();
     // this.GrammarOptions = new Dictionary<string, string[]>();
     // GrammarOptions.Add("Intro", new string[] { "hal" });
     // this.TempChoice.Add("");
     // this.voiceChoices.Add(GrammarOptions["Intro"]);
     // this.GB.Append(this.voiceChoices);
 }
        /// <summary>
        /// Creates an new instance of the Recognition class.
        /// </summary>
        /// <param name="StatusText"></param>
        /// <param name="Spee"></param>
        public RecognitionMain(TextBox StatusText, Speech.SpeechMain Spee)
        {
            this.StatusTextBox = StatusText;
            this.acknowlegdedSpeaker = false;
            this.Spee = Spee;
            this.SRE = new SpeechRecognitionEngine();
            this.SRE.SetInputToDefaultAudioDevice();
            this.SRE.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(SRE_SpeechRecognized);

            this.GenerateGrammar(VoiceStep.first);
            this.VTemp = new Temperature.TemperatureCntrl(Spee);
        }
Beispiel #3
0
    public void Update()
    {
        if (this.current != null && Time.time > this.endTime) {
            this.current = null;

            this.textObject.text = "";
        }

        if (this.current == null && this.queue.Count > 0) {
            this.current = this.queue.Dequeue();
            this.endTime = this.current.duration + Time.time;

            this.textObject.text = this.current.dialog;
        }
    }
Beispiel #4
0
    // Use this to queue messages to the dialog component.
    public void Queue(Speech speech, bool force = false)
    {
        if (speech.duration < Dialog.MinDuration) {
            speech.duration = Dialog.MinDuration;
        }

        if (force) {
            this.current = null;
            this.endTime = 0f;

            this.queue.Clear();
        }

        this.queue.Enqueue(speech);
    }
    public bool BeforeCreatureSpeech(Creature creature, Speech speech)
    {
        if (creature.IsPlayer && creature.Name.Contains(ManagerNamePrefix))
        {
            Player p = (Player)creature;

            //only the account manager should know what he said...
            p.Connection.SendCreatureSpeech(p, SpeechType.Whisper, speech.Message);
            Parse(p.Connection, managers[p.Connection].State, speech);

            //Account manager's messages can't be visible to everyone for security
            return false;
        }

        return true;
    }
Beispiel #6
0
 public static void Speak(int client, Speech speech, string text)
 {
     switch (speech)
     {
         case Speech.Say:
             Event(client, 1, 0, text);
             break;
         case Speech.Emote:
             Event(client, 2, 0, text);
             break;
         case Speech.Whisper:
             Event(client, 3, 0, text);
             break;
         case Speech.Yell:
             Event(client, 4, 0, text);
             break;
     }
 }
Beispiel #7
0
	protected override void CallOnNode (ref string name, System.Collections.Generic.List<ParserValue> pairs)
	{
		if (name == "Speaches/Speach") {
			speech = Speech.Create (pairs [0].value);
			SpeechArchive.total.Add (speech);
		}
		if (name == "Speaches/Speach/Content") {
			if (pairs.Count <= 2) {
				speech.AddContent (pairs [0].value, pairs [1].value);
			} else {
				speech.AddContent (pairs [0].value, pairs [1].value, pairs [2].value);
			}
		}
		if (name == "Speaches/Speach/ToActive") {
			foreach (ParserValue pair in pairs) {
				speech.toActive.Add (pair.value);
			}
		}
	}
Beispiel #8
0
        public override void processQuery(ref TextBox tb, ref Speech speech)
        {
            speech.talk("Which site?");
            Dictionary<string, string> sites = new Dictionary<string, string>();
            using (StreamReader sr = new StreamReader("sites.txt"))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    sites.Add(line.Split(',')[0], line.Split(',')[1]);
                }
            }

            string addr = speech.recognizeOneWordFromGrammer(sites.Keys.ToArray<string>());

            Process c = new Process();
            c.StartInfo.FileName = "chrome.exe";
            c.StartInfo.Arguments = sites[addr];
            c.Start();
        }
Beispiel #9
0
    void Start()
    {
        m_Speech = GameObject.FindGameObjectWithTag("SpeechUI").GetComponent<Speech>();
        EndConversation();

        StringReader t_Reader = new StringReader(m_DialogFile.text);

        while (true)
        {
            string t_Name = t_Reader.ReadLine();
            if (t_Name == null) break; // no more lines

            int t_Found = m_Characters.IndexOf(t_Name);
            if (t_Found == -1)
            {
                m_Characters.Add(t_Name);
                t_Found = m_Characters.Count - 1;
            }

            UnfoldedDialog.DialogSide t_Side = (t_Found % 2 == 0) ? (UnfoldedDialog.DialogSide.Left) : (UnfoldedDialog.DialogSide.Right);

            string t_Text = t_Reader.ReadLine();
            while (t_Text != null && t_Text != ".END")
            {
                UnfoldedDialog t_Dialog = new UnfoldedDialog();
                t_Dialog.Name = t_Name;
                t_Dialog.Side = t_Side;
                t_Dialog.Line = t_Text;

                m_Dialog.Add(t_Dialog);

                t_Text = t_Reader.ReadLine();
            }

        }
    }
Beispiel #10
0
 public override void processQuery(ref TextBox tb, ref Speech speech)
 {
     speech.talk("Preparing to query Wolfram. What would you like to know?");
     string query = speech.recognizeDictation();
     tb.Text = "Querying Wolfram|Alpha...";
     speech.talk("One moment.");
     try
     {
         string[] result = wolfram.simpleQuery(query);
         tb.Text = result[1];
         speech.talk(result[0].Replace("|", "-"));
     }
     catch (AmbiguousQueryException aqe)
     {
         speech.talk(aqe.Message);
         speech.talk("Please restate your query, optionally using one of the following interpretations.");
         int count = 1;
         foreach (var dym in aqe.DidYouMeans)
         {
             speech.talk(count + ": " + dym.Value);
         }
         processQuery(ref tb, ref speech);
     }
 }
Beispiel #11
0
 public void Send(Speech speech)
 {
     myOutput.Speak(speech);
 }
Beispiel #12
0
 /// <summary>
 /// Initializes a new instance of the PhoneCntrl class.
 /// </summary>
 /// <param name="spee">The speeach generator</param>
 /// <param name="Recog">The voice recognition</param>
 public PhoneCntrl(Speech.SpeechMain spee, Recognition.RecognitionMain Recog)
 {
 }
Beispiel #13
0
    /// <summary>
    /// Loads specyfic dialog from file and save it in list.
    /// </summary>
    /// <returns>
    /// The dialogs.
    /// </returns>
    /// <param name='numberOfDialog'>
    /// Number of dialog.
    /// </param>
    public List<Speech> GetDialogs(int numberOfDialog)
    {
        dialogs.Clear();
        XmlNodeList speechNodeList = xmlDoc.SelectNodes("/quest/dialog"+ numberOfDialog.ToString()+"/speech");
        foreach (XmlNode speechNode in speechNodeList) {
            Speech currentSpeech = new Speech();
            currentSpeech.Speaker = speechNode.Attributes[0].Value;
            currentSpeech.SpeechText = speechNode.InnerXml;
            dialogs.Add(currentSpeech);
        }

        return dialogs;
    }
Beispiel #14
0
 public SpeechPackage(Speech speech,
                      bool isValidSPeech)
 {
     this.speech        = speech;
     this.isValidSPeech = isValidSPeech;
 }
 public Play(Speech s, State next = null)
 {
     this.s    = s;
     this.next = next;
 }
Beispiel #16
0
 private SkillResponseBuilder(Speech speech)
 {
     Speech   = speech;
     Response = ResponseBuilder.Tell(Speech);
 }
Beispiel #17
0
 public void RemoveSpeech(Speech speech)
 {
     ActiveVoting.RemoveSpeech(speech);
 }
Beispiel #18
0
 /// <summary>
 /// Resets the Voice control to the intial state of listening to the word HAL.
 /// </summary>
 public static void ResetVoice(Speech.SpeechMain speaker, VoiceCntrl.VoiceControl VoiceRecogn)
 {
     //reset to main.
 }
Beispiel #19
0
 protected override Task abortActionAsync()
 {
     return(Speech.SayAllOf("Timed out; try again."));
 }
Beispiel #20
0
        public async Task <List <KeyValuePair <string, string> > > SectionListarCombos(SqlConnection cn, Speech objSpeechBE)
        {
            List <KeyValuePair <string, string> > lstOpcionBE = null;
            SqlCommand cmd = new SqlCommand
            {
                CommandText = "SP_SECTION_COMBO",
                CommandType = CommandType.StoredProcedure,
                Connection  = cn
            };

            cmd.Parameters.AddWithValue("@PK_Speech", objSpeechBE.PK_Speech);
            using (SqlDataReader dtr = await cmd.ExecuteReaderAsync(CommandBehavior.SingleResult))
            {
                lstOpcionBE = new List <KeyValuePair <string, string> >();
                while (await dtr.ReadAsync())
                {
                    lstOpcionBE.Add(
                        new KeyValuePair <string, string>(
                            dtr.GetString(dtr.GetOrdinal("name")),
                            Convert.ToString(dtr.GetInt32(dtr.GetOrdinal("PK_Speech")))
                            )
                        );
                }
            }
            return(lstOpcionBE);
        }
Beispiel #21
0
    private void Parse(Connection connection,DialogueState state, Speech speech)
    {
        switch (state)
        {
                //maybe define better rules for account names and passwords
            case DialogueState.AskName:
                if (speech.Message.Length > 30)
                {
                    connection.SendTextMessage(TextMessageType.ConsoleRed, "Account names must be no more than 30 characters.");
                    connection.SendTextMessage(TextMessageType.ConsoleBlue, "What would you like your account name to be?");
                }
                else if (!System.Text.RegularExpressions.Regex.IsMatch(speech.Message, "^[a-zA-Z0-9]+$"))
                {
                    connection.SendTextMessage(TextMessageType.ConsoleRed, "Only alphanumeric characters(a-z A-Z 0-9) can be used in account names.");
                    connection.SendTextMessage(TextMessageType.ConsoleBlue, "What would you like your account name to be?");
                }
                else if (Database.AccountNameExists(speech.Message))
                {
                    connection.SendTextMessage(TextMessageType.ConsoleRed, "The account name " + speech.Message + " is already being used.");
                    connection.SendTextMessage(TextMessageType.ConsoleBlue, "What would you like your account name to be?");
                    creators[connection].State = DialogueState.AskName;
                }
                else
                {
                    connection.SendTextMessage(TextMessageType.ConsoleBlue, "What would you like your password to be?");
                    creators[connection].AccName = speech.Message;
                    creators[connection].State = DialogueState.AskPassword;
                }
                break;
            case DialogueState.AskPassword:
                if (speech.Message.Length > 29)
                {
                    connection.SendTextMessage(TextMessageType.ConsoleRed, "Passwords must be shorter or as long as 29 characters.");
                    connection.SendTextMessage(TextMessageType.ConsoleBlue, "What would you like your password to be?");
                }
                else if (!System.Text.RegularExpressions.Regex.IsMatch(speech.Message, "^[a-zA-Z0-9]+$"))
                {
                    connection.SendTextMessage(TextMessageType.ConsoleRed, "Only alphanumeric characters(a-z A-Z 0-9) can be used in passwords.");
                    connection.SendTextMessage(TextMessageType.ConsoleBlue, "What would you like your password to be?");
                }
                else
                {
                    creators[connection].Password = speech.Message;
                    int id = Database.CreateAccount(creators[connection].AccName, creators[connection].Password);
                    if (id > 0)
                    {
                        uint pId = game.GenerateAvailableId();
                        if (-1 != Database.CreatePlayer(id, "Account Manager " + Convert.ToBase64String(BitConverter.GetBytes(pId)), pId))
                        {
                            connection.SendTextMessage(TextMessageType.ConsoleBlue, "Congratulations! Your account has been created successfully.");
                            connection.SendTextMessage(TextMessageType.ConsoleBlue, "Details:");
                            connection.SendTextMessage(TextMessageType.ConsoleBlue, "Account Name:   " + creators[connection].AccName);
                            connection.SendTextMessage(TextMessageType.ConsoleBlue, "Password:   "******"You can now login using your account and manage it.");
                            return;
                        }
                        else
                        {
                            connection.SendTextMessage(TextMessageType.ConsoleRed, "An error has ocurred and your account could not be created. Sorry for the inconvenience.");
                            Database.DeleteAccount(id);
                            return;
                        }
                    }
                    else
                    {
                        connection.SendTextMessage(TextMessageType.ConsoleRed, "An error has ocurred and your account could not be created. Sorry for the inconvenience.");
                        return;
                    }
                }
                break;

        }
    }
Beispiel #22
0
 private void Game_OnGameProcessPacket(GamePacketEventArgs args)
 {
     if (!IsActive())
     {
         return;
     }
     try
     {
         var  reader   = new BinaryReader(new MemoryStream(args.PacketData));
         byte packetId = reader.ReadByte(); //PacketId
         if (packetId != Packet.S2C.PlayerDisconnect.Header)
         {
             return;
         }
         Packet.S2C.PlayerDisconnect.Struct disconnect = Packet.S2C.PlayerDisconnect.Decoded(args.PacketData);
         if (disconnect.Player == null)
         {
             return;
         }
         if (_disconnects.ContainsKey(disconnect.Player))
         {
             _disconnects[disconnect.Player] = true;
         }
         else
         {
             _disconnects.Add(disconnect.Player, true);
         }
         if (
             DisReconnectDetector.GetMenuItem("SAssembliesDetectorsDisReconnectChatChoice")
             .GetValue <StringList>()
             .SelectedIndex == 1)
         {
             Game.PrintChat("Champion " + disconnect.Player.ChampionName + " has disconnected!");
         }
         else if (
             DisReconnectDetector.GetMenuItem("SAssembliesDetectorsDisReconnectChatChoice")
             .GetValue <StringList>()
             .SelectedIndex == 2 &&
             Menu.GlobalSettings.GetMenuItem("SAssembliesGlobalSettingsServerChatPingActive").GetValue <bool>())
         {
             Game.Say("Champion " + disconnect.Player.ChampionName + " has disconnected!");
         }
         if (DisReconnectDetector.GetMenuItem("SAssembliesDetectorsDisReconnectSpeech").GetValue <bool>())
         {
             Speech.Speak("Champion " + disconnect.Player.ChampionName + " has disconnected!");
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("DisconnectProcess: " + ex);
     }
     try
     {
         var  reader   = new BinaryReader(new MemoryStream(args.PacketData));
         byte packetId = reader.ReadByte(); //PacketId
         if (packetId != Packet.S2C.PlayerReconnected.Header)
         {
             return;
         }
         Packet.S2C.PlayerReconnected.Struct reconnect = Packet.S2C.PlayerReconnected.Decoded(args.PacketData);
         if (reconnect.Player == null)
         {
             return;
         }
         if (_reconnects.ContainsKey(reconnect.Player))
         {
             _reconnects[reconnect.Player] = true;
         }
         else
         {
             _reconnects.Add(reconnect.Player, true);
         }
         if (
             DisReconnectDetector.GetMenuItem("SAssembliesDetectorsDisReconnectChatChoice")
             .GetValue <StringList>()
             .SelectedIndex == 1)
         {
             Game.PrintChat("Champion " + reconnect.Player.ChampionName + " has reconnected!");
         }
         else if (
             DisReconnectDetector.GetMenuItem("SAssembliesDetectorsDisReconnectChatChoice")
             .GetValue <StringList>()
             .SelectedIndex == 2 &&
             Menu.GlobalSettings.GetMenuItem("SAssembliesGlobalSettingsServerChatPingActive").GetValue <bool>())
         {
             Game.Say("Champion " + reconnect.Player.ChampionName + " has reconnected!");
         }
         if (DisReconnectDetector.GetMenuItem("SAssembliesDetectorsDisReconnectSpeech").GetValue <bool>())
         {
             Speech.Speak("Champion " + reconnect.Player.ChampionName + " has reconnected!");
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("ReconnectProcess: " + ex);
     }
 }
Beispiel #23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Enter the value from the 'App Key' field obtained at developer.att.com in your
        // app account.
        string clientId = "";

        // Enter the value from the 'App Secret' field obtained at developer.att.com
        // in your app account.
        string secretKey = "";

        // Set the fully-qualified domain name to: https://api.att.com
        string fqdn = "https://api.att.com";

        // Set the scope to SPEECH,STTC,TTS
        string scope = "SPEECH,STTC,TTS";

        // Create the service for requesting an OAuth access token.
        var oauth = new OAuth(fqdn, clientId, secretKey, scope);

        // Get the OAuth access token using the OAuth Client Credentials.
        if (oauth.GetAccessToken(OAuth.AccessTokenType.ClientCredentials))
        {
            // Get access token
            OAuthToken at          = new OAuthToken();
            string     accessToken = at.getAccessToken(oauth.accessTokenJson);

            // Create the service for making the method request.
            var speech = new Speech(fqdn, accessToken);

            //*************************************************************************
            // Operation: speech To Text

            // Set params:
            string sttXspeechContext = "BusinessSearch";
            string sttXArgs          = "ClientApp=NoteTaker,ClientVersion=1.0.1,DeviceType=Android";
            string sttSpeechFilePath = Server.MapPath("~/") + "audio/BostonCeltics.wav";
            bool   sttChunked        = true;

            try
            {
                // Make an Make a method call to the Speech To Text API.
                // Method takes:
                // Param 1: speechContext
                // Param 2: XArgs
                // Param 3: SpeechFilePath
                // Param 4: Chunked
                RecognitionObj.RootObject speachToTextResponseObj
                    = speech.speechToText(sttXspeechContext,
                                          sttXArgs,
                                          sttSpeechFilePath,
                                          sttChunked);
            }
            catch (Exception respex)
            {
                string error = respex.StackTrace;
            }

            //*************************************************************************
            // Operation: Speech To Text Custom

            // Set params:
            string mimeData           = System.IO.File.ReadAllText(Server.MapPath("~/") + "template/x-dictionary.txt");
            string sttcXspeechContext = "GrammarList";
            string sttcXArgs          = "GrammarPenaltyPrefix=1.1,GrammarPenaltyGeneric=2.0,GrammarPenaltyAltgram=4.1";
            string sttcSpeechFilePath = Server.MapPath("~/") + "audio/pizza-en-US.wav";
            string xgrammerContent    = string.Empty;
            string xdictionaryContent = string.Empty;

            StreamReader streamReader = new StreamReader(Server.MapPath("~/") + "template/x-dictionary.txt");
            xdictionaryContent = streamReader.ReadToEnd();
            mimeData           = "x-dictionary:" + Environment.NewLine + xdictionaryContent;

            StreamReader streamReader1 = new StreamReader(Server.MapPath("~/") + "template/x-grammer.txt");
            xgrammerContent = streamReader1.ReadToEnd();
            mimeData        = mimeData + Environment.NewLine + "x-grammar:" + Environment.NewLine + xgrammerContent;

            streamReader.Close();
            streamReader1.Close();

            //make speech to text custom request
            try
            {
                // Make an Make a method call to Speech To Text Custom.
                // Method takes:
                // Param 1: mimeData
                // Param 2: speechContext
                // Param 3: XArgs
                // Param 4: SpeechFilePath
                // Param 5: xdictionaryContent
                // Param 5: xgrammerContent
                RecognitionObj.RootObject speachToTextResponseCObj
                    = speech.speechToTextCustom(mimeData,
                                                sttcXspeechContext,
                                                sttcXArgs,
                                                sttcSpeechFilePath,
                                                xdictionaryContent,
                                                xgrammerContent);
            }
            catch (Exception respex)
            {
                string error = respex.StackTrace;
            }

            //*************************************************************************
            // Operation: Text To Speech

            try
            {
                // Make an Make a method call to Text to Speech.
                // Method takes:
                // Param 1: test string
                byte[] responseAudioData = speech.textToSpeech("test");
            }
            catch (Exception respex)
            {
                string error = respex.StackTrace;
            }
        }
    }
Beispiel #24
0
        protected internal void SetAudio(Speech speech)
        {
            //Speech = speech ?? throw new NullReferenceException(nameof(speech));

            Speech = speech;
        }
Beispiel #25
0
    public Dialogue LoadFromTxt(string path, string chapterName, string partName)
    {
        StreamReader  reader = new StreamReader(path, System.Text.Encoding.UTF8);
        string        line;
        string        chapter  = chapterName;
        string        part     = partName;
        string        name     = "";
        List <Speech> speeches = new List <Speech>();
        List <string> type     = new List <string>();
        List <string> text     = new List <string>();

        while ((line = reader.ReadLine()) != chapterName)
        {
            if (line == null)
            {
                Dialogue ds = new Dialogue(chapter, part, speeches);
                return(ds);
            }
        }
        while ((line = reader.ReadLine()) != partName)
        {
            if (line == null)
            {
                Dialogue ds = new Dialogue(chapter, part, speeches);
                return(ds);
            }
        }
        line = reader.ReadLine();
        name = "Description";
        type.Add("Description");
        text.Add(line);
        line = reader.ReadLine();
        int i = 0;

        while (true)
        {
            i++;
            if (i > 10000)
            {
                System.Console.WriteLine("DialogueLoadingError");
                break;
            }
            if (line != null)
            {
                if (line[0] == '-')
                {
                    type.Add("Speech");
                    line = line.Substring(1);
                    text.Add(line);
                }
                else if (line[0] == '*')
                {
                    type.Add("Action");
                    text.Add(line);
                }
                else
                {
                    Speech s = new Speech(name, new List <string>(type), new List <string>(text));
                    speeches.Add(s);
                    type.Clear();
                    text.Clear();
                    name = line;
                }
            }
            line = reader.ReadLine();
            if (line == "-------------------------------------------------------------")
            {
                Speech s = new Speech(name, new List <string>(type), new List <string>(text));
                speeches.Add(s);
                break;
            }
        }
        Dialogue d = new Dialogue(chapter, part, speeches);

        reader.Close();
        return(d);
    }
Beispiel #26
0
        public configure_ui()
        {
            InitializeComponent();

            var setting = Data.GetSetting();

            //voice
            foreach (var voicesName in Speech.GetVoicesNames())
            {
                voices_combo.Items.Add(voicesName);
            }
            voices_combo.SelectedIndex = setting.SelectedVoice;

            //volume
            volume_trackbar.Value = setting.Volume;

            //Rate
            rate_trackbar.Value = setting.Rate;

            //Play Resume key 1 HotKey
            foreach (var key in Enum.GetValues(typeof(ControlKey)))
            {
                hk_playres_1_combo.Items.Add(key.ToString());
            }
            hk_playres_1_combo.SelectedIndex = (int)setting.PlayResume.Key1;

            //Play Resume key 2 HotKey
            foreach (var key in Enum.GetValues(typeof(ControlKey)))
            {
                hk_playres_2_combo.Items.Add(key.ToString());
            }
            hk_playres_2_combo.SelectedIndex = (int)setting.PlayResume.Key2;

            //Play Resume key 3 HotKey
            foreach (var key in Enum.GetValues(typeof(AlphabeticKey)))
            {
                hk_playres_3_combo.Items.Add(key.ToString());
            }
            hk_playres_3_combo.SelectedIndex = (int)setting.PlayResume.Key3;

            //Pause key 1 HotKey
            foreach (var key in Enum.GetValues(typeof(ControlKey)))
            {
                hk_pause_1_combo.Items.Add(key.ToString());
            }
            hk_pause_1_combo.SelectedIndex = (int)setting.Pause.Key1;

            //Pause key 2 HotKey
            foreach (var key in Enum.GetValues(typeof(ControlKey)))
            {
                hk_pause_2_combo.Items.Add(key.ToString());
            }
            hk_pause_2_combo.SelectedIndex = (int)setting.Pause.Key2;

            //Pause key 3 HotKey
            foreach (var key in Enum.GetValues(typeof(AlphabeticKey)))
            {
                hk_pause_3_combo.Items.Add(key.ToString());
            }
            hk_pause_3_combo.SelectedIndex = (int)setting.Pause.Key3;

            //Stop key 1  HotKey
            foreach (var key in Enum.GetValues(typeof(ControlKey)))
            {
                hk_stop_1_combo.Items.Add(key.ToString());
            }
            hk_stop_1_combo.SelectedIndex = (int)setting.Stop.Key1;

            //Stop key 2  HotKey
            foreach (var key in Enum.GetValues(typeof(ControlKey)))
            {
                hk_stop_2_combo.Items.Add(key.ToString());
            }
            hk_stop_2_combo.SelectedIndex = (int)setting.Stop.Key2;

            //Stop key 3  HotKey
            foreach (var key in Enum.GetValues(typeof(AlphabeticKey)))
            {
                hk_stop_3_combo.Items.Add(key.ToString());
            }
            hk_stop_3_combo.SelectedIndex = (int)setting.Stop.Key3;
        }
Beispiel #27
0
 void LogDialogue(Speech pSpeech)
 {
     Console.WriteLine(pSpeech.speaker + ": " + pSpeech.line);
     _dialogueLog.Add(pSpeech.line);
 }
Beispiel #28
0
        private void Game_OnGameUpdate(object sender, EventArgs args)
        {
            if (!IsActive() || lastGameUpdateTime + new Random().Next(500, 1000) > Environment.TickCount)
            {
                return;
            }

            lastGameUpdateTime = Environment.TickCount;
            Obj_AI_Hero player = ObjectManager.Player;

            foreach (var enemy in _enemies.ToList())
            {
                double dmg = 0;
                try
                {
                    if (player.Spellbook.CanUseSpell(SpellSlot.Q) == SpellState.Ready)
                    {
                        dmg += player.GetSpellDamage(enemy.Key, SpellSlot.Q);
                    }
                }
                catch (InvalidOperationException)
                {
                }
                try
                {
                    if (player.Spellbook.CanUseSpell(SpellSlot.W) == SpellState.Ready)
                    {
                        dmg += player.GetSpellDamage(enemy.Key, SpellSlot.W);
                    }
                }
                catch (InvalidOperationException)
                {
                }
                try
                {
                    if (player.Spellbook.CanUseSpell(SpellSlot.E) == SpellState.Ready)
                    {
                        dmg += player.GetSpellDamage(enemy.Key, SpellSlot.E);
                    }
                }
                catch (InvalidOperationException)
                {
                }
                try
                {
                    if (player.Spellbook.CanUseSpell(SpellSlot.R) == SpellState.Ready)
                    {
                        dmg += player.GetSpellDamage(enemy.Key, SpellSlot.R);
                    }
                }
                catch (InvalidOperationException)
                {
                }
                try
                {
                    dmg += player.GetAutoAttackDamage(enemy.Key);
                }
                catch (InvalidOperationException)
                {
                }
                _enemies[enemy.Key].Damage = dmg;
                if (enemy.Value.Damage > enemy.Key.Health)
                {
                    _enemies[enemy.Key].Line.Color = Color.OrangeRed;
                }
                if (enemy.Value.Damage < enemy.Key.Health && !GankTracker.GetMenuItem("SAssembliesTrackersGankKillable").GetValue <bool>())
                {
                    _enemies[enemy.Key].Line.Color = Color.GreenYellow;
                }
                else if (enemy.Key.Health / enemy.Key.MaxHealth < 0.1)
                {
                    _enemies[enemy.Key].Line.Color = Color.Red;
                    if (!_enemies[enemy.Key].Pinged)
                    {
                        if (GankTracker.GetMenuItem("SAssembliesTrackersGankVoice").GetValue <bool>())
                        {
                            Speech.Speak("Gankable " + enemy.Key.ChampionName);
                        }
                    }
                    if (!_enemies[enemy.Key].Pinged && GankTracker.GetMenuItem("SAssembliesTrackersGankPing").GetValue <bool>())
                    {
                        Packet.S2C.Ping.Encoded(new Packet.S2C.Ping.Struct(enemy.Key.ServerPosition[0],
                                                                           enemy.Key.ServerPosition[1], 0, 0, Packet.PingType.Normal)).Process();
                        _enemies[enemy.Key].Pinged = true;
                    }
                }
                else if (enemy.Key.Health / enemy.Key.MaxHealth > 0.1)
                {
                    _enemies[enemy.Key].Pinged = false;
                }
            }
        }
Beispiel #29
0
 public Form1()
 {
     InitializeComponent();
     speech = new Speech(this);
     pcc = new Camera.PCCamera(this.pictureBox1.Handle, 0, 0, 320, 240);
 }
Beispiel #30
0
        public async Task <List <KeyValuePair <string, string> > > SectionListarCombos(Speech objSpeechBE)
        {
            using (SqlConnection cn = new SqlConnection(this.stringConexion))
            {
                await cn.OpenAsync();

                SectionDatos objSectionDA = new SectionDatos();
                return(await objSectionDA.SectionListarCombos(cn, objSpeechBE));
            }
        }
Beispiel #31
0
        public void OnPlayerUseWorldItemSecondary(object secondaryResult)
        {
            WIListResult dialogResult = secondaryResult as WIListResult;

            switch (dialogResult.SecondaryResult)
            {
            case "Drink":
                if (!CanBuyDrink)
                {
                    if (gBartenderSpeech == null)
                    {
                        gBartenderSpeech = new Speech();
                    }
                    gBartenderSpeech.Text = "That's enough for one night, {lad/lass}.";
                    worlditem.Get <Talkative>().SayDTS(gBartenderSpeech);
                }
                else
                {
                    if (Player.Local.Inventory.InventoryBank.TryToRemove(PricePerDrink))
                    {
                        Profile.Get.CurrentGame.Character.Rep.GainGlobalReputation(1);
                        //spawn a cup and put some mead in it
                        WorldItem cup = null;
                        if (WorldItems.CloneRandomFromCategory("BartenderCups", WIGroups.Get.World, out cup))
                        {
                            cup.Initialize();
                            LiquidContainer container = null;
                            if (cup.Is <LiquidContainer>(out container))
                            {
                                container.State.Contents.CopyFrom(BartenderDrinkContents);
                                container.State.Contents.InstanceWeight = container.State.Capacity;
                            }
                            //try to equip it in the player's hands
                            Player.Local.Inventory.TryToEquip(cup);
                        }
                        State.NumTimesBoughtDrink++;
                        State.NumTimesBoughtDrinkTonight++;
                        State.LastTimeBoughtDrink = WorldClock.AdjustedRealTime;
                    }
                }
                break;

            case "Round":
                if (Player.Local.Inventory.InventoryBank.TryToRemove(PricePerRound))
                {
                    if (gBartenderSpeech == null)
                    {
                        gBartenderSpeech = new Speech();
                    }
                    gBartenderSpeech.Text = "Looks like this round's on {PlayerFirstName}!";
                    worlditem.Get <Talkative>().SayDTS(gBartenderSpeech);
                    Profile.Get.CurrentGame.Character.Rep.GainGlobalReputation(5);
                    State.NumTimesBoughtRound++;
                    State.LastTimeBoughtRound = WorldClock.AdjustedRealTime;
                }
                break;

            default:
                break;
            }
        }
Beispiel #32
0
 public static void SpeakQueued(Speech speech)
 {
     queue.Enqueue(speech);
     //speak(speech);
 }
Beispiel #33
0
 public void AddSpeech(Speech speech)
 {
     ActiveVoting.AddSpeech(speech);
 }
Beispiel #34
0
 public static void Speak(Speech speech, bool overwrite = true) =>
 Speak(speech.text, speech.gender, speech.speed);
Beispiel #35
0
 public void Vote(Speech speech, UserProfile profile)
 {
     ActiveVoting.Vote(speech, profile);
 }
Beispiel #36
0
	public static Speech Create (string _id) {
		Speech speech = new Speech (_id);
		speech.toActive = new List<string> ();
		return speech;
	}
Beispiel #37
0
        private async void Recognize(SpeechRecognitionMessage speech)
        {
            if (speechService == null)
            {
                speechService = new Speech();
                speechService.SpeechStatusChanged +=
                    (sender, args) => { appSettings.IsListening = args.Status == SpeechStatus.Listening; };
            }

            await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                try
                {
                    if (speech.Action != null && speech.Action.Equals("STOP"))
                    {
                        speechService.Stop();
                        return;
                    }

                    var expectedConfidence = speech.Confidence ?? (int)SpeechRecognitionConfidence.Medium;

                    var recognizeText = default(RecognizedSpeech);

                    var confident = false;
                    var timeout   = DateTime.UtcNow.AddMilliseconds(speech.Ms ?? 0);
                    while (!confident && (speech.Ms == null || speech.Ms == 0 || DateTime.UtcNow < timeout))
                    //consider timeout here
                    {
                        Debug.WriteLine("recognizing...");
                        recognizeText = await speechService.Recognize(speech.Message, speech.UI);
                        Debug.WriteLine("end recognizing...");
                        if (recognizeText.status != SpeechRecognitionResultStatus.Success)
                        {
                            break;
                        }

                        confident = expectedConfidence >= recognizeText.confidence;
                    }

                    var status = recognizeText.status == SpeechRecognitionResultStatus.Success
                        ? recognizeText.index
                        : (recognizeText.status == SpeechRecognitionResultStatus.UserCanceled
                            ? 0
                            : -(int)recognizeText.status);

                    if ((recognizeText.status == SpeechRecognitionResultStatus.Unknown ||
                         recognizeText.status == SpeechRecognitionResultStatus.Success) &&
                        !confident && (speech.Ms != null && speech.Ms != 0 || DateTime.UtcNow >= timeout))
                    {
                        status = 0; //timeout or cancelled
                    }

                    await
                    SendResult(new SpeechResultMessage(speech)
                    {
                        Result   = recognizeText.text,
                        ResultId = status,
                        Action   = recognizeText.action,
                        Value    = recognizeText.confidence
                    });
                }
                catch (Exception e)
                {
                    await SendResult(new ResultMessage
                                         (speech)
                    {
                        Result = e.Message, ResultId = e.HResult
                    });
                }
            });
        }
Beispiel #38
0
 private void testsListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     test = (Test)testsListView.SelectedItem;
     Speech.speakPurge(test.ToString());
 }
Beispiel #39
0
        public bool TryToOccupyNode(WorldItem newOccupant)
        {
            if (newOccupant == mReservant)
            {
                mOccupant = mReservant;
                return(true);
            }

            if (!CanOccupy(newOccupant) || !HasOccupantReached(newOccupant))                                      //whoops, we either can't use this or we're too far away
            {
                return(false);
            }

            if (HasOccupant && newOccupant != mOccupant)                                      //if we've made it this far and we have an occupant
            //they need to be displaced
            {
                VacateNode(mOccupant);
            }

            //hooray we're the new occupant
            State.NumTimesOccupied++;
            mOccupant = newOccupant;
            if (State.OccupantName == mOccupant.FileName)                                      //if we match the specific occupant for this node
            {
                State.NumTimesOccupiedSpecific++;
            }

            if (!mSendingEvents)
            {
                StartCoroutine(SendEvents(ActionNodeBehavior.OnOccupy));
            }

            //align to action node direction
            //load custom animation
            //if we have a speech, this will be overridden
            Motile motile = null;

            if (mOccupant.Is <Motile>(out motile))
            {
                //if we told the occupant to come here
                MotileAction topAction = motile.TopAction;
                if (topAction.Type == MotileActionType.GoToActionNode &&
                    topAction.LiveTarget == this)                                                       //finish the action
                {
                    topAction.TryToFinish();
                }
            }

            //alrighty time for the speech givin'
            //see if this new occupant is talkative
            Talkative talkative = null;

            if (mOccupant.Is <Talkative>(out talkative))
            {
                Speech speech      = null;
                bool   foundSpeech = false;
                switch (State.Speech)
                {
                case ActionNodeSpeech.None:
                default:
                    //there'll be no speechifying today
                    break;

                case ActionNodeSpeech.RandomAnyone:
                    //use speech flags to pull a random speech for anyone who uses this node
                    //not implemented
                    break;

                case ActionNodeSpeech.CustomAnyone:
                    //use speech flags to pull a specified speech for anyone who uses this node
                    //not implemented
                    break;

                case ActionNodeSpeech.RandomCharOnly:
                    //use speech flags to pull a random speech for the specific character that uses this node
                    //not implemented
                    break;

                case ActionNodeSpeech.CustomCharOnly:
                    //use speech flags to pull a specified speech for the specific character that uses this node
                    foundSpeech = Mods.Get.Runtime.LoadMod <Speech>(ref speech, "Speech", State.CustomSpeech);
                    break;

                case ActionNodeSpeech.SequenceCharOnly:
                    //use the custom speech name to get the next speech in a sequence
                    string speechName          = State.CustomSpeech;
                    int    currentSpeechNumber = 1;
                    bool   keepLooking         = true;
                    //TODO look into putting this in Talkative
                    while (keepLooking)                                                                              //get the next speech
                    {
                        speechName = State.CustomSpeech.Replace("[#]", currentSpeechNumber.ToString());
                        if (Mods.Get.Runtime.LoadMod <Speech>(ref speech, "Speech", speechName))                                                                                          //load the speech and see if it's been given by our character
                        {
                            int numTimesStartedBy = speech.NumTimesStartedBy(mOccupant.FileName);
                            if (numTimesStartedBy <= 0)                                                                                                      //if the speech hasn't been started by this character before, use it
                            {
                                keepLooking = false;
                                foundSpeech = true;
                            }
                            else                                                                                                        //otherwise increment the speech number and keep looking
                            {
                                currentSpeechNumber++;
                            }
                        }
                        else                                                                                            //no more speeches to try, oh well
                        {
                            keepLooking = false;
                        }
                    }
                    break;
                }

                if (foundSpeech)
                {
                    talkative.GiveSpeech(speech, this);
                }
            }
            //if we've gotten this far we're golden
            return(true);
        }
Beispiel #40
0
 private void signoutButton_Click(object sender, RoutedEventArgs e)
 {
     Speech.speakPurgeSync("Bye " + candidate.UserName);
     this.Close();
 }
Beispiel #41
0
        protected void ResolveEndOfGesture(Sequence <DKS> resultSequence)
        {
            MostRecentSample = resultSequence;
            if (!_userTrainingMode)
            {
                MostRecentSample.TrueClassIndex = SelectedGestureClass.index;
            }
            //Dataset?.AddSequence(MostRecentSample);

            string StageLabel = (!_userTrainingMode)
                ? $"Cued gesture {SelectedGestureClass.className}#{SelectedGestureClass.numExamples + SelectedGestureClass.numNewExamples}"
                : $"User gesture (#{Dataset.SequenceCount + 1})";

            if (!_advancedCueMode)
            {
                ResetStage(StageLabel);
            }

            _collectingData = false;
            if (Classifier == null)
            {
                return;
            }
            MostRecentSample = Analyze(MostRecentSample).Result;

            // If right or wrong, tweak the display properties of the sample.  This depends on the active mode.
            //DisplaySampleInfo(MostRecentSample);

            if (_userTrainingMode && MostRecentSample.RecognizedAsIndex >= 0)
            {
                var sc     = MostRecentSample.RecognitionScore;
                var prefix = (sc < 1) ? "Arguably " :
                             (sc < 1.5) ? "Maybe " :
                             (sc < 2) ? "Probably " :
                             (sc < 2.5) ? "Clearly " :
                             (sc < 3) ? "Certainly " :
                             "A perfect ";
                Speech.Say(prefix + MostRecentSample.RecognizedAsName);
            }
            else if (!_userTrainingMode)
            {
                if (CurrentCue == null)
                {
                    CurrentCue = new ChoreographyCue();
                }
                else if (MostRecentSample.RecognizedAsIndex == -1)
                {
                    CurrentCue.Score = double.NaN;
                }
                else if (MostRecentSample.RecognizedAsIndex != MostRecentSample.TrueClassIndex)
                {
                    CurrentCue.Score             = -1 * MostRecentSample.RecognitionScore;
                    CurrentCue.GestureClassIndex = MostRecentSample.RecognizedAsIndex;
                }
                //CuePrompter?.ReactToFinalizedGesture(MostRecentSample);
                else
                {
                    var points = MostRecentSample.RecognitionScore;
                    var delay  = MostRecentSample.Metadata.Delay;

                    CurrentCue.Score = points;
                    CurrentCue.Delay = delay;
                }
                //if (!_singleMode) Choreographer?.ProceedWithNextCue();
                MeleeChoreographer.SubmitResult(CurrentCue);
            }
        }
Beispiel #42
0
 void Thalamus.BML.ISpeakActions.SpeakBookmarks(string id, string[] text, string[] bookmarks)
 {
     Speech speech = new Speech(id, text, bookmarks);
     if (speechEngine != null)
     {
         Debug("Speaking '" + speech.FullText() + "'");
         speechEngine.Speak(speech);
     }
 }
        private void voice_SpeechRecognizedEvent(object sender, VoiceCommandEvents.SpeechRecognizedEventArgs e)
        {
            SetStatusMsg("Voice Command: " + Functions.String.ToTitleCase(e.Command), true);

            switch (e.Command)
            {
                case "open":
                case "open file":
                    OpenFile();
                    break;
                case "mute":
                    mp.Mute(true);
                    break;
                case "unmute":
                    mp.Mute(false);
                    break;
                case "increase volume":
                case "raise volume":
                case "volume up":
                    if (mp.Volume >= 90)
                        SetVolume(100);
                    else
                        SetVolume(mp.Volume + 10);
                    break;
                case "decrease volume":
                case "lower volume":
                case "volume down":
                    if (mp.Volume <= 10)
                        SetVolume(0);
                    else
                        SetVolume(mp.Volume - 10);
                    break;
                case "hide":
                    HidePlayer();
                    break;
                case "show":
                    this.WindowState = FormWindowState.Normal;
                    this.Focus();
                    break;
                case "help":
                    voiceCommandHelpToolStripMenuItem_Click(this, EventArgs.Empty);
                    break;
                case "stop listening":
                    DisableVoiceCommand();
                    break;
                case "close":
                    Application.Exit();
                    break;
            }

            // check if a file is opened before allowing playback commands
            if (!mp.PlayerIsRunning() || string.IsNullOrEmpty(mp.FileInfo.Url))
                return;

            switch (e.Command)
            {
                case "play":
                    mp.Play();
                    break;
                case "pause":
                    mp.Pause(false);
                    break;
                case "rewind":
                    mp.Rewind();
                    break;
                case "stop":
                    mp.Stop();
                    break;
                case "next chapter":
                case "skip chapter":
                    mp.NextChapter();
                    break;
                case "previous chapter":
                    mp.PreviousChapter();
                    break;
                case "next":
                case "next file":
                    playlist.PlayNext();
                    break;
                case "previous":
                case "previous file":
                    playlist.PlayPrevious();
                    break;
                case "fullscreen":
                case "view fullscreen":
                case "go fullscreen":
                    FullScreen = true;
                    break;
                case "exit fullscreen":
                case "leave fullscreen":
                    FullScreen = false;
                    break;
                case "whats playing":
                    if (speech == null)
                        speech = new Speech(mp.FileInfo);
                    speech.SayMedia();
                    break;
            }
        }
Beispiel #44
0
 public void StartSpeech(Speech speech, List <UnityEvent> events)
 {
     this.events = events;
     ShowSpeech(speech);
 }
Beispiel #45
0
    private void Parse(Connection connection, DialogueState state, Speech speech)
    {
        switch (state)
        {
            #region AskTask
            case DialogueState.AskTask:
                switch (speech.Message.ToLower())
                {
                    case "create":
                        connection.SendTextMessage(TextMessageType.ConsoleBlue, "Would you like it to be {male} or {female}'?");
                        managers[connection].State = DialogueState.AskGender;
                        break;
                    case "delete":
                        managers[connection].CharactersList =new List<CharacterListItem>(Database.GetCharacterList(connection.AccountId));
                        if (managers[connection].CharactersList.Count > 1)
                        {
                            connection.SendTextMessage(TextMessageType.ConsoleBlue, "Your account contains the following characters:");
                            for (int i = 1; i < managers[connection].CharactersList.Count; i++)
                            {
                                connection.SendTextMessage(TextMessageType.ConsoleBlue, i + ". " + managers[connection].CharactersList[i].Name);
                            }
                            connection.SendTextMessage(TextMessageType.ConsoleBlue, "What character would you like to delete (by index)?");
                            managers[connection].State = DialogueState.AskDeleteIndex;
                        }
                        else
                        {
                            connection.SendTextMessage(TextMessageType.ConsoleRed, "Your account doesn't contain any characters yet.");
                            connection.SendTextMessage(TextMessageType.ConsoleBlue, HelpPrompt);
                            managers[connection].State = DialogueState.AskTask;
                        }
                        break;
                    case "password":
                        connection.SendTextMessage(TextMessageType.ConsoleBlue, "What would you like your new password to be?");
                        managers[connection].State = DialogueState.AskPassword;
                        break;
                    default:
                        connection.SendTextMessage(TextMessageType.ConsoleRed, CantUnderstand);
                        connection.SendTextMessage(TextMessageType.ConsoleBlue, HelpPrompt);
                        break;
                }
                break;
            #endregion

            #region AskPassword
            case DialogueState.AskPassword:
                if (speech.Message.Length > 29)
                {
                    connection.SendTextMessage(TextMessageType.ConsoleRed, "Passwords must be no more than 29 characters.");
                    connection.SendTextMessage(TextMessageType.ConsoleBlue, "What would you like your password to be?");
                }
                else if (!System.Text.RegularExpressions.Regex.IsMatch(speech.Message, "^[a-zA-Z0-9]+$"))
                {
                    connection.SendTextMessage(TextMessageType.ConsoleRed, "Only alphanumeric characters(a-z A-Z 0-9) can be used in passwords.");
                    connection.SendTextMessage(TextMessageType.ConsoleBlue, "What would you like your password to be?");
                }
                else if (Database.UpdateAccountPassword(connection.AccountId, speech.Message))
                {
                    connection.SendTextMessage(TextMessageType.ConsoleBlue, "Your account password has been changed with success.");
                    connection.SendTextMessage(TextMessageType.ConsoleBlue, HelpPrompt);
                    managers[connection].State = DialogueState.AskTask;
                }
                else
                {
                    connection.SendTextMessage(TextMessageType.ConsoleRed, "An error has occurred and your password could not be changed. Sorry for the inconvenience.");
                    connection.SendTextMessage(TextMessageType.ConsoleBlue, HelpPrompt);
                    managers[connection].State = DialogueState.AskTask;
                }
                break;
            #endregion

            #region AskGender
            case DialogueState.AskGender:
                switch (speech.Message.ToLower())
                {
                    case "male":
                        managers[connection].CharacterGender = Gender.Male;
                        break;
                    case "female":
                        managers[connection].CharacterGender = Gender.Female;
                        break;
                    default:
                        connection.SendTextMessage(TextMessageType.ConsoleRed, CantUnderstand);
                        connection.SendTextMessage(TextMessageType.ConsoleBlue, "Would you like it to be {male} or {female}?");
                        return;
                }
                connection.SendTextMessage(TextMessageType.ConsoleBlue, vocationsText);
                managers[connection].State = DialogueState.AskVocation;
                break;
            #endregion

            #region AskVocation
            case DialogueState.AskVocation:
                try
                {
                    managers[connection].CharacterVocation = (Vocation)Enum.Parse(typeof(Vocation), speech.Message, true);
                    connection.SendTextMessage(TextMessageType.ConsoleBlue, "What would you like your character's name to be?");
                    managers[connection].State = DialogueState.AskName;
                }
                catch
                {
                    connection.SendTextMessage(TextMessageType.ConsoleRed, CantUnderstand);
                    connection.SendTextMessage(TextMessageType.ConsoleBlue, vocationsText);
                }
                break;
            #endregion

            #region AskName
            case DialogueState.AskName:
                if (speech.Message.Length > 29)
                {
                    connection.SendTextMessage(TextMessageType.ConsoleRed, "Character names must be shorter or as long as 29 characters.");
                    connection.SendTextMessage(TextMessageType.ConsoleBlue, "What would you like your character name to be?");
                }
                else if (!System.Text.RegularExpressions.Regex.IsMatch(speech.Message, "^[a-zA-Z-' ]+$"))
                {
                    connection.SendTextMessage(TextMessageType.ConsoleRed, "Only letters(a-z A-Z), hyphens(-) and apostrophes(') can be used in character names.");
                    connection.SendTextMessage(TextMessageType.ConsoleBlue, "What would you like your character name to be?");
                }
                else if (Database.PlayerNameExists(speech.Message))
                {
                    connection.SendTextMessage(TextMessageType.ConsoleRed, "A character with that name already exists.");
                    connection.SendTextMessage(TextMessageType.ConsoleBlue, "What would you like your character's name to be?");
                }
                else
                {
                    managers[connection].CharacterName = speech.Message;
                    managers[connection].State = DialogueState.AskGender;
                    Player p = new Player();
                    p.Connection = connection;
                    p.Name = managers[connection].CharacterName;
                    p.Gender = managers[connection].CharacterGender;
                    p.Vocation = managers[connection].CharacterVocation;
                    p.Id=game.GenerateAvailableId();
                    p.Tile = new Tile();
                    p.Tile.Location = new Location(97, 205, 7);//"temple position"
                    if (p.Gender == Gender.Male)
                        p.Outfit = new Outfit(128, 0);
                    else
                        p.Outfit = new Outfit(136, 0);
                    Database.CreatePlayer(connection.AccountId, p.Name, p.Id);
                    Database.SavePlayerInfo(p);
                    connection.SendTextMessage(TextMessageType.ConsoleBlue, "Your character has been created sucessfully.You can now relog to access it.");

                    connection.SendTextMessage(TextMessageType.ConsoleBlue, HelpPrompt);
                    managers[connection].State = DialogueState.AskTask;
                }
                break;
            #endregion

            #region AskDeleteIndex
            case DialogueState.AskDeleteIndex:
                ushort us;
                if(ushort.TryParse(speech.Message,out us))
                {
                    if (us < managers[connection].CharactersList.Count && us != 0)
                    {
                        managers[connection].DeleteSelected = managers[connection].CharactersList[(int)us].Name;
                        connection.SendTextMessage(TextMessageType.ConsoleOrange, "Are you sure you want to delete the character " + managers[connection].DeleteSelected + " from your account('yes' or 'no')?This decision is irreversible.");
                        managers[connection].State = DialogueState.AskDeleteConfirmation;
                    }
                    else
                    {
                        connection.SendTextMessage(TextMessageType.ConsoleRed, "Index out of range(1-" + (managers[connection].CharactersList.Count - 1) + ").");
                        connection.SendTextMessage(TextMessageType.ConsoleBlue, "Which character would you like to delete (by index)?");
                    }
                }
                else
                {
                    connection.SendTextMessage(TextMessageType.ConsoleRed, CantUnderstand);
                    connection.SendTextMessage(TextMessageType.ConsoleBlue, "Which character would you like to delete (by index)?");
                }

                break;
            #endregion

            #region AskDeleteConfirmation
            case DialogueState.AskDeleteConfirmation:
                switch (speech.Message.ToLower())
                {
                    case "yes":
                        if (Database.DeletePlayerByName(managers[connection].DeleteSelected))
                        {
                            connection.SendTextMessage(TextMessageType.ConsoleBlue, "Your character has been deleted sucessfully.");
                        }
                        else
                        {
                            connection.SendTextMessage(TextMessageType.ConsoleRed, "An error has occurred and your character could not be deleted.Sorry for the inconvenience.");
                        }
                        connection.SendTextMessage(TextMessageType.ConsoleBlue, HelpPrompt);
                        managers[connection].State = DialogueState.AskTask;
                        break;
                    case "no":
                        connection.SendTextMessage(TextMessageType.ConsoleBlue, "Character deletion canceled.");
                        connection.SendTextMessage(TextMessageType.ConsoleBlue, HelpPrompt);
                        managers[connection].State = DialogueState.AskTask;
                        break;
                    default:
                        connection.SendTextMessage(TextMessageType.ConsoleRed, CantUnderstand);
                        connection.SendTextMessage(TextMessageType.ConsoleOrange, "Are you sure you want to delete the character " + managers[connection].DeleteSelected + " from your account ({yes} or {no})? This decision is irreversible.");
                        break;
                }
                break;
            #endregion
        }
    }
 void LogSpeech(Speech pSpeech)
 {
     Console.WriteLine("Got Speech: " + pSpeech.speaker + " said " + pSpeech.line);
     _speech.Add(pSpeech);
 }
Beispiel #47
0
        public MainV2()
        {
            Form splash = new Splash();
            splash.Show();

            string strVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

            strVersion = "mav " + MAVLink.MAVLINK_WIRE_PROTOCOL_VERSION;

            splash.Text = "APM Planner " + Application.ProductVersion + " " + strVersion + " By Michael Oborne";

            splash.Refresh();

            Application.DoEvents();

            instance = this;

            InitializeComponent();

            _connectionControl = toolStripConnectionControl.ConnectionControl;
            _connectionControl.CMB_baudrate.TextChanged += this.CMB_baudrate_TextChanged;
            _connectionControl.CMB_baudrate.SelectedIndexChanged += this.CMB_baudrate_SelectedIndexChanged;
            _connectionControl.CMB_serialport.SelectedIndexChanged += this.CMB_serialport_SelectedIndexChanged;
            _connectionControl.CMB_serialport.Enter += this.CMB_serialport_Enter;
            _connectionControl.CMB_serialport.Click += this.CMB_serialport_Click;
            _connectionControl.TOOL_APMFirmware.SelectedIndexChanged += this.TOOL_APMFirmware_SelectedIndexChanged;

            srtm.datadirectory = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + "srtm";

            var t = Type.GetType("Mono.Runtime");
            MONO = (t != null);

            speechEngine = new Speech();

            MyRenderer.currentpressed = MenuFlightData;

            MainMenu.Renderer = new MyRenderer();

            List<object> list = new List<object>();
            foreach (object obj in Enum.GetValues(typeof(Firmwares)))
            {
                _connectionControl.TOOL_APMFirmware.Items.Add(obj);
            }

            if (_connectionControl.TOOL_APMFirmware.Items.Count > 0)
                _connectionControl.TOOL_APMFirmware.SelectedIndex = 0;

            this.Text = splash.Text;

            comPort.BaseStream.BaudRate = 115200;

            // ** Old
            //            CMB_serialport.Items.AddRange(SerialPort.GetPortNames());
            //            CMB_serialport.Items.Add("TCP");
            //            CMB_serialport.Items.Add("UDP");
            //            if (CMB_serialport.Items.Count > 0)
            //            {
            //                CMB_baudrate.SelectedIndex = 7;
            //                CMB_serialport.SelectedIndex = 0;
            //            }
            // ** new
            _connectionControl.CMB_serialport.Items.AddRange(ArdupilotMega.Comms.SerialPort.GetPortNames());
            _connectionControl.CMB_serialport.Items.Add("TCP");
            _connectionControl.CMB_serialport.Items.Add("UDP");
            if (_connectionControl.CMB_serialport.Items.Count > 0)
            {
                _connectionControl.CMB_baudrate.SelectedIndex = 7;
                _connectionControl.CMB_serialport.SelectedIndex = 0;
            }
            // ** Done

            splash.Refresh();
            Application.DoEvents();

            // set this before we reset it
            MainV2.config["NUM_tracklength"] = "200";

            xmlconfig(false);

            if (config.ContainsKey("language") && !string.IsNullOrEmpty((string)config["language"]))
                changelanguage(CultureInfoEx.GetCultureInfo((string)config["language"]));

            if (!MONO) // windows only
            {
                if (MainV2.config["showconsole"] != null && MainV2.config["showconsole"].ToString() == "True")
                {
                }
                else
                {
                    int win = FindWindow("ConsoleWindowClass", null);
                    ShowWindow(win, SW_HIDE); // hide window
                }
            }

            try
            {
                FlightData = new GCSViews.FlightData();
                FlightPlanner = new GCSViews.FlightPlanner();
                //Configuration = new GCSViews.Configuration();
                Simulation = new GCSViews.Simulation();
                Firmware = new GCSViews.Firmware();
                //Terminal = new GCSViews.Terminal();

                // preload
                Python.CreateEngine();
            }
            catch (Exception e) { CustomMessageBox.Show("A Major error has occured : " + e.ToString()); this.Close(); }

            if (MainV2.config["CHK_GDIPlus"] != null)
                GCSViews.FlightData.myhud.UseOpenGL = !bool.Parse(MainV2.config["CHK_GDIPlus"].ToString());

            ChangeUnits();

            try
            {
                if (config["MainLocX"] != null && config["MainLocY"] != null)
                {
                    this.StartPosition = FormStartPosition.Manual;
                    Point startpos = new Point(int.Parse(config["MainLocX"].ToString()), int.Parse(config["MainLocY"].ToString()));
                    this.Location = startpos;
                }

                if (config["MainMaximised"] != null)
                {
                    this.WindowState = (FormWindowState)Enum.Parse(typeof(FormWindowState), config["MainMaximised"].ToString());
                    // dont allow minimised start state
                    if (this.WindowState == FormWindowState.Minimized)
                    {
                        this.WindowState = FormWindowState.Normal;
                        this.Location = new Point(100, 100);
                    }
                }

                if (config["MainHeight"] != null)
                    this.Height = int.Parse(config["MainHeight"].ToString());
                if (config["MainWidth"] != null)
                    this.Width = int.Parse(config["MainWidth"].ToString());

                if (config["CMB_rateattitude"] != null)
                    MainV2.cs.rateattitude = byte.Parse(config["CMB_rateattitude"].ToString());
                if (config["rateposition"] != null)
                    MainV2.cs.rateposition = byte.Parse(config["CMB_rateposition"].ToString());
                if (config["CMB_ratestatus"] != null)
                    MainV2.cs.ratestatus = byte.Parse(config["CMB_ratestatus"].ToString());
                if (config["CMB_raterc"] != null)
                    MainV2.cs.raterc = byte.Parse(config["CMB_raterc"].ToString());
                if (config["CMB_ratesensors"] != null)
                    MainV2.cs.ratesensors = byte.Parse(config["CMB_ratesensors"].ToString());

                if (config["speechenable"] != null)
                    MainV2.speechEnable = bool.Parse(config["speechenable"].ToString());

                //int fixme;
                /*
                MainV2.cs.rateattitude = 50;
                MainV2.cs.rateposition = 50;
                MainV2.cs.ratestatus = 50;
                MainV2.cs.raterc = 50;
                MainV2.cs.ratesensors = 50;
                */
                try
                {
                    if (config["TXT_homelat"] != null)
                        cs.HomeLocation.Lat = double.Parse(config["TXT_homelat"].ToString());

                    if (config["TXT_homelng"] != null)
                        cs.HomeLocation.Lng = double.Parse(config["TXT_homelng"].ToString());

                    if (config["TXT_homealt"] != null)
                        cs.HomeLocation.Alt = double.Parse(config["TXT_homealt"].ToString());
                }
                catch { }

            }
            catch { }

            if (cs.rateattitude == 0) // initilised to 10, configured above from save
            {
                CustomMessageBox.Show("NOTE: your attitude rate is 0, the hud will not work\nChange in Configuration > Planner > Telemetry Rates");
            }

            //System.Threading.Thread.Sleep(2000);

            // make sure new enough .net framework is installed
            if (!MONO)
            {
                Microsoft.Win32.RegistryKey installed_versions = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP");
                string[] version_names = installed_versions.GetSubKeyNames();
                //version names start with 'v', eg, 'v3.5' which needs to be trimmed off before conversion
                double Framework = Convert.ToDouble(version_names[version_names.Length - 1].Remove(0, 1), CultureInfo.InvariantCulture);
                int SP = Convert.ToInt32(installed_versions.OpenSubKey(version_names[version_names.Length - 1]).GetValue("SP", 0));

                if (Framework < 3.5)
                {
                    CustomMessageBox.Show("This program requires .NET Framework 3.5. You currently have " + Framework);
                }
            }

            Application.DoEvents();

            splash.Close();
        }
		public void MixAndMatchEntityScalar()
		{
			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();
			Speech speech = new Speech();
			speech.Length = 23d;
			speech.Name = "Mine";
			s.Save(speech);
			s.Flush();
			s.Clear();

			IList l = s.CreateSQLQuery("select name, id, flength, name as scalarName from Speech")
				.SetResultSetMapping("speech")
				.List();
			Assert.AreEqual(l.Count, 1);

			t.Rollback();
			s.Close();
		}
Beispiel #49
0
 IEnumerator Schedule(Speech chunk)
 {
     yield return null;
 }
Beispiel #50
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Enter the value from the 'App Key' field obtained at developer.att.com in your
        // app account.
        string clientId = "";

        // Enter the value from the 'App Secret' field obtained at developer.att.com
        // in your app account.
        string secretKey = "";

        // Set the fully-qualified domain name to: https://api.att.com
        string fqdn = "https://api.att.com";

        // Set the scope to SPEECH,STTC,TTS
        string scope = "SPEECH,STTC,TTS";

        // Create the service for requesting an OAuth access token.
        var oauth = new OAuth(fqdn, clientId, secretKey, scope);

        // Get the OAuth access token using the OAuth Client Credentials.
        if (oauth.GetAccessToken(OAuth.AccessTokenType.ClientCredentials))
        {
            // Get access token
            OAuthToken at = new OAuthToken();
            string accessToken = at.getAccessToken(oauth.accessTokenJson);

            // Create the service for making the method request.
            var speech = new Speech(fqdn, accessToken);

            //*************************************************************************
            // Operation: speech To Text

            // Set params:
            string sttXspeechContext = "BusinessSearch";
            string sttXArgs = "ClientApp=NoteTaker,ClientVersion=1.0.1,DeviceType=Android";
            string sttSpeechFilePath = Server.MapPath("~/") + "audio/BostonCeltics.wav";
            bool sttChunked = true;

            try
            {
                // Make an Make a method call to the Speech To Text API.
                // Method takes:
                // Param 1: speechContext
                // Param 2: XArgs
                // Param 3: SpeechFilePath
                // Param 4: Chunked
                RecognitionObj.RootObject speachToTextResponseObj
                    = speech.speechToText(sttXspeechContext,
                                            sttXArgs,
                                            sttSpeechFilePath,
                                            sttChunked);
            }
            catch (Exception respex)
            {
                string error = respex.StackTrace;
            }

            //*************************************************************************
            // Operation: Speech To Text Custom

            // Set params:
            string mimeData = System.IO.File.ReadAllText(Server.MapPath("~/") + "template/x-dictionary.txt");
            string sttcXspeechContext = "GrammarList";
            string sttcXArgs = "GrammarPenaltyPrefix=1.1,GrammarPenaltyGeneric=2.0,GrammarPenaltyAltgram=4.1";
            string sttcSpeechFilePath = Server.MapPath("~/") + "audio/pizza-en-US.wav";
            string xgrammerContent = string.Empty;
            string xdictionaryContent = string.Empty;

            StreamReader streamReader = new StreamReader(Server.MapPath("~/") + "template/x-dictionary.txt");
            xdictionaryContent = streamReader.ReadToEnd();
            mimeData = "x-dictionary:" + Environment.NewLine + xdictionaryContent;

            StreamReader streamReader1 = new StreamReader(Server.MapPath("~/") + "template/x-grammer.txt");
            xgrammerContent = streamReader1.ReadToEnd();
            mimeData = mimeData + Environment.NewLine + "x-grammar:" + Environment.NewLine + xgrammerContent;

            streamReader.Close();
            streamReader1.Close();

            //make speech to text custom request
            try
            {
                // Make an Make a method call to Speech To Text Custom.
                // Method takes:
                // Param 1: mimeData
                // Param 2: speechContext
                // Param 3: XArgs
                // Param 4: SpeechFilePath
                // Param 5: xdictionaryContent
                // Param 5: xgrammerContent
                RecognitionObj.RootObject speachToTextResponseCObj
                    = speech.speechToTextCustom(mimeData,
                                                sttcXspeechContext,
                                                sttcXArgs,
                                                sttcSpeechFilePath,
                                                xdictionaryContent,
                                                xgrammerContent);
            }
            catch (Exception respex)
            {
                string error = respex.StackTrace;
            }

            //*************************************************************************
            // Operation: Text To Speech

            try
            {
                // Make an Make a method call to Text to Speech.
                // Method takes:
                // Param 1: test string
                byte[] responseAudioData = speech.textToSpeech("test");
            }
            catch (Exception respex)
            {
                string error = respex.StackTrace;
            }
        }
    }
Beispiel #51
0
        public void Ssml_Error_With_No_Text()
        {
            var ssml = new Speech();

            Assert.Throws <InvalidOperationException>(() => ssml.ToXml());
        }
Beispiel #52
0
 protected override Task nextStageActionAsync()
 {
     return(Speech.SayAllOf("Got it.", SoundOptions.AtSpeed(1.75)));
 }
        public async Task <IActionResult> GetVoices()
        {
            Speech sch = new Speech();

            return(await Task.FromResult(Ok(sch.GetVoices().Result)));
        }
        private void Game_OnGameUpdate(EventArgs args)
        {
            if (!IsActive() || lastGameUpdateTime + new Random().Next(500, 1000) > Environment.TickCount)
            {
                return;
            }

            lastGameUpdateTime = Environment.TickCount;

            if (HealthTimer.GetActive())
            {
                HealthObject healthDestroyed = null;
                foreach (HealthObject health in Healths)
                {
                    if (health.Obj.IsValid)
                    {
                        if (health.Obj.Health > 0)
                        {
                            health.Locked          = false;
                            health.NextRespawnTime = 0;
                            health.Called          = false;
                        }
                        else if (health.Obj.Health < 1 && health.Locked == false)
                        {
                            health.Locked          = true;
                            health.NextRespawnTime = health.RespawnTime + (int)Game.ClockTime;
                        }
                    }
                    if (health.NextRespawnTime < (int)Game.ClockTime && health.Locked)
                    {
                        healthDestroyed = health;
                    }
                }
                if (healthDestroyed != null)
                {
                    healthDestroyed.TextMinimap.Dispose();
                    healthDestroyed.TextMinimap.Remove();
                    healthDestroyed.TextMap.Dispose();
                    healthDestroyed.TextMap.Remove();
                    Healths.Remove(healthDestroyed);
                }
                foreach (Obj_AI_Minion health in ObjectManager.Get <Obj_AI_Minion>())
                {
                    HealthObject nHealth = null;
                    if (health.Name.Contains("Health"))
                    {
                        HealthObject health1 = Healths.Find(jm => jm.Obj.NetworkId == health.NetworkId);
                        if (health1 == null)
                        {
                            nHealth = new HealthObject(health);
                        }
                    }

                    if (nHealth != null)
                    {
                        Healths.Add(nHealth);
                    }
                }
            }

            /////

            if (HealthTimer.GetActive())
            {
                foreach (HealthObject health in Healths)
                {
                    if (health.Locked)
                    {
                        if (health.NextRespawnTime - (int)Game.ClockTime <= 0 || health.MapType != GMap.Type)
                        {
                            continue;
                        }
                        int time = Timer.Timers.GetMenuItem("SAssembliesTimersRemindTime").GetValue <Slider>().Value;
                        if (!health.Called && health.NextRespawnTime - (int)Game.ClockTime <= time &&
                            health.NextRespawnTime - (int)Game.ClockTime >= time - 1)
                        {
                            health.Called = true;
                            Timer.PingAndCall("Heal respawns in " + time + " seconds!", health.Position);
                            if (HealthTimer.GetMenuItem("SAssembliesTimersHealthSpeech").GetValue <bool>())
                            {
                                Speech.Speak("Heal respawns in " + time + " seconds!");
                            }
                        }
                    }
                }
            }
        }
 private void OnSomeoneSaidSomething(Speech pInfo)
 {
     _lines.Add(pInfo.line);
 }
        private void HandleRecall(Packet.S2C.Teleport.Struct recallEx)
        {
            int time = Environment.TickCount - Game.Ping;

            for (int i = 0; i < Recalls.Count; i++)
            {
                Packet.S2C.Teleport.Struct recall = Recalls[i];
                if (true /*recallEx.Type == Recall.ObjectType.Player*/)
                {
                    var obj   = ObjectManager.GetUnitByNetworkId <Obj_AI_Hero>(recall.UnitNetworkId);
                    var objEx = ObjectManager.GetUnitByNetworkId <Obj_AI_Hero>(recallEx.UnitNetworkId);
                    if (obj == null)
                    {
                        continue;
                    }
                    if (obj.NetworkId == objEx.NetworkId) //already existing
                    {
                        recall = recallEx;
                        //recall.Recall2 = new Recall.Struct();

                        var    percentHealth = (int)((obj.Health / obj.MaxHealth) * 100);
                        String sColor;
                        String hColor = (percentHealth > 50
                            ? "<font color='#00FF00'>"
                            : (percentHealth > 30 ? "<font color='#FFFF00'>" : "<font color='#FF0000'>"));
                        if (recallEx.Status == Packet.S2C.Teleport.Status.Start)
                        {
                            String text = (recallEx.Type == Packet.S2C.Teleport.Type.Recall
                                ? Language.GetString("DETECTORS_RECALL_TEXT_RECALLING")
                                : Language.GetString("DETECTORS_RECALL_TEXT_PORTING"));
                            sColor       = "<font color='#FFFF00'>";
                            recall.Start = (int)Game.Time;
                            if (
                                RecallDetector.GetMenuItem("SAssembliesDetectorsRecallChatChoice")
                                .GetValue <StringList>()
                                .SelectedIndex == 1)
                            {
                                Game.PrintChat("{0}" + obj.ChampionName + " {1} " + Language.GetString("DETECTORS_RECALL_TEXT_WITH") + " {2} " +
                                               Language.GetString("DETECTORS_RECALL_TEXT_HP") + " {3}({4})", sColor, text,
                                               (int)obj.Health, hColor, percentHealth);
                            }
                            else if (
                                RecallDetector.GetMenuItem("SAssembliesDetectorsRecallChatChoice")
                                .GetValue <StringList>()
                                .SelectedIndex == 2 &&
                                Menu.GlobalSettings.GetMenuItem("SAssembliesGlobalSettingsServerChatPingActive")
                                .GetValue <bool>())
                            {
                                Game.Say("{0}" + obj.ChampionName + " {1} " + Language.GetString("DETECTORS_RECALL_TEXT_WITH") + " {2} " +
                                         Language.GetString("DETECTORS_RECALL_TEXT_HP") + " {3}({4})", sColor, text, (int)obj.Health,
                                         hColor, percentHealth);
                            }
                            if (RecallDetector.GetMenuItem("SAssembliesDetectorsRecallSpeech").GetValue <bool>())
                            {
                                Speech.Speak(obj.ChampionName + " " + text);
                            }
                        }
                        else if (recallEx.Status == Packet.S2C.Teleport.Status.Finish)
                        {
                            String text = (recallEx.Type == Packet.S2C.Teleport.Type.Recall
                                ? Language.GetString("DETECTORS_RECALL_TEXT_RECALLED")
                                : Language.GetString("DETECTORS_RECALL_TEXT_PORTED"));
                            sColor = "<font color='#FF0000'>";
                            if (
                                RecallDetector.GetMenuItem("SAssembliesDetectorsRecallChatChoice")
                                .GetValue <StringList>()
                                .SelectedIndex == 1)
                            {
                                Game.PrintChat("{0}" + obj.ChampionName + " {1} " + Language.GetString("DETECTORS_RECALL_TEXT_WITH") + " {2} " +
                                               Language.GetString("DETECTORS_RECALL_TEXT_HP") + " {3}({4})", sColor, text,
                                               (int)obj.Health, hColor, percentHealth);
                            }
                            else if (
                                RecallDetector.GetMenuItem("SAssembliesDetectorsRecallChatChoice")
                                .GetValue <StringList>()
                                .SelectedIndex == 2 &&
                                Menu.GlobalSettings.GetMenuItem(
                                    "SAssembliesGlobalSettingsServerChatPingActive").GetValue <bool>())
                            {
                                Game.Say("{0}" + obj.ChampionName + " {1} " + Language.GetString("DETECTORS_RECALL_TEXT_WITH") + " {2} " +
                                         Language.GetString("DETECTORS_RECALL_TEXT_HP") + " {3}({4})", sColor, text,
                                         (int)obj.Health, hColor, percentHealth);
                            }
                            if (RecallDetector.GetMenuItem("SAssembliesDetectorsRecallSpeech").GetValue <bool>())
                            {
                                Speech.Speak(obj.ChampionName + " " + text);
                            }
                        }
                        else
                        {
                            sColor = "<font color='#00FF00'>";
                            if (
                                RecallDetector.GetMenuItem("SAssembliesDetectorsRecallChatChoice")
                                .GetValue <StringList>()
                                .SelectedIndex == 1)
                            {
                                Game.PrintChat("{0}" + obj.ChampionName + " " + Language.GetString("DETECTORS_RECALL_TEXT_CANCELED") + " " +
                                               Language.GetString("DETECTORS_RECALL_TEXT_WITH") + " {1} " +
                                               Language.GetString("DETECTORS_RECALL_TEXT_HP") + "", sColor, (int)obj.Health);
                            }
                            else if (
                                RecallDetector.GetMenuItem("SAssembliesDetectorsRecallChatChoice")
                                .GetValue <StringList>()
                                .SelectedIndex == 2 &&
                                Menu.GlobalSettings.GetMenuItem(
                                    "SAssembliesGlobalSettingsServerChatPingActive").GetValue <bool>())
                            {
                                Game.Say("{0}" + obj.ChampionName + " " + Language.GetString("DETECTORS_RECALL_TEXT_CANCELED") + " "
                                         + Language.GetString("DETECTORS_RECALL_TEXT_WITH") + " {1} " +
                                         Language.GetString("DETECTORS_RECALL_TEXT_HP") + "", sColor, (int)obj.Health);
                            }
                            if (RecallDetector.GetMenuItem("SAssembliesDetectorsRecallSpeech").GetValue <bool>())
                            {
                                Speech.Speak(obj.ChampionName + " " + Language.GetString("DETECTORS_RECALL_TEXT_CANCELED"));
                            }
                        }
                        return;
                    }
                }
            }
        }
Beispiel #57
0
        public MainV2()
        {
            log.Info("Mainv2 ctor");

            Form splash = Program.Splash;

            string strVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

            strVersion = "mav " + MAVLink.MAVLINK_WIRE_PROTOCOL_VERSION;

            splash.Text = "Mission Planner " + Application.ProductVersion + " " + strVersion;

            splash.Refresh();

            Application.DoEvents();

            instance = this;

            InitializeComponent();

            MenuFlightPlanner.Image = new Bitmap(MissionPlanner.Properties.Resources.flightplanner);

            MyView = new MainSwitcher(this);

            View = MyView;

            _connectionControl = toolStripConnectionControl.ConnectionControl;
            _connectionControl.CMB_baudrate.TextChanged += this.CMB_baudrate_TextChanged;
            _connectionControl.CMB_baudrate.SelectedIndexChanged += this.CMB_baudrate_SelectedIndexChanged;
            _connectionControl.CMB_serialport.SelectedIndexChanged += this.CMB_serialport_SelectedIndexChanged;
            _connectionControl.CMB_serialport.Enter += this.CMB_serialport_Enter;
            _connectionControl.CMB_serialport.Click += this.CMB_serialport_Click;
            _connectionControl.TOOL_APMFirmware.SelectedIndexChanged += this.TOOL_APMFirmware_SelectedIndexChanged;

            _connectionControl.ShowLinkStats += (sender, e) => ShowConnectionStatsForm();
            srtm.datadirectory = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + "srtm";

            var t = Type.GetType("Mono.Runtime");
            MONO = (t != null);

            speechEngine = new Speech();

            // proxy loader - dll load now instead of on config form load
            new Transition(new TransitionType_EaseInEaseOut(2000));

            //MyRenderer.currentpressed = MenuFlightData;

            //MainMenu.Renderer = new MyRenderer();

            foreach (object obj in Enum.GetValues(typeof(Firmwares)))
            {
                _connectionControl.TOOL_APMFirmware.Items.Add(obj);
            }

            if (_connectionControl.TOOL_APMFirmware.Items.Count > 0)
                _connectionControl.TOOL_APMFirmware.SelectedIndex = 0;

            this.Text = splash.Text;

            comPort.BaseStream.BaudRate = 115200;

            // ** Old
            //            CMB_serialport.Items.AddRange(SerialPort.GetPortNames());
            //            CMB_serialport.Items.Add("TCP");
            //            CMB_serialport.Items.Add("UDP");
            //            if (CMB_serialport.Items.Count > 0)
            //            {
            //                CMB_baudrate.SelectedIndex = 7;
            //                CMB_serialport.SelectedIndex = 0;
            //            }
            // ** new
            _connectionControl.CMB_serialport.Items.Add("AUTO");
            _connectionControl.CMB_serialport.Items.AddRange(SerialPort.GetPortNames());
            _connectionControl.CMB_serialport.Items.Add("TCP");
            _connectionControl.CMB_serialport.Items.Add("UDP");
            if (_connectionControl.CMB_serialport.Items.Count > 0)
            {
                _connectionControl.CMB_baudrate.SelectedIndex = 7;
                _connectionControl.CMB_serialport.SelectedIndex = 0;
            }
            // ** Done

            splash.Refresh();
            Application.DoEvents();

            // set this before we reset it
            MainV2.config["NUM_tracklength"] = "200";

            // load config
            xmlconfig(false);

            if (config.ContainsKey("language") && !string.IsNullOrEmpty((string)config["language"]))
                changelanguage(CultureInfoEx.GetCultureInfo((string)config["language"]));

            if (!MONO) // windows only
            {
                if (MainV2.config["showconsole"] != null && MainV2.config["showconsole"].ToString() == "True")
                {
                }
                else
                {
                    int win = NativeMethods.FindWindow("ConsoleWindowClass", null);
                    NativeMethods.ShowWindow(win, NativeMethods.SW_HIDE); // hide window
                }
            }

            ChangeUnits();

            if (config["theme"] != null)
            {
                ThemeManager.SetTheme((ThemeManager.Themes)Enum.Parse(typeof(ThemeManager.Themes), MainV2.config["theme"].ToString()));

                if (ThemeManager.CurrentTheme == ThemeManager.Themes.Custom)
                {
                    try
                    {
                        ThemeManager.BGColor = Color.FromArgb(int.Parse(MainV2.config["theme_bg"].ToString()));
                        ThemeManager.ControlBGColor = Color.FromArgb(int.Parse(MainV2.config["theme_ctlbg"].ToString()));
                        ThemeManager.TextColor = Color.FromArgb(int.Parse(MainV2.config["theme_text"].ToString()));
                        ThemeManager.ButBG = Color.FromArgb(int.Parse(MainV2.config["theme_butbg"].ToString()));
                        ThemeManager.ButBorder = Color.FromArgb(int.Parse(MainV2.config["theme_butbord"].ToString()));
                    }
                    catch { log.Error("Bad Custom theme - reset to standard"); ThemeManager.SetTheme(ThemeManager.Themes.BurntKermit); }
                }
            }

            try
            {
                log.Info("Create FD");
                FlightData = new GCSViews.FlightData();
                log.Info("Create FP");
                FlightPlanner = new GCSViews.FlightPlanner();
                //Configuration = new GCSViews.ConfigurationView.Setup();
                log.Info("Create SIM");
                Simulation = new GCSViews.Simulation();
                //Firmware = new GCSViews.Firmware();
                //Terminal = new GCSViews.Terminal();

                // preload
                log.Info("Create Python");
                Python.CreateEngine();
            }
            catch (ArgumentException e)
            {
                //http://www.microsoft.com/en-us/download/details.aspx?id=16083
                //System.ArgumentException: Font 'Arial' does not support style 'Regular'.

                log.Fatal(e);
                CustomMessageBox.Show(e.ToString() + "\n\n Font Issues? Please install this http://www.microsoft.com/en-us/download/details.aspx?id=16083");
                //splash.Close();
                //this.Close();
                Application.Exit();
            }
            catch (Exception e) { log.Fatal(e); CustomMessageBox.Show("A Major error has occured : " + e.ToString()); Application.Exit(); }

            if (MainV2.config["CHK_GDIPlus"] != null)
                GCSViews.FlightData.myhud.UseOpenGL = !bool.Parse(MainV2.config["CHK_GDIPlus"].ToString());

            try
            {
                if (config["MainLocX"] != null && config["MainLocY"] != null)
                {
                    this.StartPosition = FormStartPosition.Manual;
                    Point startpos = new Point(int.Parse(config["MainLocX"].ToString()), int.Parse(config["MainLocY"].ToString()));
                    this.Location = startpos;
                }

                if (config["MainMaximised"] != null)
                {
                    this.WindowState = (FormWindowState)Enum.Parse(typeof(FormWindowState), config["MainMaximised"].ToString());
                    // dont allow minimised start state
                    if (this.WindowState == FormWindowState.Minimized)
                    {
                        this.WindowState = FormWindowState.Normal;
                        this.Location = new Point(100, 100);
                    }
                }

                if (config["MainHeight"] != null)
                    this.Height = int.Parse(config["MainHeight"].ToString());
                if (config["MainWidth"] != null)
                    this.Width = int.Parse(config["MainWidth"].ToString());

                if (config["CMB_rateattitude"] != null)
                    MainV2.comPort.MAV.cs.rateattitude = byte.Parse(config["CMB_rateattitude"].ToString());
                if (config["CMB_rateposition"] != null)
                    MainV2.comPort.MAV.cs.rateposition = byte.Parse(config["CMB_rateposition"].ToString());
                if (config["CMB_ratestatus"] != null)
                    MainV2.comPort.MAV.cs.ratestatus = byte.Parse(config["CMB_ratestatus"].ToString());
                if (config["CMB_raterc"] != null)
                    MainV2.comPort.MAV.cs.raterc = byte.Parse(config["CMB_raterc"].ToString());
                if (config["CMB_ratesensors"] != null)
                    MainV2.comPort.MAV.cs.ratesensors = byte.Parse(config["CMB_ratesensors"].ToString());

                if (config["speechenable"] != null)
                    MainV2.speechEnable = bool.Parse(config["speechenable"].ToString());

                //int fixme;
                /*
                MainV2.comPort.MAV.cs.rateattitude = 50;
                MainV2.comPort.MAV.cs.rateposition = 50;
                MainV2.comPort.MAV.cs.ratestatus = 50;
                MainV2.comPort.MAV.cs.raterc = 50;
                MainV2.comPort.MAV.cs.ratesensors = 50;
                */
                try
                {
                    if (config["TXT_homelat"] != null)
                        MainV2.comPort.MAV.cs.HomeLocation.Lat = double.Parse(config["TXT_homelat"].ToString());

                    if (config["TXT_homelng"] != null)
                        MainV2.comPort.MAV.cs.HomeLocation.Lng = double.Parse(config["TXT_homelng"].ToString());

                    if (config["TXT_homealt"] != null)
                        MainV2.comPort.MAV.cs.HomeLocation.Alt = double.Parse(config["TXT_homealt"].ToString());
                }
                catch { }
            }
            catch { }

            if (MainV2.comPort.MAV.cs.rateattitude == 0) // initilised to 10, configured above from save
            {
                CustomMessageBox.Show("NOTE: your attitude rate is 0, the hud will not work\nChange in Configuration > Planner > Telemetry Rates");
            }

            // log dir

            if (config["logdirectory"] != null)
                MainV2.LogDir = config["logdirectory"].ToString();

            //System.Threading.Thread.Sleep(2000);

            // make sure new enough .net framework is installed
            if (!MONO)
            {
                Microsoft.Win32.RegistryKey installed_versions = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP");
                string[] version_names = installed_versions.GetSubKeyNames();
                //version names start with 'v', eg, 'v3.5' which needs to be trimmed off before conversion
                double Framework = Convert.ToDouble(version_names[version_names.Length - 1].Remove(0, 1), CultureInfo.InvariantCulture);
                int SP = Convert.ToInt32(installed_versions.OpenSubKey(version_names[version_names.Length - 1]).GetValue("SP", 0));

                if (Framework < 3.5)
                {
                    CustomMessageBox.Show("This program requires .NET Framework 3.5. You currently have " + Framework);
                }
            }

            Application.DoEvents();

            Comports.Add(comPort);

            //int fixmenextrelease;
               // if (MainV2.getConfig("fixparams") == "")
            {
            //    Utilities.ParameterMetaDataParser.GetParameterInformation();
            //    MainV2.config["fixparams"] = 1;
            }

            splash.Close();
        }
Beispiel #58
0
 // Use this for initialization
 void Start()
 {
     Speech = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Speech>();
 }