コード例 #1
0
        public static void LogError(object msg)
        {
            string message = msg.ToString();
            Color  color   = Color.red;

            SGroup sGroup = new SGroup();

            sGroup.AutoGrowDirection = SGroup.EDirection.Vertical;
            sGroup.AutoLayout        = (SGroup g) => g.AutoLayoutHorizontal;
            sGroup.OnUpdateStyle     = delegate(SElement elem)
            {
                elem.Fill();
            };
            sGroup.AutoLayoutVerticalStretch   = false;
            sGroup.AutoLayoutHorizontalStretch = false;
            sGroup.GrowExtra         = Vector2.zero;
            sGroup.ContentSize       = Vector2.zero;
            sGroup.AutoLayoutPadding = 0;
            sGroup.Background        = Color.clear;

            LogLabel modname = new LogLabel(Initialisation.metadata.Name + ": ");

            modname.Colors[0] = color;
            sGroup.Children.Add(modname);

            LogLabel label = new LogLabel(message);

            label.Colors[0]  = color;
            label.Background = Color.clear;
            sGroup.Children.Add(label);

            ETGModConsole.Instance.GUI[0].Children.Add(sGroup);

            ETGModConsole.Instance.GUI[0].UpdateStyle();
        }
コード例 #2
0
        /// <summary>
        /// Update the lesson
        /// </summary>
        private void UpdateLesson()
        {
            //Make new instance of DB Class
            DBRepository DB = DBRepository.GetInstance();


            //Make a new lesson object
            Lesson L = new Lesson(TB_Title.Text, LessonToEditID, CB_Lesson_Status.SelectedItem.ToString(), TB_Desc.Text, TB_Subject.Text, 0);

            //Update the lesson using the object
            DB.UpdateLesson(L);

            //Get Group Information
            var Groups   = DB.FindGroupData();
            int Group_ID = 0;

            //For every group in the list of groups
            foreach (var SGroup in Groups)
            {
                if (SGroup.GetGroupName() == CB_Classes.SelectedItem.ToString())
                {
                    //If groupname equals the selected group (add id)
                    Group_ID = SGroup.Get_Group_ID();
                }
            }

            //Delete previous groups that had this lesson
            DB.DeleteLessonAtGroupsByID(LessonToEditID);
            DB.DeleteImageFromLessonByID(LessonToEditID);
            DB.DeleteArtObjFromLessonByID(LessonToEditID);

            //Add this lesson to the groups that currently have this lesson
            if (CB_Classes.SelectedItem.ToString() == "All")
            {
                DB.InsertLessonForGroups(LessonToEditID, 0);

                //Inserting Images into Lesson
                Saving_Images_To_Lesson(LessonToEditID);

                //Inserting Art into Lesson
                Saving_Artobjects_To_Lesson(LessonToEditID);
            }
            else
            {
                DB.InsertLessonForGroups(LessonToEditID, Group_ID);

                //Inserting Images into Lesson
                Saving_Images_To_Lesson(LessonToEditID);

                //Inserting Art into Lesson
                Saving_Artobjects_To_Lesson(LessonToEditID);
            }

            MessageBox.Show("Lesson Updated");
        }
コード例 #3
0
        public void SetupDebugText()
        {
            Logger.Debug("SetupDebugText()");

            _DebugGroup = new SGroup {
                AutoLayout    = (self) => self.AutoLayoutVertical,
                Visible       = true,
                OnUpdateStyle = (elem) => {
                    elem.Fill(0);
                },
                Background = new Color(0.0f, 0.0f, 0.0f, 0.0f)
            };

            _DebugGroup.Children.Add(_VersionLabel = new SLabel($"ModUntitled v{VERSION}"));
            _DebugGroup.Children.Add(_FPSLabel     = new SLabel("?? FPS"));
        }
コード例 #4
0
 public override void Start()
 {
     GUI = new SGroup {
         Visible         = false,
         Border          = 20f,
         OnUpdateStyle   = (SElement elem) => elem.Fill(),
         AutoLayout      = (SGroup g) => g.AutoLayoutVertical,
         ScrollDirection = SGroup.EDirection.Vertical,
         Children        =
         {
             new SLabel("THIS LOG IS <color=#ff0000ff>WORK IN PROGRESS</color>."),
             new SLabel("It drops the Unity OnGUI / IMGUI system for SGUI."),
             new SLabel("Some code may still be missing in the SGUI port."),
         }
     };
 }
コード例 #5
0
ファイル: Healthbars.cs プロジェクト: flagmaggot/HealthBars
        public void Start()
        {
            parent = GetComponent <BraveBehaviour>();

            bar = new SGroup()
            {
                Size = new Vector2(50, 10),
                With =
                {
                    new HealthbarFix(parent)
                },
                Border = 2f
            };
            parent.healthHaver.OnDeath         += OnDeath;
            parent.healthHaver.OnHealthChanged += OnHealthChanged;

            lastHealth = parent.healthHaver.GetCurrentHealth();
        }
コード例 #6
0
        public void Awake()
        {
            SlideOffset = NotificationSpaceWidth;

            _CurrentNotificationDelay = MaxNotificationDelay;
            _NotificationGroup        = new SGroup {
                Visible    = true,
                Background = new Color(0, 0, 0, 0),

                OnUpdateStyle = (obj) => {
                    var width = NotificationSpaceWidth;
                    obj.Position = new Vector2(Screen.width - width, 0);
                    obj.Size     = new Vector2(width, Screen.height);
                },

                Children = { }
            };
        }
コード例 #7
0
        public static void SegmentGroupUpdateStyle(SElement elem)
        {
            // elem.Position = elem.Previous.Position + new Vector2(0, elem.Previous.Size.y + elem.Backend.LineHeight * 2);

            if (!(elem is SGroup))
            {
                return;
            }
            SGroup group = (SGroup)elem;

            group.Border = 0;

            float height = 0f;

            for (int i = 0; i < group.Children.Count; i++)
            {
                if (i > 0)
                {
                    height += group.AutoLayoutPadding;
                }
                height += group.Children[i].Size.y;
            }
            elem.Size = new Vector2(elem.Parent.InnerSize.x, height);
        }
コード例 #8
0
    public override void Start()
    {
        KeepSinging();

        IconMod = Resources.Load <Texture2D>("etgmod/gui/icon_mod");
        IconAPI = Resources.Load <Texture2D>("etgmod/gui/icon_api");
        IconZip = Resources.Load <Texture2D>("etgmod/gui/icon_zip");
        IconDir = Resources.Load <Texture2D>("etgmod/gui/icon_dir");

        GUI = new SGroup {
            Visible       = false,
            OnUpdateStyle = (SElement elem) => elem.Fill(),
            Children      =
            {
                new SLabel("ETGMod <color=#ffffffff>" + ETGMod.BaseUIVersion + "</color>")
                {
                    Foreground    = Color.gray,
                    OnUpdateStyle = elem => elem.Size.x = elem.Parent.InnerSize.x
                },

                (DisabledListGroup = new SGroup{
                    Background = new Color(0f, 0f, 0f, 0f),
                    AutoLayout = (SGroup g) => g.AutoLayoutVertical,
                    ScrollDirection = SGroup.EDirection.Vertical,
                    OnUpdateStyle = delegate(SElement elem){
                        elem.Size = new Vector2(
                            Mathf.Max(288f, elem.Parent.InnerSize.x * 0.25f),
                            Mathf.Max(256f, elem.Parent.InnerSize.y * 0.2f)
                            );
                        elem.Position = new Vector2(0f, elem.Parent.InnerSize.y - elem.Size.y);
                    },
                }),
                new SLabel("DISABLED MODS")
                {
                    Foreground    = Color.gray,
                    OnUpdateStyle = delegate(SElement elem){
                        elem.Position = new Vector2(DisabledListGroup.Position.x, DisabledListGroup.Position.y - elem.Backend.LineHeight - 4f);
                    },
                },

                (ModListGroup = new SGroup{
                    Background = new Color(0f, 0f, 0f, 0f),
                    AutoLayout = (SGroup g) => g.AutoLayoutVertical,
                    ScrollDirection = SGroup.EDirection.Vertical,
                    OnUpdateStyle = delegate(SElement elem){
                        elem.Position = new Vector2(0f, elem.Backend.LineHeight * 2.5f);
                        elem.Size = new Vector2(
                            DisabledListGroup.Size.x,
                            DisabledListGroup.Position.y - elem.Position.y - elem.Backend.LineHeight * 1.5f
                            );
                    },
                }),
                new SLabel("ENABLED MODS")
                {
                    Foreground    = Color.gray,
                    OnUpdateStyle = delegate(SElement elem){
                        elem.Position = new Vector2(ModListGroup.Position.x, ModListGroup.Position.y - elem.Backend.LineHeight - 4f);
                    },
                },

                /*  (ModOnlineListGroup = new SGroup {
                 *    Background = new Color(0f, 0f, 0f, 0f),
                 *    AutoLayout = (SGroup g) => g.AutoLayoutVertical,
                 *    ScrollDirection = SGroup.EDirection.Vertical,
                 *    OnUpdateStyle = delegate (SElement elem) {
                 *        elem.Position = new Vector2(ModOnlineListGroup.Size.x + 4f, ModListGroup.Position.y);
                 *        elem.Size = new Vector2(
                 *            DisabledListGroup.Size.x,
                 *            elem.Parent.InnerSize.y - elem.Position.y
                 *        );
                 *    },
                 * }),
                 * new SLabel("LASTBULLET MODS") {
                 *    Foreground = Color.gray,
                 *    OnUpdateStyle = delegate (SElement elem) {
                 *        elem.Position = new Vector2(ModOnlineListGroup.Position.x, ModListGroup.Position.y - elem.Backend.LineHeight - 4f);
                 *    },
                 * },*/
            }
        };
    }
コード例 #9
0
        public static void Init()
        {
            if (Root != null)
            {
                return;
            }

            Root = SGUIRoot.Setup();
            GameObject.Find("SGUI Root").tag = "DoNotPause";

            ModEvents.OnUpdate += Update;
            SceneManager.activeSceneChanged += (sceneA, sceneB) => {
                ShowGameGUI();
            };

            Root.Background = new Color(
                0.17f,
                0.21f,
                0.23f,
                Root.Background.a
                );

            MainGroup = new SGroup()
            {
                Visible = false,

                OnUpdateStyle = elem => {
                    elem.Fill(0);
                },

                Children =
                {
                    new SLabel($"Yooka-Laylee Mod {ModAPI.UIVersion}")
                    {
                        Background = HeaderBackground,
                        Foreground = HeaderForeground
                    },

                    new SLabel("Help:")
                    {
                        OnUpdateStyle = elem =>          {
                            elem.Position = new Vector2(elem.Previous.Position.x, elem.Previous.Position.y + elem.Previous.Size.y + Padding);
                        }
                    },

                    (HelpGroup = new SGroup              {
                        ScrollDirection = SGroup.EDirection.Vertical,
                        AutoLayout = elem => elem.AutoLayoutVertical,
                        AutoLayoutPadding = PaddingColumnElements,
                        OnUpdateStyle = elem =>          {
                            elem.Position = new Vector2(elem.Previous.Position.x, elem.Previous.Position.y + elem.Previous.Size.y + Padding);
                            elem.Size = new Vector2(512, elem.Parent.Size.y - elem.Position.y - Padding);
                        },
                        With =                           { new SGroupForceScrollModifier()            },
                        Children =
                        {
                            new SGroup()
                            {
                                Background = new Color(0f, 0f, 0f, 0f),
                                AutoLayout = elem => elem.AutoLayoutVertical,
                                AutoLayoutVerticalStretch = false,
                                AutoLayoutPadding = 0f,
                                OnUpdateStyle = SegmentGroupUpdateStyle,
                                Children =
                                {
                                    new SLabel("Debug Log:")
                                    {
                                        Background = HeaderBackground,
                                        Foreground = HeaderForeground
                                    },
                                    new SLabel("Keyboard:")
                                    {
                                        Background = HeaderBackground,
                                        Foreground = HeaderForeground
                                    },
                                    new SLabel("HOME / POS1: Toggle log"),
                                    new SLabel("PAGE UP / DOWN: Scroll")
                                }
                            },

                            new SGroup()
                            {
                                Background = new Color(0f, 0f, 0f, 0f),
                                AutoLayout = elem => elem.AutoLayoutVertical,
                                AutoLayoutVerticalStretch = false,
                                AutoLayoutPadding = 0f,
                                OnUpdateStyle = SegmentGroupUpdateStyle,
                                Children =
                                {
                                    new SLabel("Miscellaneous:")
                                    {
                                        Background = HeaderBackground,
                                        Foreground = HeaderForeground
                                    },
                                    new SLabel("Keyboard:")
                                    {
                                        Background = HeaderBackground,
                                        Foreground = HeaderForeground
                                    },
                                    new SLabel("F11: Toggle game GUI"),
                                }
                            }
                        }
                    }),

                    new SLabel("Settings:")
                    {
                        OnUpdateStyle = elem =>          {
                            elem.Position = new Vector2(elem.Previous.Previous.Position.x + elem.Previous.Size.x + Padding, elem.Previous.Previous.Position.y);
                        }
                    },

                    (SettingsGroup = new SGroup          {
                        ScrollDirection = SGroup.EDirection.Vertical,
                        AutoLayout = elem => elem.AutoLayoutVertical,
                        AutoLayoutPadding = PaddingColumnElements,
                        OnUpdateStyle = elem =>          {
                            elem.Position = new Vector2(elem.Previous.Position.x, elem.Previous.Position.y + elem.Previous.Size.y + Padding);
                            elem.Size = new Vector2(256, elem.Parent.Size.y - elem.Position.y - Padding);
                        },
                        With =                           { new SGroupForceScrollModifier()            },
                        Children =
                        {
                            new SGroup()
                            {
                                Background = new Color(0f, 0f, 0f, 0f),
                                AutoLayout = elem => elem.AutoLayoutVertical,
                                OnUpdateStyle = SegmentGroupUpdateStyle,
                                Children =
                                {
                                    new SLabel("YLMAPI-DEV TOOLS:")
                                    {
                                        Background = HeaderBackground,
                                        Foreground = HeaderForeground
                                    },

                                    new SButton("Clear loaded content mod cache")
                                    {
                                        Alignment = TextAnchor.MiddleLeft,
                                        OnClick = b =>   {
                                            ModContent.Cache.Clear();
                                        }
                                    },

                                    new SButton("Recreate content mod tree")
                                    {
                                        Alignment = TextAnchor.MiddleLeft,
                                        OnClick = b =>   {
                                            ModContent.Recrawl();
                                        }
                                    },

                                    new SButton("Patch content in scene")
                                    {
                                        Alignment = TextAnchor.MiddleLeft,
                                        OnClick = b =>   {
                                            ModContentPatcher.PatchContent(SceneManager.GetActiveScene()).StartGlobal();
                                        }
                                    },

                                    new SButton("Dump content in scene")
                                    {
                                        Alignment = TextAnchor.MiddleLeft,
                                        OnClick = b =>   {
                                            ModContentDumper.DumpContent(SceneManager.GetActiveScene()).StartGlobal();
                                        }
                                    }
                                }
                            },

                            new SGroup()
                            {
                                Background = new Color(0f, 0f, 0f, 0f),
                                AutoLayout = elem => elem.AutoLayoutVertical,
                                OnUpdateStyle = SegmentGroupUpdateStyle,
                                Children =
                                {
                                    new SLabel("General:")
                                    {
                                        Background = HeaderBackground,
                                        Foreground = HeaderForeground
                                    },

                                    new SButton("Show Game GUI")
                                    {
                                        Alignment = TextAnchor.MiddleLeft,
                                        With =           { new SCheckboxModifier()
                                                           {
                                                               GetValue = b => IsGameHUDVisible,
                                                               SetValue = (b, v) => {
                                                                   if (v)
                                                                   {
                                                                       ShowGameGUI();
                                                                   }
                                                                   else
                                                                   {
                                                                       HideGameGUI();
                                                                   }
                                                               }
                                                           } }
                                    },

                                    new SButton("Show Mod Log")
                                    {
                                        Alignment = TextAnchor.MiddleLeft,
                                        With =           { new SCheckboxModifier()
                                                           {
                                                               GetValue = b => LogGroup?.Visible ?? false,
                                                               SetValue = (b, v) => LogGroup.Visible = v
                                                           } }
                                    },

                                    new SButton("Fullscreen Log")
                                    {
                                        Alignment = TextAnchor.MiddleLeft,
                                        With =           { new SCheckboxModifier()
                                                           {
                                                               GetValue = b => IsLogBig,
                                                               SetValue = (b, v) => { IsLogBig = v; LogGroup?.UpdateStyle(); }
                                                           } }
                                    }
                                }
                            }
                        }
                    }),

                    new SLabel("Scenes:")
                    {
                        OnUpdateStyle = elem =>          {
                            elem.Position = new Vector2(elem.Previous.Previous.Position.x + elem.Previous.Size.x + Padding, elem.Previous.Previous.Position.y);
                        }
                    },

                    (ScenesGroup = new SGroup            {
                        ScrollDirection = SGroup.EDirection.Vertical,
                        AutoLayout = elem => elem.AutoLayoutVertical,
                        AutoLayoutPadding = Padding,
                        OnUpdateStyle = elem =>          {
                            elem.Position = new Vector2(elem.Previous.Position.x, elem.Previous.Position.y + elem.Previous.Size.y + Padding);
                            elem.Size = new Vector2(256, elem.Parent.Size.y - elem.Position.y - Padding);
                        },
                        With =                           { new SGroupForceScrollModifier()            }
                    }),
                }
            };

            LogGroup = new SGroup()
            {
                Visible           = false,
                ScrollDirection   = SGroup.EDirection.Vertical,
                AutoLayout        = elem => elem.AutoLayoutVertical,
                AutoLayoutPadding = 0f,

                OnUpdateStyle = elem => {
                    if (IsLogBig)
                    {
                        elem.Fill(0);
                    }
                    else
                    {
                        elem.Size     = new Vector2(512, 512);
                        elem.Position = elem.Root.Size - elem.Size;
                    }
                },

                Children =
                {
                    new SLabel($"Yooka-Laylee {File.ReadAllText(Path.Combine(Application.streamingAssetsPath, "subversion.txt")).Trim()}"),
                    new SLabel($"Yooka-Laylee Mod {ModAPI.UIVersion}"),
                    new SLabel("DEBUG LOG"),
                    new SLabel("Use HOME / POS 1 key on keyboard to hide / show."),
                    new SLabel("Use F2 to switch between cornered and full log."),
                    new SLabel("Use PAGE UP / DOWN to scroll."),
                    new SLabel(),
                    new SLabel("For all keybindings, hit F1."),
                    new SLabel()
                }
            };

            _ListScenes().StartGlobal();
        }
コード例 #10
0
 static void AddTriToGroup(ref SGroup group, int[] pGroupTriangleBuffer, int iTriIndex)
 {
     pGroupTriangleBuffer[group.iNrFaces + group.faceOffset] = iTriIndex;
     group.iNrFaces++;
 }
コード例 #11
0
ファイル: YLFreeCamera.cs プロジェクト: YLMAPI/YLMAPI
    public override void Init()
    {
        Instance = this;

        new SGroup()
        {
            Parent     = ModGUI.HelpGroup,
            Background = new Color(0f, 0f, 0f, 0f),
            AutoLayout = elem => elem.AutoLayoutVertical,
            AutoLayoutVerticalStretch = false,
            AutoLayoutPadding         = 0f,
            OnUpdateStyle             = ModGUI.SegmentGroupUpdateStyle,
            Children =
            {
                new SLabel("Magic Camera™:")
                {
                    Background = ModGUI.HeaderBackground,
                    Foreground = ModGUI.HeaderForeground
                },
                new SLabel("Special thanks to Shesez (Boundary Break)!")
                {
                    Background = ModGUI.HeaderBackground,
                    Foreground = ModGUI.HeaderForeground
                },

                new SLabel("Controller:")
                {
                    Background = ModGUI.HeaderBackground,
                    Foreground = ModGUI.HeaderForeground
                },
                new SLabel("Press L3 and R3 (into the two sticks) at the same time."),
                new SLabel("Movement:")
                {
                    Background = ModGUI.Header2Background,
                    Foreground = ModGUI.Header2Foreground
                },
                new SLabel("Left stick: First person movement"),
                new SLabel("Right stick: Rotate camera"),
                new SLabel("LB / L1: Move straight down"),
                new SLabel("RB / R1: Move straight up"),
                new SLabel("Speed manipulation:")
                {
                    Background = ModGUI.Header2Background,
                    Foreground = ModGUI.Header2Foreground
                },
                new SLabel("LT / L2: Reduce move speed"),
                new SLabel("RT / R2: Increase move speed"),
                new SLabel("LT + RT / L2 + R2: Reset move speed"),
                new SLabel("DPad left: Freeze game"),
                new SLabel("DPad right: Reset game speed"),
                new SLabel("LT + RT / L2 + R2: Reset move speed"),
                new SLabel("Other:")
                {
                    Background = ModGUI.Header2Background,
                    Foreground = ModGUI.Header2Foreground
                },
                new SLabel("B / Circle: Toggle info in bottom-right corner"),
                new SLabel("X / Square: Toggle game GUI / HUD"),
                new SLabel("Y / Triangle: Toggle neutral lighting"),

                new SLabel("Keyboard:")
                {
                    Background = ModGUI.HeaderBackground,
                    Foreground = ModGUI.HeaderForeground
                },
                new SLabel("Press F12."),
                new SLabel("Movement:")
                {
                    Background = ModGUI.Header2Background,
                    Foreground = ModGUI.Header2Foreground
                },
                new SLabel("WASD: First person movement"),
                new SLabel("R / F: Move straight down"),
                new SLabel("Q / E: Move straight up"),
                new SLabel("Mouse: Rotate camera"),
                new SLabel("Shift: Run"),
                new SLabel("Speed manipulation:")
                {
                    Background = ModGUI.Header2Background,
                    Foreground = ModGUI.Header2Foreground
                },
                new SLabel("1 / Scroll up: Reduce move* speed"),
                new SLabel("2 / Scroll down: Increase move* speed"),
                new SLabel("3 / Middle mouse button: Reset move* speed"),
                new SLabel("Hold control + scroll = modify game speed"),
                new SLabel("4: Reduce game speed"),
                new SLabel("5: Increase game speed"),
                new SLabel("6: Reset game speed"),
                new SLabel("7: Freeze game"),
                new SLabel("Other:")
                {
                    Background = ModGUI.Header2Background,
                    Foreground = ModGUI.Header2Foreground
                },
                new SLabel("F3: Toggle info in bottom-right corner"),
                new SLabel("F4: Toggle neutral lighting")
            }
        };

        GUISettingsGroup = new SGroup()
        {
            Parent        = ModGUI.SettingsGroup,
            Background    = new Color(0f, 0f, 0f, 0f),
            AutoLayout    = elem => elem.AutoLayoutVertical,
            OnUpdateStyle = ModGUI.SegmentGroupUpdateStyle,
            Children      =
            {
                new SLabel("Magic Camera™:")
                {
                    Background = ModGUI.HeaderBackground,
                    Foreground = ModGUI.HeaderForeground
                },

                new SButton("Show Camera Info")
                {
                    Alignment = TextAnchor.MiddleLeft,
                    With      = { new SCheckboxModifier()
                                  {
                                      GetValue = b => IsGUIVisible,
                                      SetValue = (b, v) => IsGUIVisible = v
                                  } }
                },

                new SButton("Neutral Ambient Lighting")
                {
                    Alignment = TextAnchor.MiddleLeft,
                    With      = { new SCheckboxModifier()
                                  {
                                      GetValue = b => IsFullBright,
                                      SetValue = (b, v) => IsFullBright = v
                                  } }
                }
            }
        };

        GUIInfoGroup = new SGroup()
        {
            ScrollDirection   = SGroup.EDirection.Vertical,
            AutoLayout        = elem => elem.AutoLayoutVertical,
            AutoLayoutPadding = 0f,

            OnUpdateStyle = elem => {
                elem.Size     = new Vector2(256, elem.Backend.LineHeight * elem.Children.Count);
                elem.Position = elem.Root.Size - elem.Size;
            },

            Children =
            {
                new SLabel("MAGIC CAMERA™")
                {
                    Background = ModGUI.HeaderBackground,
                    Foreground = ModGUI.HeaderForeground
                },
                new SLabel("Press F1 to view controls."),
                new SLabel(),
                (GUIInfoGameSpeed = new SLabel()),
                (GUIInfoMoveSpeed = new SLabel()),
                new SLabel(),
                (GUIInfoSceneName = new SLabel()),
                (GUIInfoPosition = new SLabel()),
                (GUIInfoRotation = new SLabel()),
            }
        };


        ModInput.ButtonMap["FreeCam Toggle"] =
            input => Input.GetKey(KeyCode.F12) || (ModInput.GetButton("LS") && ModInput.GetButton("RS"));
        ModInput.ButtonMap["FreeCam GUI Toggle"] =
            input => Input.GetKey(KeyCode.F3) || ModInput.GetButton("B");
        ModInput.ButtonMap["FreeCam Game GUI Toggle Ext"] =
            input => ModInput.GetButton("X");

        ModInput.ButtonMap["FreeCam Light Toggle"] =
            input => Input.GetKey(KeyCode.F4) || ModInput.GetButton("Y");

        ModInput.ButtonMap["FreeCam Run"] =
            input => Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);

        ModInput.ButtonMap["FreeCam Internal Speed Switch"] =
            input => Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);

        ModInput.ButtonMap["FreeCam Internal Speed Reset"] =
            input => Input.GetMouseButton(2) || (ModInput.GetButton("LT") && ModInput.GetButton("RT"));
        ModInput.ButtonMap["FreeCam Move Speed Reset"] =
            input =>
            Input.GetKey(KeyCode.Alpha3) ||
            (!ModInput.GetButton("FreeCam Internal Speed Switch") && ModInput.GetButton("FreeCam Internal Speed Reset"));
        ModInput.ButtonMap["FreeCam Game Speed Reset"] =
            input =>
            Input.GetKey(KeyCode.Alpha6) || ModInput.GetButton("DPadRight") ||
            (ModInput.GetButton("FreeCam Internal Speed Switch") && ModInput.GetButton("FreeCam Internal Speed Reset"));
        ModInput.ButtonMap["FreeCam Game Speed Freeze"] =
            input => Input.GetKey(KeyCode.Alpha7) || ModInput.GetButton("DPadLeft");

        ModInput.AxisMap["FreeCam Y Movement"] =
            input =>
            Input.GetKey(KeyCode.F) || Input.GetKey(KeyCode.Q) || ModInput.GetButton("LB") ? -1f :
            Input.GetKey(KeyCode.R) || Input.GetKey(KeyCode.E) || ModInput.GetButton("RB") ?  1f :
            0f;

        ModInput.AxisMap["FreeCam Internal Speed"] =
            input =>
            Input.mouseScrollDelta.y +
            (ModInput.GetButton("LT") ? -0.4f : ModInput.GetButton("RT") ? 0.4f : 0f);
        ModInput.AxisMap["FreeCam Move Speed"] =
            input =>
            (Input.GetKey(KeyCode.Alpha1) ? -0.4f : Input.GetKey(KeyCode.Alpha2) ? 0.4f : 0f) +
            (!ModInput.GetButton("FreeCam Internal Speed Switch") ? ModInput.GetAxis("FreeCam Internal Speed") : 0f);
        ModInput.AxisMap["FreeCam Game Speed"] =
            input =>
            (ModInput.GetButton("DPadUp") ? 0.4f : ModInput.GetButton("DPadDown") ? -0.4f : 0f) +
            (Input.GetKey(KeyCode.Alpha4) ? -0.4f : Input.GetKey(KeyCode.Alpha5) ? 0.4f : 0f) +
            (ModInput.GetButton("FreeCam Internal Speed Switch") ? ModInput.GetAxis("FreeCam Internal Speed") : 0f);

        SceneManager.activeSceneChanged += (sceneA, sceneB) => {
            WasFullBright = IsFullBright = false;
        };

        ModEvents.OnUpdate += Update;
        // Only make the game use the player input when the free cam is disabled.
        ModEvents.OnPlayerInputUpdate += input => !IsEnabled;
    }
コード例 #12
0
ファイル: ETGModConsole.cs プロジェクト: thswogur00/ETGMod
    public void ShowAutocomplete()
    {
        if (GUI.Children.Count >= 3)
        {
            return;
        }
        STextField field = (STextField)GUI[1];

        // AUTO COMPLETIONATOR 3000
        // (by Zatherz)
        //
        // TODO: Make Tab autocomplete to the shared part of completions
        // TODO: AutocompletionRule interface and class per rule?
        // Create an input array by splitting it on spaces
        string inputtext = field.Text.Substring(0, field.CursorIndex);

        string[] input      = SplitArgs(inputtext);
        string   otherinput = string.Empty;

        if (field.CursorIndex < field.Text.Length)
        {
            otherinput = field.Text.Substring(field.CursorIndex + 1);
        }
        // Get where the command appears in the path so that we know where the arguments start
        int           commandindex = Commands.GetFirstNonUnitIndexInPath(input);
        List <string> pathlist     = new List <string>();

        for (int i = 0; i < input.Length - (input.Length - commandindex); i++)
        {
            pathlist.Add(input[i]);
        }

        string[] path = pathlist.ToArray();

        ConsoleCommandUnit unit = Commands.GetUnit(path);
        // Get an array of available completions
        int matchindex = input.Length - path.Length;

        /*
         *      HACK! blame Zatherz
         *      matchindex will be off by +1 if the current keyword your cursor is on isn't empty
         *      this will check if there are no spaces on the left on the cursor
         *      and if so, decrease matchindex
         *      if there *are* spaces on the left of the cursor, that means the current
         *      "token" the cursor is on is an empty string, so that doesn't have any problems
         *      Hopefully this is a good enough explanation, if not, ping @Zatherz on Discord
         */

        string matchkeyword = string.Empty;

        if (!inputtext.EndsWithInvariant(" "))
        {
            matchindex--;
            matchkeyword = input[input.Length - 1];
        }

        string[] completions = unit.Autocompletion.Match(Math.Max(matchindex, 0), matchkeyword);

        if (completions == null || completions.Length == 0)
        {
            Debug.Log("ETGModConsole: no completions available (match returned null)");
        }
        else if (completions.Length == 1)
        {
            if (path.Length > 0)
            {
                field.Text = string.Join(" ", path) + " " + completions[0] + " " + otherinput;
            }
            else
            {
                field.Text = completions[0] + " " + otherinput;
            }

            field.MoveCursor(field.Text.Length);
        }
        else if (completions.Length > 1)
        {
            SGroup hints = new SGroup {
                Parent          = GUI,
                AutoLayout      = (SGroup g) => g.AutoLayoutVertical,
                ScrollDirection = SGroup.EDirection.Vertical,
                OnUpdateStyle   = delegate(SElement elem) {
                    elem.Size     = new Vector2(elem.Parent.InnerSize.x, Mathf.Min(((SGroup)elem).ContentSize.y, 160f));
                    elem.Position = GUI[1].Position - new Vector2(0f, elem.Size.y + 4f);
                }
            };

            for (int i = 0; i < completions.Length; i++)
            {
                hints.Children.Add(new SLabel(completions[i]));
            }
        }
    }
コード例 #13
0
        public Console()
        {
            AddDefaultCommands();

            Window = new SGroup {
                Background = new Color(0, 0f, 0f, 0.8f),
                Visible    = false,

                OnUpdateStyle = elem => {
                    elem.Fill(0);
                },

                Children =
                {
                    new SGroup { // OutputBox
                        Background      = new Color(0,                                0,    0,    0),
                        AutoLayout      = (self) => self.AutoLayoutVertical,
                        ScrollDirection = SGroup.EDirection.Vertical,
                        OnUpdateStyle   = (elem) => {
                            elem.Fill(0);
                            elem.Size                -= new Vector2(0,                    elem.Backend.LineHeight);
                        },
                        Children                     =
                        {
                            new SLabel($"SemiLoader v{Semi.SemiLoader.VERSION}")
                            {
                                Foreground           = new Color(0 / 255f,                161 / 255f,              231 / 255f)
                            }
                        },
                    },
                    new SGroup { // AutocompleteBox
                        Background      = new Color(0.2f,                          0.2f, 0.2f, 0.9f),
                        AutoLayout      = (self) => self.AutoLayoutVertical,
                        ScrollDirection = SGroup.EDirection.Vertical,
                        OnUpdateStyle   = (elem) => {
                            elem.Size.x     = elem.Parent.InnerSize.x;
                            elem.Size.y     = elem.Parent.InnerSize.y / 10; // 10%
                            elem.Position.y = elem.Parent.InnerSize.y - elem.Parent[(int)WindowChild.InputBox].Size.y - elem.Size.y;
                        },
                        Children                     = {},
                    },
                    new STextField { // InputBox
                        OverrideTab                  = true,

                        OnUpdateStyle                = (elem) => {
                            elem.Size.x     = elem.Parent.InnerSize.x;
                            elem.Position.x =          0;
                            elem.Position.y = elem.Parent.InnerSize.y - elem.Size.y;
                        },

                        OnKey                        = (self,                             is_down,    key) => {
                            if (!is_down || key == KeyCode.Return || key == KeyCode.KeypadEnter)
                            {
                                return;
                            }

                            switch (key)
                            {
                            case KeyCode.Home:
                                self.MoveCursor(0);
                                break;

                            case KeyCode.Escape:
                            case KeyCode.F2:
                            case KeyCode.BackQuote:
                                Hide();
                                break;

                            case KeyCode.Tab:
                                break;
                                // TODO @console probably not necessary but might be nice?
                                DoAutoComplete();
                                break;

                            case KeyCode.UpArrow:
                                History.MoveUp();
                                self.MoveCursor(History.Entry.Length);
                                break;

                            case KeyCode.DownArrow:
                                History.MoveDown();
                                self.MoveCursor(History.Entry.Length);
                                break;

                            default:
                                History.LastEntry    = self.Text;
                                History.CurrentIndex = History.LastIndex;
                                break;
                            }

                            self.Text                = History.Entry;
                        },

                        OnSubmit                     = (elem,                             text) => {
                            if (text.Trim().Length == 0)
                            {
                                return;
                            }
                            History.Push();
                            ExecuteCommandAndPrintResult(text);
                        },
                    }
                }
            };

            _Executor = new Parser.Executor((name, args, history_index) => {
                Command cmd = ResolveCommand(name);
                if (history_index == null && History.LastIndex > 0)
                {
                    history_index = History.LastIndex - 1;
                }
                return(cmd.Run(args, history_index));
            });

            NormalHistory = new CommandHistory(_Executor, _Parser);
        }
コード例 #14
0
        private SGroup _CreateNotificationSGroup(Notification notif)
        {
            var sgroup = new NotificationSGroup {
                Visible    = true,
                Background = notif.BackgroundColor,

                OnUpdateStyle = (obj) => {
                    var group = (NotificationSGroup)obj;

                    if (group.Decaying)
                    {
                        return;
                    }

                    if (obj.Previous == null && !group.Displayed)
                    {
                        group.Displayed = true;
                        var seq = new SNotificationAnimationSequence(
                            IdleDuration,
                            FadeoutDuration,
                            DecayDuration,
                            this
                            );
                        group.Modifiers.Add(seq);
                        seq.Start();
                    }

                    float ysize = ((SGroup)obj).AutoLayoutPadding;
                    for (int i = 0; i < obj.Children.Count; i++)
                    {
                        var child = obj.Children[i];
                        if (child is SGroup)
                        {
                            child.UpdateStyle();
                            ysize += child.Size.y;
                        }
                    }

                    float y;
                    if (obj.Previous != null)
                    {
                        y = obj.Previous.Position.y - NotificationPadding;
                    }
                    else
                    {
                        y = Screen.height;
                    }

                    y -= obj.Size.y;

                    obj.Size     = new Vector2(NotificationSpaceWidth, ysize);
                    obj.Position = new Vector2(obj.Position.x, y);
                },

                Children = { }
            };

            if (notif.Image != null)
            {
                sgroup.Children.Add(new SImage(notif.Image)
                {
                    OnUpdateStyle = (obj) => {
                        var image  = (SImage)obj;
                        image.Size = new Vector2(image.Texture.width, image.Texture.height);
                    }
                });
            }

            var inner_group = new SGroup {
                Background = new Color(0f, 0f, 0f, 0f),
                AutoLayout = (self) => self.AutoLayoutVertical,
                Children   =
                {
                    new SLabel(notif.Title)
                    {
                        Foreground = notif.TitleColor
                    },
                    new SLabel(notif.Content)
                    {
                        Foreground = notif.ContentColor
                    }
                },
                OnUpdateStyle = (obj) => {
                    float ysize = ((SGroup)obj).AutoLayoutPadding;
                    for (int i = 0; i < obj.Children.Count; i++)
                    {
                        var child = obj.Children[i];
                        if (child is SLabel)
                        {
                            ysize += obj.Backend.MeasureText(((SLabel)child).Text, obj.Size.x).y;
                            ysize += ((SGroup)obj).AutoLayoutPadding;
                        }
                    }

                    if (notif.Image != null)
                    {
                        obj.Position = new Vector2(notif.Image.width, 0);
                        obj.Size     = new Vector2(obj.Parent.Size.x - notif.Image.width, ysize);
                    }
                    else
                    {
                        obj.Position = new Vector2(0, 0);
                        obj.Size     = new Vector2(obj.Parent.Size.x, ysize);
                    }
                },
                Size = new Vector2(NotificationSpaceWidth, NotificationHeight)
            };

            sgroup.Children.Add(inner_group);
            inner_group.UpdateStyle();
            sgroup.UpdateStyle();

            sgroup.Modifiers.Add(new SSlideInHorizontallyAnimation(
                                     SlideOffset,
                                     SlideDuration
                                     ));

            return(sgroup);
        }
コード例 #15
0
ファイル: Extensions.cs プロジェクト: declard/Dotnet.Func.Ext
 public static type Sub <type, mark>(this SGroup <type, Additive <mark> > group, type l, type r) => group.Add(l, group.Neg(r));
コード例 #16
0
ファイル: Extensions.cs プロジェクト: declard/Dotnet.Func.Ext
 public static type Div <type, mark>(this SGroup <type, Multiplicative <mark> > group, type l, type r) => group.Mul(l, group.Recip(r));
コード例 #17
0
ファイル: ETGModConsole.cs プロジェクト: thswogur00/ETGMod
    public override void Start()
    {
        // GUI
        GUI = new SGroup {
            Visible       = false,
            OnUpdateStyle = (SElement elem) => elem.Fill(),
            Children      =
            {
                new SGroup     {
                    Background      = new Color(0f, 0f, 0f, 0f),
                    AutoLayout      = (SGroup g) => g.AutoLayoutVertical,
                    ScrollDirection = SGroup.EDirection.Vertical,
                    OnUpdateStyle   = delegate(SElement elem) {
                        elem.Fill();
                        elem.Size -= new Vector2(0f, elem.Backend.LineHeight - 4f); // Command line input space
                    },
                    Children =
                    {
                        new SLabel("ETGMod <color=#ffffffff>" + ETGMod.BaseUIVersion + "</color>")
                        {
                            Foreground = Color.gray
                        },
                        new SLabel("Console backend <color=#ffffffff>R" + REVISION + "</color>")
                        {
                            Foreground = Color.gray
                        },
                        new SLabel("THIS CONSOLE IS <color=#ff0000ff>WORK IN PROGRESS</color>."),
                        new SLabel("Use <color=#ffffffff>help</color> to find out how to use the console.")
                        {
                            Foreground = Color.gray
                        },
                        new SLabel(),
                        //new SLabel("Wee this text gets randomized in order!") {
                        //   With = {
                        //       new SRandomLabelModifier()
                        //   }
                        //},
                        // new SLabel(),
                    }
                },
                new STextField {
                    OnUpdateStyle = delegate(SElement elem){
                        elem.Size.x     = elem.Parent.InnerSize.x;
                        elem.Position.x = 0f;
                        elem.Position.y = elem.Parent.InnerSize.y - elem.Size.y;
                    },
                    OnTextUpdate = delegate(STextField elem, string prevText){
                        HideAutocomplete();
                    },
                    OverrideTab = true,
                    OnKey       = delegate(STextField field, bool keyDown, KeyCode keyCode) {
                        if (!keyDown)
                        {
                            return;
                        }
                        if (keyCode == KeyCode.Escape || keyCode == KeyCode.F2 || keyCode == KeyCode.Slash || keyCode == KeyCode.BackQuote)
                        {
                            ETGModGUI.CurrentMenu = ETGModGUI.MenuOpened.None;
                            return;
                        }
                        if (keyCode == KeyCode.Tab)
                        {
                            ShowAutocomplete();
                            return;
                        }
                    },
                    OnSubmit = delegate(STextField elem, string text){
                        if (text.Length == 0)
                        {
                            return;
                        }
                        ParseCommand(text);
                        if (_CloseConsoleOnCommand)
                        {
                            ETGModGUI.CurrentMenu = ETGModGUI.MenuOpened.None;
                        }
                    }
                }
            }
        };

        // GLOBAL NAMESPACE
        Commands
        .AddUnit("help", delegate(string[] args) {
            List <List <string> > paths = Commands.ConstructPaths();
            for (int i = 0; i < paths.Count; i++)
            {
                Log(string.Join(" ", paths[i].ToArray()));
            }
        })
        .AddUnit("exit", (string[] args) => ETGModGUI.CurrentMenu = ETGModGUI.MenuOpened.None)
        .AddUnit("screenshake", SetShake)
        .AddUnit("echo", Echo)
        .AddUnit("tp", Teleport)
        .AddUnit("character", SwitchCharacter)
        .AddUnit("clear", (string[] args) => GUI[0].Children.Clear())
        .AddUnit("godmode", godmode)        // {
        //   GameManager.Instance.PrimaryPlayer.healthHaver.IsVulnerable = SetBool(args, GameManager.Instance.PrimaryPlayer.healthHaver.IsVulnerable);
        // GameManager.Instance.PrimaryPlayer.healthHaver.IsVulnerable = SetBool(args, GameManager.Instance.PrimaryPlayer.healthHaver.IsVulnerable); delegate(string[] args
        // })
        .AddGroup("spawn", Spawn, _SpawnAutocompletionSettings);

        // SPAWN NAMESAPCE
        Commands.GetGroup("spawn")
        .AddUnit("chest", SpawnChest)
        .AddUnit("all", SpawnAll);

        // GIVE NAMESPACE
        Commands.AddGroup("give", GiveItem, _GiveAutocompletionSettings);

        Commands.GetGroup("give")
        .AddGroup("all", (string[] args) => {
            foreach (string id in Game.Items.IDs)
            {
                if (id != "gungeon:cell_key" /* (bugged!) */)
                {
                    Game.PrimaryPlayer.GiveItem(id);
                }
            }
        });

        // GIVE ALL NAMESPACE
        Commands.GetGroup("give").GetGroup("all")
        .AddUnit("guns", (string[] args) => {
            foreach (string id in Game.Items.IDs)
            {
                if (ETGMod.Databases.Items[id] is Gun)
                {
                    Game.PrimaryPlayer.GiveItem(id);
                }
            }
        })
        .AddUnit("passives", (string[] args) => {
            foreach (string id in Game.Items.IDs)
            {
                if (ETGMod.Databases.Items[id] is PassiveItem)
                {
                    Game.PrimaryPlayer.GiveItem(id);
                }
            }
        })
        .AddUnit("actives", (string[] args) => {
            foreach (string id in Game.Items.IDs)
            {
                if (ETGMod.Databases.Items[id] is PlayerItem)
                {
                    Game.PrimaryPlayer.GiveItem(id);
                }
            }
        });

        // STAT NAMESPACE
        Commands.AddGroup("stat");

        Commands.GetGroup("stat")
        .AddUnit("get", StatGet, _StatAutocompletionSettings)
        .AddGroup("set", StatSetCurrentCharacter, _StatAutocompletionSettings)
        .AddUnit("mod", StatMod, _StatAutocompletionSettings)
        .AddUnit("list", StatList);

        Commands.GetGroup("stat").GetGroup("set")
        .AddUnit("session", StatSetSession, _StatAutocompletionSettings);

        // ROLL NAMESPACE
        Commands.AddGroup("roll");

        Commands.GetGroup("roll")
        .AddUnit("distance", DodgeRollDistance)
        .AddUnit("speed", DodgeRollSpeed);

        // TEST NAMESPACE
        Commands.AddUnit("test", new ConsoleCommandGroup());

        Commands.GetGroup("test")
        .AddGroup("resources")
        .AddUnit("skiplevel", delegate(string[] args) {
            Pixelator.Instance.FadeToBlack(0.5f, false, 0f);
            GameManager.Instance.DelayedLoadNextLevel(0.5f);
        }).AddUnit("charselect", delegate(string[] args) {
            Pixelator.Instance.FadeToBlack(0.5f, false, 0f);
            GameManager.Instance.DelayedLoadCharacterSelect(0.5f);
        });

        //// TEST.RESOURCES NAMESPACE
        Commands.GetGroup("test").GetGroup("resources")
        .AddUnit("load", ResourcesLoad);

        // DUMP NAMESPACE
        Commands.AddUnit("dump", new ConsoleCommandGroup());

        Commands.GetGroup("dump")
        .AddGroup("sprites", (args) => SetBool(args, ref ETGMod.Assets.DumpSprites))
        .AddUnit("packer", (args) => ETGMod.Assets.Dump.DumpPacker())
        .AddUnit("synergies", DumpSynergies)
        .AddUnit("pickups", DumpPickups);

        Commands.GetGroup("dump").GetGroup("sprites")
        .AddUnit("metadata", (args) => SetBool(args, ref ETGMod.Assets.DumpSpritesMetadata));

        // CONF NAMESPACE
        Commands.AddGroup("conf");

        Commands.GetGroup("conf")
        .AddUnit("close_console_on_command", (args) => SetBool(args, ref _CloseConsoleOnCommand))
        .AddUnit("cut_input_focus_on_command", (args) => SetBool(args, ref _CutInputFocusOnCommand))
        .AddUnit("enable_damage_indicators", (args) => SetBool(args, ref ETGModGUI.UseDamageIndicators))
        .AddUnit("match_contains", (args) => SetBool(args, ref AutocompletionSettings.MatchContains))
        .AddUnit("enable_stat_set", (args) => SetBool(args, ref StatSetEnabled))
        .AddUnit("player", (args) => ETGMod.Player.PlayerReplacement    = args.Length == 1 ? args[0] : null)
        .AddUnit("player_coop", (args) => ETGMod.Player.CoopReplacement = args.Length == 1 ? args[0] : null);
    }
コード例 #18
0
        /// <summary>
        /// this version of Mikktspace only deals with triangles
        /// in order to save sometime in moving the code over to c#
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static bool genTangSpace(ref SMikkTSpaceContext context, float fAngularThreshold)
        {
            int[]      piTriListIn            = null;
            int[]      piGroupTrianglesBuffer = null;
            STriInfo[] pTriInfos = null;
            SGroup[]   pGroups   = null;
            STSpace[]  psTspace  = null;

            int   iNrTrianglesIn = 0, f = 0, t = 0, i = 0;
            int   iNrTSPaces = 0, iNrMaxGroups = 0;
            int   iNrActiveGroups = 0, index = 0;
            int   iNrFaces  = context.m_pInterface.m_getNumFaces(ref context);
            float fThresCos = (float)Math.Cos((fAngularThreshold * ((float)Math.PI / 180.0f)));

            for (f = 0; f < iNrFaces; f++)
            {
                int verts = context.m_pInterface.m_getNumVerticesOfFace(ref context, f);
                if (verts == 3)
                {
                    iNrTrianglesIn++;
                }
            }
            if (iNrTrianglesIn <= 0)
            {
                return(false);
            }

            piTriListIn = new int[3 * iNrTrianglesIn];
            pTriInfos   = new STriInfo[iNrTrianglesIn];

            iNrTSPaces = GenerateInitialVerticesIndexList(ref pTriInfos, piTriListIn, ref context, iNrTrianglesIn);

            GenerateSharedVerticesIndexList(piTriListIn, ref context, iNrTrianglesIn);

            InitTriInfo(ref pTriInfos, piTriListIn, ref context, iNrTrianglesIn);

            iNrMaxGroups = iNrTrianglesIn * 3;
            pGroups      = new SGroup[iNrMaxGroups];

            for (f = 0; f < iNrMaxGroups; f++)
            {
                pGroups[f] = new SGroup();
            }

            piGroupTrianglesBuffer = new int[iNrTrianglesIn * 3];

            try
            {
                iNrActiveGroups = Build4RuleGroups(ref pTriInfos, ref pGroups, piGroupTrianglesBuffer, piTriListIn, iNrTrianglesIn);

                psTspace = new STSpace[iNrTSPaces];
                for (t = 0; t < iNrTSPaces; t++)
                {
                    psTspace[t].vOs.X = 1.0f;
                    psTspace[t].fMagS = 1.0f;
                    psTspace[t].vOt.Y = 1.0f;
                    psTspace[t].fMagT = 1.0f;
                }

                GenerateTSpaces(ref psTspace, ref pTriInfos, pGroups, iNrActiveGroups, piTriListIn, piGroupTrianglesBuffer, fThresCos, ref context);

                index = 0;
                for (f = 0; f < iNrFaces; f++)
                {
                    int verts = context.m_pInterface.m_getNumVerticesOfFace(ref context, f);
                    if (verts != 3)
                    {
                        continue;
                    }

                    for (i = 0; i < verts; ++i)
                    {
                        var     pSpace = psTspace[index];
                        float[] tang   = new float[] { pSpace.vOs.X, pSpace.vOs.Y, pSpace.vOs.Z };
                        float[] bitang = new float[] { pSpace.vOt.X, pSpace.vOt.Y, pSpace.vOt.Z };
                        context.m_pInterface.m_setTSpace(ref context, tang, bitang, pSpace.fMagS, pSpace.fMagT, pSpace.bOrient, f, i);
                        context.m_pInterface.m_setTSpaceBasic(ref context, tang, pSpace.bOrient ? 1 : -1, f, i);
                        ++index;
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            return(true);
        }
コード例 #19
0
        /// <summary>
        /// Used to log messages. messages can have the mod name, mod icon, both, or none in front.
        /// if color is set to null, messege color will be set to white
        /// note that modifiers are applied the sGroup children, not to the sGroup. if you want to change/add modifiers to the sGroup, use the returned sGroup
        /// n order to log an image in your text, you do "@(embedded file path, sizemult)" in your text, sizemult is not required, will default to 1.
        /// </summary>
        /// <param name="msg">the object or string you want to log</param>
        /// <param name="modifiers">an array of Selement modifiers to be added to each element logged</param>
        /// <param name="col">text color in unity Color32 or Color</param>
        /// <param name="HaveModName">whether your log messege will have the mod name at the front</param>
        /// <param name="HaveModIcon">whether your logged messege will have your mod icon at the front</param>
        public static SGroup Log(object msg, Color32?col = null, bool HaveModName = false, bool HaveModIcon = false, SModifier[] modifiers = null)
        {
            //in your module outside of methods you need:
            // public static ETGModuleMetadata metadata = new ETGModuleMetadata();

            //then in your modules init you need:
            // metadata = this.Metadata;
            Color color = Color.white;

            if (col != null)
            {
                color = col.Value;
            }
            string message = msg.ToString();

            SGroup sGroup = new SGroup();

            sGroup.AutoGrowDirection = SGroup.EDirection.Vertical;
            sGroup.AutoLayout        = (SGroup g) => g.AutoLayoutHorizontal;
            sGroup.OnUpdateStyle     = delegate(SElement elem)
            {
                elem.Fill();
            };
            sGroup.AutoLayoutVerticalStretch   = false;
            sGroup.AutoLayoutHorizontalStretch = false;
            sGroup.GrowExtra         = Vector2.zero;
            sGroup.ContentSize       = Vector2.zero;
            sGroup.AutoLayoutPadding = 0;
            sGroup.Background        = Color.clear;

            if (File.Exists(Initialisation.metadata.Archive))
            {
                if (HaveModIcon)
                {
                    SImage icon = new SImage(Initialisation.metadata.Icon);
                    sGroup.Children.Add(icon);
                }
            }
            if (HaveModName)
            {
                LogLabel modname = new LogLabel(Initialisation.metadata.Name + ": ");
                modname.Colors[0] = color;
                sGroup.Children.Add(modname);
            }
            string[] split = Regex.Split(message, "(@\\(.+?\\))");
            foreach (string item in split)
            {
                if (item.StartsWith("@("))
                {
                    string   image    = item.TrimStart('@', '(').TrimEnd(')');
                    string[] sizeMult = image.Split(',');
                    image = sizeMult[0];
                    float SizeMultButForReal = 1;

                    if (sizeMult.Length > 1)
                    {
                        if (sizeMult[1] != null && sizeMult[1] != "" && sizeMult[1] != " ")
                        {
                            SizeMultButForReal = float.Parse(sizeMult[1]);
                        }
                    }

                    string    extension = !image.EndsWith(".png") ? ".png" : "";
                    string    path      = image + extension;
                    Texture2D tex       = GetTextureFromResource(path);
                    TextureScale.Point(tex, Mathf.RoundToInt(tex.width * SizeMultButForReal), Mathf.RoundToInt(tex.height * SizeMultButForReal));

                    SImage img = new SImage(tex);
                    sGroup.Children.Add(img);
                    var idx = sGroup.Children.IndexOf(img);
                }
                else
                {
                    LogLabel label = new LogLabel(item);
                    label.Colors[0]  = color;
                    label.Background = Color.clear;
                    sGroup.Children.Add(label);
                }
                if (modifiers != null)
                {
                    for (int i = 0; i < modifiers.Length; i++)
                    {
                        sGroup.Children[sGroup.Children.Count - 1].Modifiers.Add(modifiers[i]);
                    }
                }
            }
            ETGModConsole.Instance.GUI[0].Children.Add(sGroup);

            ETGModConsole.Instance.GUI[0].UpdateStyle();
            return(sGroup);
        }
コード例 #20
0
        static void AssignRecur(int[] piTriListIn, int[] pGroupTriangleBuffer, ref STriInfo[] psTriInfos, int iMyTriIndex, ref SGroup pGroup)
        {
            int i        = -1;
            int iVertRep = pGroup.iVertex;

            if (piTriListIn[3 * iMyTriIndex] == iVertRep)
            {
                i = 0;
            }
            else if (piTriListIn[3 * iMyTriIndex + 1] == iVertRep)
            {
                i = 1;
            }
            else if (piTriListIn[3 * iMyTriIndex + 2] == iVertRep)
            {
                i = 2;
            }

            if (psTriInfos[iMyTriIndex].AssignedGroup[i] == pGroup)
            {
                return;
            }
            else if (psTriInfos[iMyTriIndex].AssignedGroup[i] != null)
            {
                return;
            }
            if ((psTriInfos[iMyTriIndex].iFlag & GROUP_WITH_ANY) != 0)
            {
                if (psTriInfos[iMyTriIndex].AssignedGroup[0] == null &&
                    psTriInfos[iMyTriIndex].AssignedGroup[1] == null &&
                    psTriInfos[iMyTriIndex].AssignedGroup[2] == null)
                {
                    psTriInfos[iMyTriIndex].iFlag &= (~ORIENT_PRESERVING);
                    psTriInfos[iMyTriIndex].iFlag |= (pGroup.bOrientPreservering ? ORIENT_PRESERVING : 0);
                }
            }
            {
                bool bOrient = (psTriInfos[iMyTriIndex].iFlag & ORIENT_PRESERVING) != 0;
                if (bOrient != pGroup.bOrientPreservering)
                {
                    return;
                }
            }

            AddTriToGroup(ref pGroup, pGroupTriangleBuffer, iMyTriIndex);
            psTriInfos[iMyTriIndex].AssignedGroup[i] = pGroup;

            {
                int neigh_indexL = psTriInfos[iMyTriIndex].faceNeighbors[i];
                int neigh_indexR = psTriInfos[iMyTriIndex].faceNeighbors[i > 0 ? (i - 1) : 2];
                if (neigh_indexL >= 0)
                {
                    AssignRecur(piTriListIn, pGroupTriangleBuffer, ref psTriInfos, neigh_indexL, ref pGroup);
                }
                if (neigh_indexR >= 0)
                {
                    AssignRecur(piTriListIn, pGroupTriangleBuffer, ref psTriInfos, neigh_indexR, ref pGroup);
                }
            }
        }
コード例 #21
0
        public Console()
        {
            AddDefaultCommands();

            Window = new SGroup {
                Visible = false,

                Background = new Color(0, 0f, 0f, 0.8f),

                OnUpdateStyle = elem => {
                    elem.Fill(0);
                },

                Children =
                {
                    new SGroup { // OutputBox
                        Background      = new Color(0,                             0,    0,    0),
                        AutoLayout      = (self) => self.AutoLayoutVertical,
                        ScrollDirection = SGroup.EDirection.Vertical,
                        OnUpdateStyle   = (elem) => {
                            elem.Fill(0);
                            elem.Size                -= new Vector2(0,                    elem.Backend.LineHeight);
                        },
                        Children                     =
                        {
                            new SLabel($"ModUntitled v{ModUntitled.VERSION}")
                            {
                                Foreground           = UnityUtil.NewColorRGB(0,               161,              231)
                            }
                        }
                    },
                    new SGroup { // AutocompleteBox
                        Background      = new Color(0.2f,                       0.2f, 0.2f, 0.9f),
                        AutoLayout      = (self) => self.AutoLayoutVertical,
                        ScrollDirection = SGroup.EDirection.Vertical,
                        OnUpdateStyle   = (elem) => {
                            elem.Size.x     = elem.Parent.InnerSize.x;
                            elem.Size.y     = elem.Parent.InnerSize.y / 10; // 10%
                            elem.Position.y = elem.Parent.InnerSize.y - elem.Parent[(int)WindowChild.InputBox].Size.y - elem.Size.y;
                        },
                        Children = {},
                        Visible  = false
                    },
                    new STextField { // InputBox
                        OverrideTab                  = true,

                        OnUpdateStyle                = (elem) => {
                            elem.Size.x     = elem.Parent.InnerSize.x;
                            elem.Position.x =          0;
                            elem.Position.y = elem.Parent.InnerSize.y - elem.Size.y;
                        },

                        OnKey                        = (self,                             is_down, key) => {
                            if (!is_down || key == KeyCode.Return || key == KeyCode.KeypadEnter)
                            {
                                return;
                            }

                            switch (key)
                            {
                            case KeyCode.Home:
                                self.MoveCursor(0);
                                break;

                            case KeyCode.Escape:
                            case KeyCode.F2:
                                Hide();
                                break;

                            case KeyCode.Tab:
                                DoAutoComplete();
                                break;

                            case KeyCode.UpArrow:
                                History.MoveUp();
                                self.MoveCursor(History.Entry.Length);
                                break;

                            case KeyCode.DownArrow:
                                History.MoveDown();
                                self.MoveCursor(History.Entry.Length);
                                break;

                            default:
                                History.LastEntry    = self.Text;
                                History.CurrentIndex = History.LastIndex;
                                break;
                            }

                            self.Text                = History.Entry;
                        },

                        OnSubmit                     = (elem,                             text) => {
                            if (text.Trim().Length == 0)
                            {
                                return;
                            }
                            History.Push();
                            //if (Console.LuaMode) {
                            //    Console.ExecuteLuaAndPrintResult(text);
                            //} else {
                            ExecuteCommandAndPrintResult(text);
                            //}
                        },
                    }
                }
            };

            // Console ctor code
            _Executor = new Parser.Executor((name, args, history_index) => {
                Command cmd = ResolveCommand(name);
                if (history_index == null && History.LastIndex > 0)
                {
                    history_index = History.LastIndex - 1;
                }
                return(cmd.Run(args, history_index));
            });

            NormalHistory = new CommandHistory(_Executor, _Parser);
            //LuaHistory = new CommandHistory(_Executor, _Parser);

            Logger.Info($"Console initialized");
        }