예제 #1
0
        public override byte[] GetMessageBytes()
        {
            int msgLen = GetBaseSize() + 1 + sliders.Count * 3 * sizeof(float) + sliders.Count;             // BaseSize + Amount of Sliders + <AmountOfSlider> * 3 * float + 1 Byte for each string (string amount before str)

            foreach (SliderDetails sd in sliders)
            {
                msgLen += sd.name.Length;                 // ... + 1 byte for each character in each string.
            }

            _bytes = new byte[msgLen];

            int index = 0;

            PackDuties(ref index);                                                                       // Msg Type

            MobileControlPackHelper.PackByte(ref _bytes, ref index, Convert.ToByte(sliders.Count));      // Amount of sliders

            foreach (SliderDetails sd in sliders)                                                        // For each slider:
            {
                MobileControlPackHelper.PackByte(ref _bytes, ref index, Convert.ToByte(sd.name.Length)); // Amound of letters for this name
                MobileControlPackHelper.PackString(ref _bytes, ref index, sd.name);                      // name (letter for letter, not null terminated)
                MobileControlPackHelper.PackFloat(ref _bytes, ref index, sd.minValue);                   // Minimum Slider Value
                MobileControlPackHelper.PackFloat(ref _bytes, ref index, sd.maxValue);                   // Maximum Slider Value
                MobileControlPackHelper.PackFloat(ref _bytes, ref index, sd.curValue);                   // Current Slider Value
            }

            return(_bytes);
        }
예제 #2
0
        public override byte[] GetMessageBytes()
        {
            int msgLen = GetBaseSize() + sizeof(int) + menuList.Count;             // BaseSize + list entries (int) + 1 byte for each string length ...

            foreach (string str in menuList)
            {
                msgLen += str.Length;                 // ... + 1 byte for each character in each string.
            }

            _bytes = new byte[msgLen];

            int index = 0;

            PackDuties(ref index);                                                  // Msg Type

            MobileControlPackHelper.PackInt(ref _bytes, ref index, menuList.Count); // Amount of list entries

            // For each list entry:
            for (int ii = 0; ii < menuList.Count; ++ii)
            {
                MobileControlPackHelper.PackByte(ref _bytes, ref index, Convert.ToByte(menuList[ii].Length)); // Amound of letters for this element
                MobileControlPackHelper.PackString(ref _bytes, ref index, menuList[ii]);                      // list entry (letter for letter, not null terminated)
            }

            return(_bytes);
        }
예제 #3
0
        public override byte[] GetMessageBytes()
        {
            int msgLen = GetBaseSize() + 1 + disabledButtonList.Count + 1 + namedButtonList.Count;             // BaseSize + 1 amount of optional bytes + optional bytes (disabled and named amount)

            // + 1 amount of named buttons + amount of strings.

            foreach (KeyValuePair <uint, string> entry in namedButtonList)
            {
                msgLen += entry.Value.Length + 1;                 // ... + x bytes (for all characters of each "named button" string) + 1 byte (for amount of chars).
            }

            _bytes = new byte[msgLen];

            int index = 0;

            PackDuties(ref index);                                                                             // Msg Type

            MobileControlPackHelper.PackByte(ref _bytes, ref index, Convert.ToByte(disabledButtonList.Count)); // Amount of optional disabled button bytes

            foreach (uint disabledOption in disabledButtonList)
            {
                MobileControlPackHelper.PackByte(ref _bytes, ref index, Convert.ToByte(disabledOption));                 // For each disabled button, add the button id.
            }

            MobileControlPackHelper.PackByte(ref _bytes, ref index, Convert.ToByte(namedButtonList.Count));             // Amount of optional named buttons

            foreach (KeyValuePair <uint, string> entry in namedButtonList)
            {
                MobileControlPackHelper.PackByte(ref _bytes, ref index, Convert.ToByte(entry.Key));          // For each named button, add the button id.
                MobileControlPackHelper.PackByte(ref _bytes, ref index, Convert.ToByte(entry.Value.Length)); // Amound of letters for this element
                MobileControlPackHelper.PackString(ref _bytes, ref index, entry.Value);                      // And afterwards the string (button name).
            }

            return(_bytes);
        }
예제 #4
0
        public override byte[] GetMessageBytes()
        {
            int msgLen = GetBaseSize();

            // Figure out size of the data:
            msgLen += 1;             // Amount of Categories

            for (int categoryIndex = 0; categoryIndex < categorySectionList.Count; ++categoryIndex)
            {
                Category category = categorySectionList[categoryIndex];

                msgLen += 1 + 1 + category.categoryName.Length + 1;                 // Category ID +  Amount of Chars (Category Name) + Category Name + Amount of Scenes

                for (int sceneIndex = 0; sceneIndex < category.sectionList.Count; ++sceneIndex)
                {
                    Category.Section section = category.sectionList[sceneIndex];

                    msgLen += 1 + 1 + section.sectionName.Length;                     // Scene ID + Amount of Chars (Category Name) + Scene Name
                }
            }

            // Now start packing:
            _bytes = new byte[msgLen];
            int index = 0;

            PackDuties(ref index);                                                                              // Msg Type

            MobileControlPackHelper.PackByte(ref _bytes, ref index, Convert.ToByte(categorySectionList.Count)); // Amount of Categories

            for (int categoryIndex = 0; categoryIndex < categorySectionList.Count; ++categoryIndex)
            {
                Category category = categorySectionList[categoryIndex];

                MobileControlPackHelper.PackByte(ref _bytes, ref index, Convert.ToByte(category.categoryID));          // Category ID
                MobileControlPackHelper.PackByte(ref _bytes, ref index, Convert.ToByte(category.categoryName.Length)); // Category Name String Length
                MobileControlPackHelper.PackString(ref _bytes, ref index, category.categoryName);                      // Category Name


                MobileControlPackHelper.PackByte(ref _bytes, ref index, Convert.ToByte(category.sectionList.Count));                 // Amount of Scenes

                for (int sceneIndex = 0; sceneIndex < category.sectionList.Count; ++sceneIndex)
                {
                    Category.Section section = category.sectionList[sceneIndex];

                    MobileControlPackHelper.PackByte(ref _bytes, ref index, Convert.ToByte(section.sectionID));          // Scene ID
                    MobileControlPackHelper.PackByte(ref _bytes, ref index, Convert.ToByte(section.sectionName.Length)); // Section Name String Length
                    MobileControlPackHelper.PackString(ref _bytes, ref index, section.sectionName);                      // Section Name
                }
            }

            return(_bytes);
        }