Exemple #1
0
        private void CheckConfigure()
        {
            bool isModified = false;
            Dictionary <string, string> displayOptions = new Dictionary <string, string>();
            ConfigOptionMap             options        = GameManager.Instance.root.GetRenderSystemByName(renderMenu.getSelectedItem()).GetConfigOptions();

            for (uint i = 3; i < GameManager.Instance.trayMgr.getNumWidgets(renderMenu.getTrayLocation()); i++)
            {
                SelectMenu optionMenu = (SelectMenu)GameManager.Instance.trayMgr.getWidget(renderMenu.getTrayLocation(), i);
                if (optionMenu.getSelectedItem() != options[optionMenu.getCaption()].currentValue)
                {
                    isModified = true;
                }
                displayOptions.Add(optionMenu.getCaption(), optionMenu.getSelectedItem());
            }
            OgreConfigFileAdapter       ofa         = new OgreConfigFileAdapter("ogre.cfg");
            List <OgreConfigNode>       ogrecfgdata = ofa.ReadConfigData();
            OgreConfigNode              oneConfig   = ogrecfgdata.Where(o => o.Section == renderMenu.getSelectedItem()).FirstOrDefault();
            Dictionary <string, string> fileOptions = oneConfig.Settings;

            if (isModified)
            {
                int indexDeleted = ogrecfgdata.IndexOf(oneConfig);
                ogrecfgdata.RemoveAt(indexDeleted);
                oneConfig.Settings = displayOptions;
                ogrecfgdata.Insert(indexDeleted, oneConfig);
                ofa.SaveConfig(ogrecfgdata);
                m_bQuit = true;

                ReConfigure(renderMenu.getSelectedItem(), displayOptions);
            }
        }
Exemple #2
0
        bool FrameRenderingQueued(FrameEvent evt)
        {
            selectedModName = modChooserMenu.getSelectedItem();
            float carouselOffset = modChooserMenu.getSelectionIndex() - carouselPlace;

            if ((carouselOffset <= 0.001) && (carouselOffset >= -0.001))
            {
                carouselPlace = modChooserMenu.getSelectionIndex();
            }
            else
            {
                carouselPlace += carouselOffset * OpenMB.Utilities.Helper.Clamp <float>(evt.timeSinceLastFrame * 15.0f, -1.0f, 1.0f);
            }

            for (int i = 0; i < modThumbs.Count; i++)
            {
                float thumbOffset = carouselPlace - i;
                float phase       = (thumbOffset / 2.0f) - 2.8f;

                if (thumbOffset < -5 || thumbOffset > 4)    // prevent thumbnails from wrapping around in a circle
                {
                    modThumbs[i].Hide();
                    continue;
                }
                else
                {
                    modThumbs[i].Show();
                }

                float left  = Mogre.Math.Cos(phase) * 200.0f;
                float top   = Mogre.Math.Sin(phase) * 200.0f;
                float scale = 1.0f / Convert.ToSingle(System.Math.Pow((Mogre.Math.Abs(thumbOffset) + 1.0f), 0.75f));

                OverlayContainer.ChildContainerIterator xx = modThumbs[i].GetChildContainerIterator();
                BorderPanelOverlayElement frame            = (BorderPanelOverlayElement)xx.ElementAt(0);

                modThumbs[i].SetDimensions(128.0f * scale, 96.0f * scale);
                frame.SetDimensions(modThumbs[i].Width + 16.0f, modThumbs[i].Height + 16.0f);
                modThumbs[i].SetPosition((left - 80.0f - (modThumbs[i].Width / 2.0f)),
                                         (top - 5.0f - (modThumbs[i].Height / 2.0f)));

                if (i == modChooserMenu.getSelectionIndex())
                {
                    frame.BorderMaterialName = "SdkTrays/Frame/Over";
                }
                else
                {
                    frame.BorderMaterialName = "SdkTrays/Frame";
                }
            }

            GameManager.Instance.trayMgr.frameRenderingQueued(evt);

            return(true);
        }
Exemple #3
0
        public override void enter(ModData e = null)
        {
            sceneMgr = GameManager.Instance.root.CreateSceneManager(Mogre.SceneType.ST_GENERIC, "ModChooserSceneMgr");

            ColourValue cvAmbineLight = new ColourValue(0.7f, 0.7f, 0.7f);

            sceneMgr.AmbientLight = cvAmbineLight;

            camera = sceneMgr.CreateCamera("ModChooserCam");
            camera.SetPosition(0, 25, -50);
            Mogre.Vector3 vectorCameraLookat = new Mogre.Vector3(0, 0, 0);
            camera.LookAt(vectorCameraLookat);
            camera.NearClipDistance = 1;

            camera.AspectRatio = GameManager.Instance.viewport.ActualWidth / GameManager.Instance.viewport.ActualHeight;

            GameManager.Instance.viewport.Camera = camera;
            modNames.Clear();
            modThumb.Clear();

            mods = ModManager.Instance.GetInstalledMods();
            foreach (var mod in mods)
            {
                if (mod.Value.MetaData.DisplayInChooser)
                {
                    modNames.Add(mod.Key);
                    modDescs.Add(mod.Value.MetaData.Description);
                    modThumb.Add(mod.Value.MetaData.Thumb);
                }
            }

            GameManager.Instance.trayMgr.destroyAllWidgets();
            modTitle = GameManager.Instance.trayMgr.createLabel(TrayLocation.TL_LEFT, "ModTitle", "Mod Info");
            modTitle.setCaption("Mod Info");
            modDescBox = GameManager.Instance.trayMgr.createTextBox(TrayLocation.TL_LEFT, "ModInfo", "Mod Info", 250, 208);
            modDescBox.setCaption("Mod Info");
            modChooserMenu = GameManager.Instance.trayMgr.createThickSelectMenu(TrayLocation.TL_LEFT, "SelMod", "Select Mod", 250, 10);
            modChooserMenu.setCaption("Select Mod");
            modChooserMenu.setItems(modNames);
            modSlider = GameManager.Instance.trayMgr.createThickSlider(TrayLocation.TL_LEFT, "ModSlider", "Slider Mods", 250, 80, 0, 0, 0);
            modSlider.setCaption("Slider Mods");
            if (modNames.Count > 0)
            {
                modTitle.setCaption(modChooserMenu.getSelectedItem());
            }

            GameManager.Instance.trayMgr.showLogo(TrayLocation.TL_RIGHT);
            GameManager.Instance.trayMgr.createSeparator(TrayLocation.TL_RIGHT, "LogoSep");
            GameManager.Instance.trayMgr.createButton(TrayLocation.TL_RIGHT, "Play", LocateSystem.Instance.GetLocalizedString(Localization.LocateFileType.GameString, "str_play"), 140);
            GameManager.Instance.trayMgr.createButton(TrayLocation.TL_RIGHT, "Quit", LocateSystem.Instance.GetLocalizedString(Localization.LocateFileType.GameString, "str_quit"), 140);

            setupModMenu();

            GameManager.Instance.mouse.MouseMoved          += Mouse_MouseMoved;
            GameManager.Instance.mouse.MousePressed        += Mouse_MousePressed;
            GameManager.Instance.mouse.MouseReleased       += Mouse_MouseReleased;
            GameManager.Instance.root.FrameRenderingQueued += FrameRenderingQueued;
        }