Esempio n. 1
0
        void TextChanged()
        {
            var text = xmlEditor.GetText();

            if (string.IsNullOrEmpty(text) || string.IsNullOrWhiteSpace(text))
            {
                objectMaps    = null;
                validXml      = false;
                widget        = null;
                exceptionText = "Nothing typed yet";
                return;
            }
            try
            {
                objectMaps = new List <XmlObjectMap>();
                widget     = (UiWidget)mainWindow.UiData.XmlLoader.FromString(text, objectMaps);
                if (mainWindow.UiData.Stylesheet != null)
                {
                    widget.ApplyStylesheet(mainWindow.UiData.Stylesheet);
                }
                context.SetWidget(widget);
                validXml = true;
            }
            catch (Exception ex)
            {
                validXml      = false;
                exceptionText = $"Invalid XML\n\n{ex.Message}\n{ex.StackTrace}";
            }
        }
Esempio n. 2
0
        public RoomGameplay(FreelancerGame g, GameSession session, string newBase, BaseRoom room = null, string virtualRoom = null) : base(g)
        {
            this.session = session;
            baseId       = newBase;
            currentBase  = g.GameData.GetBase(newBase);
            currentRoom  = room ?? currentBase.StartRoom;
            currentRoom.InitForDisplay();
            SwitchToRoom();
            tophotspots = new List <BaseHotspot>();
            foreach (var hp in currentRoom.Hotspots)
            {
                if (TOP_IDS.Contains(hp.Name))
                {
                    tophotspots.Add(hp);
                }
            }
            var rm = virtualRoom ?? currentRoom.Nickname;

            SetActiveHotspot(rm);
            this.virtualRoom = virtualRoom;
            ui         = new UiContext(Game);
            ui.GameApi = new BaseUiApi(this);
            widget     = ui.CreateAll("baseside.xml");
            Game.Keyboard.TextInput += Game_TextInput;
            Game.Keyboard.KeyDown   += Keyboard_KeyDown;
            cursor = Game.ResourceManager.GetCursor("arrow");
            FadeIn(0.8, 1.7);
        }
        public LuaMenu(FreelancerGame g) : base(g)
        {
            api        = new MenuAPI(this);
            ui         = new UiContext(g);
            ui.GameApi = new MenuAPI(this);
            widget     = ui.CreateAll("mainmenu.xml");
            g.GameData.PopulateCursors();
            g.CursorKind = CursorKind.None;
            intro        = g.GameData.GetIntroScene();
            scene        = new Cutscene(new ThnScriptContext(intro.Scripts), Game.GameData, Game.Viewport, Game);
            scene.Update(TimeSpan.FromSeconds(1f / 60f)); //Do all the setup events - smoother entrance
            FLLog.Info("Thn", "Playing " + intro.ThnName);
            cur = g.ResourceManager.GetCursor("arrow");
            GC.Collect(); //crap
            g.Sound.PlayMusic(intro.Music);
#if DEBUG
            g.Keyboard.KeyDown += Keyboard_KeyDown;
#endif
            FadeIn(0.1, 0.3);
        }
 public SpaceGameplay(FreelancerGame g, GameSession session) : base(g)
 {
     FLLog.Info("Game", "Entering system " + session.PlayerSystem);
     g.ResourceManager.ClearTextures(); //Do before loading things
     this.session = session;
     #if false
     pyw = new DebugGraph();
     pyw.AddLine(Color4.Red, 240, -1, 1);
     pyw.AddLine(Color4.Green, 240, -1, 1);
     pyw.AddLine(Color4.Blue, 240, -1, 1);
     pyw.X      = 850;
     pyw.Y      = 10;
     pyw.Width  = 170;
     pyw.Height = 124;
     #endif
     sys        = g.GameData.GetSystem(session.PlayerSystem);
     loader     = new LoadingScreen(g, g.GameData.LoadSystemResources(sys));
     ui         = new UiContext(g);
     ui.GameApi = uiApi = new LuaAPI(this);
     widget     = ui.CreateAll("hud.xml");
 }