コード例 #1
0
ファイル: OptionsGraphics.cs プロジェクト: XZelnar/MicroWorld
        public override void Initialize()
        {
            ButtonsCount = FrameButtonsCount.One;

            #region MaxRes
            var a = GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.GetEnumerator();
            a.MoveNext();
            maxw = a.Current.Width;
            maxh = a.Current.Height;
            a.MoveNext();
            while (true)//DO NOT TOUCH THIS CYCLE OR ELSE MONO GETS SCARED!!!
            {
                try
                {
                    if (a.Current == null)
                        break;
                }
                catch { System.Threading.Thread.Sleep(1); }
                try
                {
                    if (a.Current == null)
                        break;
                }
                catch { break; }
                try
                {
                    if (a.Current.Width > maxw) maxw = a.Current.Width;
                    if (a.Current.Height > maxh) maxh = a.Current.Height;
                }
                catch { }
                a.MoveNext();
            }
            #endregion

            #region Resoulutions
            l_aspectRatio = new Elements.Label((int)Position.X + 5, (int)Position.Y + 5, "Aspect ratio:");
            l_aspectRatio.foreground = Color.White;
            controls.Add(l_aspectRatio);

            co_aspectRation = new Elements.ComboBox((int)Position.X + 150, (int)Position.Y + 7, 120, 24);
            co_aspectRation.onElementSelected += new Elements.ComboBox.ElementSelectedHandler(ar_onElementSelected);
            controls.Add(co_aspectRation);
            co_aspectRation.ItemsAdd("4*3");
            co_aspectRation.ItemsAdd("5*3");
            if (maxw >= 1280 && maxh >= 720) co_aspectRation.ItemsAdd("16*9");
            if (maxw >= 1280 && maxh >= 800) co_aspectRation.ItemsAdd("16*10");

            l_resolution = new Elements.Label((int)Position.X + 5, (int)Position.Y + 35, "Resolution:");
            l_resolution.foreground = Color.White;
            controls.Add(l_resolution);

            co_resolution = new Elements.ComboBox((int)Position.X + 150, (int)Position.Y + 37, 120, 24);
            co_resolution.onElementSelected += new Elements.ComboBox.ElementSelectedHandler(res_onElementSelected);
            controls.Add(co_resolution);

            cb_fullscreen = new Elements.CheckBox((int)Position.X + 5, (int)Position.Y + 65, 200, 20, "FullScreen", false);
            cb_fullscreen.foreground = Color.White;
            cb_fullscreen.onCheckedChanged += new Elements.CheckBox.CheckBoxCheckedHandler(cb_fullscreen_onCheckedChanged);
            controls.Add(cb_fullscreen);

            b_apply = new Elements.MenuButton((int)(Position.X + Size.X) - 120, (int)(Position.Y + Size.Y) - 23, 120, 23,
                "Apply");
            b_apply.Font = ButtonFont;
            b_apply.onClicked += new Elements.Button.ClickedEventHandler(apply_onClicked);
            controls.Add(b_apply);
            #endregion

            cb_drawgrig = new Elements.CheckBox((int)Position.X + 5, (int)Position.Y + 95, 200, 20, "Draw grid", false);
            cb_drawgrig.foreground = Color.White;
            cb_drawgrig.onCheckedChanged += new Elements.CheckBox.CheckBoxCheckedHandler(cb_drawgrig_onCheckedChanged);
            controls.Add(cb_drawgrig);

            cb_warning = new Elements.CheckBox((int)Position.X + 5, (int)Position.Y + 125, 200, 20, "Show intro warning", false);
            cb_warning.foreground = Color.White;
            cb_warning.onCheckedChanged += new Elements.CheckBox.CheckBoxCheckedHandler(cb_warning_onCheckedChanged);
            controls.Add(cb_warning);

            base.Initialize();
        }
コード例 #2
0
ファイル: OptionsGraphics.cs プロジェクト: XZelnar/MicroWorld
        public override void Initialize()
        {
            ButtonsCount = FrameButtonsCount.One;

            #region MaxRes
            var a = GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.GetEnumerator();
            a.MoveNext();
            maxw = a.Current.Width;
            maxh = a.Current.Height;
            a.MoveNext();
            while (true)//DO NOT TOUCH THIS CYCLE OR ELSE MONO GETS SCARED!!!
            {
                try
                {
                    if (a.Current == null)
                    {
                        break;
                    }
                }
                catch { System.Threading.Thread.Sleep(1); }
                try
                {
                    if (a.Current == null)
                    {
                        break;
                    }
                }
                catch { break; }
                try
                {
                    if (a.Current.Width > maxw)
                    {
                        maxw = a.Current.Width;
                    }
                    if (a.Current.Height > maxh)
                    {
                        maxh = a.Current.Height;
                    }
                }
                catch { }
                a.MoveNext();
            }
            #endregion

            #region Resoulutions
            l_aspectRatio            = new Elements.Label((int)Position.X + 5, (int)Position.Y + 5, "Aspect ratio:");
            l_aspectRatio.foreground = Color.White;
            controls.Add(l_aspectRatio);

            co_aspectRation = new Elements.ComboBox((int)Position.X + 150, (int)Position.Y + 7, 120, 24);
            co_aspectRation.onElementSelected += new Elements.ComboBox.ElementSelectedHandler(ar_onElementSelected);
            controls.Add(co_aspectRation);
            co_aspectRation.ItemsAdd("4*3");
            co_aspectRation.ItemsAdd("5*3");
            if (maxw >= 1280 && maxh >= 720)
            {
                co_aspectRation.ItemsAdd("16*9");
            }
            if (maxw >= 1280 && maxh >= 800)
            {
                co_aspectRation.ItemsAdd("16*10");
            }

            l_resolution            = new Elements.Label((int)Position.X + 5, (int)Position.Y + 35, "Resolution:");
            l_resolution.foreground = Color.White;
            controls.Add(l_resolution);

            co_resolution = new Elements.ComboBox((int)Position.X + 150, (int)Position.Y + 37, 120, 24);
            co_resolution.onElementSelected += new Elements.ComboBox.ElementSelectedHandler(res_onElementSelected);
            controls.Add(co_resolution);

            cb_fullscreen                   = new Elements.CheckBox((int)Position.X + 5, (int)Position.Y + 65, 200, 20, "FullScreen", false);
            cb_fullscreen.foreground        = Color.White;
            cb_fullscreen.onCheckedChanged += new Elements.CheckBox.CheckBoxCheckedHandler(cb_fullscreen_onCheckedChanged);
            controls.Add(cb_fullscreen);

            b_apply = new Elements.MenuButton((int)(Position.X + Size.X) - 120, (int)(Position.Y + Size.Y) - 23, 120, 23,
                                              "Apply");
            b_apply.Font       = ButtonFont;
            b_apply.onClicked += new Elements.Button.ClickedEventHandler(apply_onClicked);
            controls.Add(b_apply);
            #endregion

            cb_drawgrig                   = new Elements.CheckBox((int)Position.X + 5, (int)Position.Y + 95, 200, 20, "Draw grid", false);
            cb_drawgrig.foreground        = Color.White;
            cb_drawgrig.onCheckedChanged += new Elements.CheckBox.CheckBoxCheckedHandler(cb_drawgrig_onCheckedChanged);
            controls.Add(cb_drawgrig);

            cb_warning                   = new Elements.CheckBox((int)Position.X + 5, (int)Position.Y + 125, 200, 20, "Show intro warning", false);
            cb_warning.foreground        = Color.White;
            cb_warning.onCheckedChanged += new Elements.CheckBox.CheckBoxCheckedHandler(cb_warning_onCheckedChanged);
            controls.Add(cb_warning);

            base.Initialize();
        }
コード例 #3
0
ファイル: Options.cs プロジェクト: XZelnar/MicroWorld
        public new void Initialize()
        {
            #region Basic
            Layer = 100000;
            ShouldBeScaled = false;

            var a = GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.GetEnumerator();
            a.MoveNext();
            maxw = a.Current.Width;
            maxh = a.Current.Height;
            a.MoveNext();
            while (true)//DO NOT TOUCH THIS CYCLE OR ELSE MONO GETS SCARED!!!
            {
                try
                {
                    if (a.Current == null)
                        break;
                }
                catch { System.Threading.Thread.Sleep(1); }
                try
                {
                    if (a.Current == null)
                        break;
                }
                catch { break; }
                try
                {
                    if (a.Current.Width > maxw) maxw = a.Current.Width;
                    if (a.Current.Height > maxh) maxh = a.Current.Height;
                }
                catch { }
                a.MoveNext();
            }
            #endregion

            #region ControlButtons
            sb = new Elements.EncyclopediaBrowserButton(410, 440, 120, 30, "Back");
            (sb as Elements.EncyclopediaBrowserButton).OverrideTexture("GUI/Menus/ButtonBackground2");
            sb.foreground = Color.White;
            //sb.font = ResourceManager.Load<SpriteFont>("Fonts/MenuFont");
            sb.onClicked +=new Elements.Button.ClickedEventHandler(sbClick);
            controls.Add(sb);

            sac = new Elements.EncyclopediaBrowserButton(540, 440, 120, 30, "Save");
            (sac as Elements.EncyclopediaBrowserButton).OverrideTexture("GUI/Menus/ButtonBackground2");
            sac.foreground = Color.White;
            //sac.font = ResourceManager.Load<SpriteFont>("Fonts/MenuFont");
            sac.onClicked += new Elements.Button.ClickedEventHandler(sacClick);
            controls.Add(sac);

            ap = new Elements.EncyclopediaBrowserButton(670, 440, 120, 30, "Apply");
            (ap as Elements.EncyclopediaBrowserButton).OverrideTexture("GUI/Menus/ButtonBackground2");
            ap.foreground = Color.White;
            //ap.font = ResourceManager.Load<SpriteFont>("Fonts/MenuFont");
            ap.onClicked += new Elements.Button.ClickedEventHandler(apClick);
            controls.Add(ap);
            #endregion

            #region MasterVolume
            Elements.Label l1 = new Elements.Label(10, 20, "Master Volume");
            l1.foreground = Color.White;
            controls.Add(l1);

            mv = new Elements.ScrollBar(170, 24, 200, 20);
            mv.onValueChanged += new Elements.ScrollBar.ValueChangedEventHandler(mv_onValueChanged);
            mv.MinValue = 0;
            mv.MaxValue = 100;
            mv.Value = (int)(Settings.MasterVolume * 100);
            controls.Add(mv);
            #endregion

            #region EffectVolume
            Elements.Label l11 = new Elements.Label(10, 50, "Effects Volume");
            l11.foreground = Color.White;
            controls.Add(l11);

            ev = new Elements.ScrollBar(170, 54, 200, 20);
            ev.onValueChanged += new Elements.ScrollBar.ValueChangedEventHandler(ev_onValueChanged);
            ev.MinValue = 0;
            ev.MaxValue = 100;
            ev.Value = (int)(Settings.EffectsVolume * 100);
            controls.Add(ev);
            #endregion

            #region MusicVolume
            Elements.Label l111 = new Elements.Label(10, 80, "Music Volume");
            l111.foreground = Color.White;
            controls.Add(l111);

            mzv = new Elements.ScrollBar(170, 84, 200, 20);
            mzv.onValueChanged += new Elements.ScrollBar.ValueChangedEventHandler(mzv_onValueChanged);
            mzv.MinValue = 0;
            mzv.MaxValue = 100;
            mzv.Value = (int)(Settings.MusicVolume * 100);
            controls.Add(mzv);
            #endregion

            #region Resoulutions
            lar = new Elements.Label(400, 20, "Aspect ratio:");
            lar.foreground = Color.White;
            controls.Add(lar);

            ar = new Elements.ComboBox(550, 22, 120, 24);
            ar.onElementSelected += new Elements.ComboBox.ElementSelectedHandler(ar_onElementSelected);
            controls.Add(ar);
            ar.ItemsAdd("4*3");
            ar.ItemsAdd("5*3");
            if (maxw >= 1280 && maxh >= 720) ar.ItemsAdd("16*9");
            if (maxw >= 1280 && maxh >= 800) ar.ItemsAdd("16*10");

            lres = new Elements.Label(400, 50, "Resolution:");
            lres.foreground = Color.White;
            controls.Add(lres);

            res = new Elements.ComboBox(550, 52, 120, 24);
            res.onElementSelected += new Elements.ComboBox.ElementSelectedHandler(res_onElementSelected);
            controls.Add(res);

            fs = new Elements.CheckBox(400, 90, 170, 20, "FullScreen", false);
            fs.foreground = Color.White;
            controls.Add(fs);
            #endregion

            #region Hotkeys
            hcSimStart = new Elements.HotkeyControl(5, 125, 250, "Simulation start", Settings.k_SimulationStart);
            controls.Add(hcSimStart);
            hcSimStop = new Elements.HotkeyControl(5, 150, 250,  "Simulation stop", Settings.k_SimulationStop);
            controls.Add(hcSimStop);
            hcSimPause = new Elements.HotkeyControl(5, 175, 250, "Simulation pause", Settings.k_SimulationPause);
            controls.Add(hcSimPause);
            hcUndo = new Elements.HotkeyControl(5,    200, 250, "Undo", Settings.k_Undo);
            controls.Add(hcUndo);
            hcCompRem = new Elements.HotkeyControl(5, 250, 250, "Remove single component", Settings.k_ComponentRemove);
            controls.Add(hcCompRem);
            hcEraser = new Elements.HotkeyControl(5, 275, 250, "Eraser", Settings.k_Eraser);
            controls.Add(hcEraser);
            hcZoomIn = new Elements.HotkeyControl(5, 300, 250, "Zoom In", Settings.k_ZoomIn);
            controls.Add(hcZoomIn);
            hcZoomOut = new Elements.HotkeyControl(5, 325, 250, "Zoom Out", Settings.k_ZoomOut);
            controls.Add(hcZoomOut);
            #endregion

            base.Initialize();
            background = GUIEngine.s_mainMenu.background;
        }
コード例 #4
0
ファイル: Options.cs プロジェクト: XZelnar/MicroWorld
        public new void Initialize()
        {
            #region Basic
            Layer          = 100000;
            ShouldBeScaled = false;

            var a = GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.GetEnumerator();
            a.MoveNext();
            maxw = a.Current.Width;
            maxh = a.Current.Height;
            a.MoveNext();
            while (true)//DO NOT TOUCH THIS CYCLE OR ELSE MONO GETS SCARED!!!
            {
                try
                {
                    if (a.Current == null)
                    {
                        break;
                    }
                }
                catch { System.Threading.Thread.Sleep(1); }
                try
                {
                    if (a.Current == null)
                    {
                        break;
                    }
                }
                catch { break; }
                try
                {
                    if (a.Current.Width > maxw)
                    {
                        maxw = a.Current.Width;
                    }
                    if (a.Current.Height > maxh)
                    {
                        maxh = a.Current.Height;
                    }
                }
                catch { }
                a.MoveNext();
            }
            #endregion

            #region ControlButtons
            sb = new Elements.EncyclopediaBrowserButton(410, 440, 120, 30, "Back");
            (sb as Elements.EncyclopediaBrowserButton).OverrideTexture("GUI/Menus/ButtonBackground2");
            sb.foreground = Color.White;
            //sb.font = ResourceManager.Load<SpriteFont>("Fonts/MenuFont");
            sb.onClicked += new Elements.Button.ClickedEventHandler(sbClick);
            controls.Add(sb);

            sac = new Elements.EncyclopediaBrowserButton(540, 440, 120, 30, "Save");
            (sac as Elements.EncyclopediaBrowserButton).OverrideTexture("GUI/Menus/ButtonBackground2");
            sac.foreground = Color.White;
            //sac.font = ResourceManager.Load<SpriteFont>("Fonts/MenuFont");
            sac.onClicked += new Elements.Button.ClickedEventHandler(sacClick);
            controls.Add(sac);

            ap = new Elements.EncyclopediaBrowserButton(670, 440, 120, 30, "Apply");
            (ap as Elements.EncyclopediaBrowserButton).OverrideTexture("GUI/Menus/ButtonBackground2");
            ap.foreground = Color.White;
            //ap.font = ResourceManager.Load<SpriteFont>("Fonts/MenuFont");
            ap.onClicked += new Elements.Button.ClickedEventHandler(apClick);
            controls.Add(ap);
            #endregion

            #region MasterVolume
            Elements.Label l1 = new Elements.Label(10, 20, "Master Volume");
            l1.foreground = Color.White;
            controls.Add(l1);

            mv = new Elements.ScrollBar(170, 24, 200, 20);
            mv.onValueChanged += new Elements.ScrollBar.ValueChangedEventHandler(mv_onValueChanged);
            mv.MinValue        = 0;
            mv.MaxValue        = 100;
            mv.Value           = (int)(Settings.MasterVolume * 100);
            controls.Add(mv);
            #endregion

            #region EffectVolume
            Elements.Label l11 = new Elements.Label(10, 50, "Effects Volume");
            l11.foreground = Color.White;
            controls.Add(l11);

            ev = new Elements.ScrollBar(170, 54, 200, 20);
            ev.onValueChanged += new Elements.ScrollBar.ValueChangedEventHandler(ev_onValueChanged);
            ev.MinValue        = 0;
            ev.MaxValue        = 100;
            ev.Value           = (int)(Settings.EffectsVolume * 100);
            controls.Add(ev);
            #endregion

            #region MusicVolume
            Elements.Label l111 = new Elements.Label(10, 80, "Music Volume");
            l111.foreground = Color.White;
            controls.Add(l111);

            mzv = new Elements.ScrollBar(170, 84, 200, 20);
            mzv.onValueChanged += new Elements.ScrollBar.ValueChangedEventHandler(mzv_onValueChanged);
            mzv.MinValue        = 0;
            mzv.MaxValue        = 100;
            mzv.Value           = (int)(Settings.MusicVolume * 100);
            controls.Add(mzv);
            #endregion

            #region Resoulutions
            lar            = new Elements.Label(400, 20, "Aspect ratio:");
            lar.foreground = Color.White;
            controls.Add(lar);

            ar = new Elements.ComboBox(550, 22, 120, 24);
            ar.onElementSelected += new Elements.ComboBox.ElementSelectedHandler(ar_onElementSelected);
            controls.Add(ar);
            ar.ItemsAdd("4*3");
            ar.ItemsAdd("5*3");
            if (maxw >= 1280 && maxh >= 720)
            {
                ar.ItemsAdd("16*9");
            }
            if (maxw >= 1280 && maxh >= 800)
            {
                ar.ItemsAdd("16*10");
            }

            lres            = new Elements.Label(400, 50, "Resolution:");
            lres.foreground = Color.White;
            controls.Add(lres);

            res = new Elements.ComboBox(550, 52, 120, 24);
            res.onElementSelected += new Elements.ComboBox.ElementSelectedHandler(res_onElementSelected);
            controls.Add(res);

            fs            = new Elements.CheckBox(400, 90, 170, 20, "FullScreen", false);
            fs.foreground = Color.White;
            controls.Add(fs);
            #endregion

            #region Hotkeys
            hcSimStart = new Elements.HotkeyControl(5, 125, 250, "Simulation start", Settings.k_SimulationStart);
            controls.Add(hcSimStart);
            hcSimStop = new Elements.HotkeyControl(5, 150, 250, "Simulation stop", Settings.k_SimulationStop);
            controls.Add(hcSimStop);
            hcSimPause = new Elements.HotkeyControl(5, 175, 250, "Simulation pause", Settings.k_SimulationPause);
            controls.Add(hcSimPause);
            hcUndo = new Elements.HotkeyControl(5, 200, 250, "Undo", Settings.k_Undo);
            controls.Add(hcUndo);
            hcCompRem = new Elements.HotkeyControl(5, 250, 250, "Remove single component", Settings.k_ComponentRemove);
            controls.Add(hcCompRem);
            hcEraser = new Elements.HotkeyControl(5, 275, 250, "Eraser", Settings.k_Eraser);
            controls.Add(hcEraser);
            hcZoomIn = new Elements.HotkeyControl(5, 300, 250, "Zoom In", Settings.k_ZoomIn);
            controls.Add(hcZoomIn);
            hcZoomOut = new Elements.HotkeyControl(5, 325, 250, "Zoom Out", Settings.k_ZoomOut);
            controls.Add(hcZoomOut);
            #endregion

            base.Initialize();
            background = GUIEngine.s_mainMenu.background;
        }