Beispiel #1
0
 void StartPlay(string classname)
 {
     try
     {
         _playData = new UiData()
         {
             Fonts           = Project.UiData.Fonts,
             Infocards       = Project.UiData.Infocards,
             DataPath        = Project.UiData.DataPath,
             FileSystem      = Project.UiData.FileSystem,
             FlDirectory     = Project.UiData.FlDirectory,
             ResourceManager = Project.UiData.ResourceManager,
             NavbarIcons     = Project.UiData.NavbarIcons,
             NavmapIcons     = Project.UiData.NavmapIcons,
             Resources       = Project.UiData.Resources
         };
         _playData.SetBundle(Compiler.Compile(Project.XmlFolder, Project.XmlLoader));
         _playContext = new UiContext(_playData)
         {
             RenderContext = RenderContext
         };
         _playContext.CommandBuffer = CommandBuffer;
         _playContext.GameApi       = TestApi;
         _playContext.LoadCode();
         _playContext.OpenScene(classname);
         playing = true;
     }
     catch (Exception e)
     {
         var detail = new StringBuilder();
         BuildExceptionString(e, detail);
         CrashWindow.Run("Interface Edit", "Compile Error", detail.ToString());
     }
 }
 public LoadingScreen(FreelancerGame game, IEnumerator <object> loader)
 {
     this.game   = game;
     this.loader = loader;
     ui          = new UiContext(game);
     ui.CreateAll("loading.xml");
 }
Beispiel #3
0
        public void CreateContext(MainWindow window)
        {
            var uidata = new UiData();

            uidata.FileSystem = window.GameData.VFS;
            uidata.DataPath   = window.GameData.Ini.Freelancer.DataPath;
            if (window.GameData.Ini.Navmap != null)
            {
                uidata.NavmapIcons = new IniNavmapIcons(window.GameData.Ini.Navmap);
            }
            else
            {
                uidata.NavmapIcons = new NavmapIcons();
            }
            uidata.Fonts           = window.GetService <FontManager>();
            uidata.ResourceManager = window.Resources;
            ctx = new UiContext(uidata);
            ctx.RenderContext   = window.RenderContext;
            navmap              = new Navmap();
            navmap.Width        = 480;
            navmap.Height       = 480;
            navmap.LetterMargin = true;
            navmap.MapBorder    = true;
            ctx.SetWidget(navmap);
            this.win = window;
        }
Beispiel #4
0
        /// <summary>
        ///     Do the actual upload to OneDrive
        /// </summary>
        /// <param name="oAuth2Settings">OAuth2Settings</param>
        /// <param name="surfaceToUpload">ISurface to upload</param>
        /// <param name="outputSettings">OutputSettings for the image file format</param>
        /// <param name="title">Title</param>
        /// <param name="filename">Filename</param>
        /// <param name="progress">IProgress</param>
        /// <param name="token">CancellationToken</param>
        /// <returns>ImgurInfo with details</returns>
        public static async Task <OneDriveUploadResponse> UploadToOneDriveAsync(OAuth2Settings oAuth2Settings, ISurface surfaceToUpload,
                                                                                SurfaceOutputSettings outputSettings, string title, string filename, IProgress <int> progress = null,
                                                                                CancellationToken token = default)
        {
            var uploadUri      = new Uri(UrlUtils.GetUploadUrl(filename));
            var localBehaviour = Behaviour.ShallowClone();

            if (progress != null)
            {
                localBehaviour.UploadProgress = percent => { UiContext.RunOn(() => progress.Report((int)(percent * 100)), token); };
            }
            var oauthHttpBehaviour = OAuth2HttpBehaviourFactory.Create(oAuth2Settings, localBehaviour);

            using (var imageStream = new MemoryStream())
            {
                ImageOutput.SaveToStream(surfaceToUpload, imageStream, outputSettings);
                imageStream.Position = 0;
                using (var content = new StreamContent(imageStream))
                {
                    content.Headers.Add("Content-Type", "image/" + outputSettings.Format);
                    oauthHttpBehaviour.MakeCurrent();
                    return(await uploadUri.PostAsync <OneDriveUploadResponse>(content, token));
                }
            }
        }
Beispiel #5
0
        public LuaMenu(FreelancerGame g) : base(g)
        {
            api        = new MenuAPI(this);
            ui         = Game.Ui;
            ui.GameApi = api;
            ui.Visible = true;
            ui.OpenScene("mainmenu");
            g.GameData.PopulateCursors();
            g.CursorKind = CursorKind.None;
            intro        = g.GameData.GetIntroScene();
            scene        = new Cutscene(new ThnScriptContext(null), Game.GameData, Game.RenderContext.CurrentViewport, Game);
            scene.BeginScene(intro.Scripts);
            FLLog.Info("Thn", "Playing " + intro.ThnName);
            cur = g.ResourceManager.GetCursor("arrow");
            GC.Collect(); //crap
            g.Sound.PlayMusic(intro.Music);
            g.Keyboard.KeyDown   += UiKeyDown;
            g.Keyboard.TextInput += UiTextInput;
#if DEBUG
            g.Keyboard.KeyDown += Keyboard_KeyDown;
#endif
            Game.Saves.Selected = -1;
            if (g.LoadTimer != null)
            {
                g.LoadTimer.Stop();
                FLLog.Info("Game", $"Initial load took {g.LoadTimer.Elapsed.TotalSeconds} seconds");
                g.LoadTimer = null;
            }
            FadeIn(0.1, 0.3);
        }
Beispiel #6
0
        public static void RegisterAutoLoadPackages(this IPackageManager manager, IMafPackage package, Action loadAction)
        {
            if (package.LoadOption != PackageLoadOption.OnContextActivated)
            {
                return;
            }

            var attributes = package.GetType().GetAttributes <PackageAutoLoadAttribute>(true);

            foreach (var attribute in attributes)
            {
                var uiContext = UiContext.FromUiContextGuid(attribute.LoadGuid);
                if (Mapping.ContainsKey(attribute.LoadGuid))
                {
                    Mapping[attribute.LoadGuid].Add(package.Id);
                }
                else
                {
                    Mapping.Add(attribute.LoadGuid, new HashSet <Guid> {
                        package.Id
                    });
                }
                uiContext.WhenActivated(loadAction);
            }
        }
Beispiel #7
0
        /// <summary>
        ///     Make sure we startup everything after WPF instanciated
        /// </summary>
        /// <param name="e">StartupEventArgs</param>
        protected override async void OnStartup(StartupEventArgs e)
        {
            // Enable UI access for different Dapplo packages, especially the UiContext.RunOn
            // This only works here, not before the Application is started and not later
            UiContext.Initialize();

            _bootstrapper.Configure();

            // Register the UI SynchronizationContext, this can be retrieved by specifying the name "ui" for the argument
            _bootstrapper.Builder.RegisterInstance(SynchronizationContext.Current).Named <SynchronizationContext>("ui");
            _bootstrapper.Builder.RegisterInstance(TaskScheduler.FromCurrentSynchronizationContext()).Named <TaskScheduler>("ui");

            // Prepare the bootstrapper
            await _bootstrapper.InitializeAsync().ConfigureAwait(true);

            // The following makes sure that Caliburn.Micro is correctly initialized on the right thread and Execute.OnUIThread works
            // Very important to do this, after all assemblies are loaded!
            _caliburnMicroBootstrapper = new CaliburnMicroBootstrapper(_bootstrapper);
            _caliburnMicroBootstrapper.Initialize();

            // Now check if there is a lock, if so we invoke OnAlreadyRunning and return
            if (_bootstrapper.IsAlreadyRunning)
            {
                var exitCode = OnAlreadyRunning?.Invoke() ?? -1;
                Shutdown(exitCode);
                return;
            }

            // Start Dapplo, do not use configure-await false here, so the OnStartup doesn't have any issues
            await _bootstrapper.StartupAsync().ConfigureAwait(true);

            // This also triggers the Caliburn.Micro.BootstrapperBase.OnStartup
            base.OnStartup(e);
        }
Beispiel #8
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, "baseside.xml");
            ui.GameApi = new BaseUiApi(this);
            ui.Start();
            Game.Keyboard.TextInput += Game_TextInput;
            Game.Keyboard.KeyDown   += Keyboard_KeyDown;
            cursor = Game.ResourceManager.GetCursor("arrow");
            FadeIn(0.8, 1.7);
        }
        /// <summary>
        ///     Do the actual upload to OneDrive
        /// </summary>
        /// <param name="oAuth2Settings">OAuth2Settings</param>
        /// <param name="surfaceToUpload">ISurface to upload</param>
        /// <param name="progress">IProgress</param>
        /// <param name="token">CancellationToken</param>
        /// <returns>OneDriveUploadResponse with details</returns>
        private async Task <OneDriveUploadResponse> UploadToOneDriveAsync(OAuth2Settings oAuth2Settings,
                                                                          ISurface surfaceToUpload, IProgress <int> progress = null,
                                                                          CancellationToken token = default)
        {
            var filename       = surfaceToUpload.GenerateFilename(CoreConfiguration, _oneDriveConfiguration);
            var uploadUri      = OneDriveUri.AppendSegments("root:", "Screenshots", filename + ":", "content");
            var localBehaviour = _oneDriveHttpBehaviour.ShallowClone();

            if (progress != null)
            {
                localBehaviour.UploadProgress = percent => { UiContext.RunOn(() => progress.Report((int)(percent * 100)), token); };
            }
            var oauthHttpBehaviour = OAuth2HttpBehaviourFactory.Create(oAuth2Settings, localBehaviour);

            using (var imageStream = new MemoryStream())
            {
                surfaceToUpload.WriteToStream(imageStream, CoreConfiguration, _oneDriveConfiguration);
                imageStream.Position = 0;
                using (var content = new StreamContent(imageStream))
                {
                    content.Headers.Add("Content-Type", surfaceToUpload.GenerateMimeType(CoreConfiguration, _oneDriveConfiguration));
                    oauthHttpBehaviour.MakeCurrent();
                    return(await uploadUri.PutAsync <OneDriveUploadResponse>(content, token));
                }
            }
        }
Beispiel #10
0
        public FormOrder(UiContext context, OrderView order)
        {
            InitializeComponent();

            driver = new OrderPageDriver(context, order);

            ConfigureDriver();
        }
Beispiel #11
0
        public FormOrders(UiContext context)
        {
            InitializeComponent();

            driver = new OrdersPageDriver(context);

            ConfigureDriver();
        }
 public ResourceWindow(MainWindow mainWindow, UiContext context)
 {
     this.resources  = context.Resources;
     this.context    = context;
     librarySelector = new FileSelector(context.FlDirectory);
     modelSelector   = new FileSelector(context.FlDirectory);
     this.mainWindow = mainWindow;
 }
Beispiel #13
0
        public FormOrderProduct(UiContext context, OrderView order, OrderProductView orderProduct)
        {
            InitializeComponent();

            driver = new OrderProductPageDriver(context, order, orderProduct);

            ConfigureDriver();
        }
Beispiel #14
0
        public FormProduct(UiContext context, ProductView product)
        {
            InitializeComponent();

            driver = new ProductPageDriver(context, product);

            ConfigureDriver();
        }
Beispiel #15
0
        public FormProducts(UiContext context)
        {
            InitializeComponent();

            driver = new ProductsPageDriver(context);

            ConfigureDriver();
        }
Beispiel #16
0
        public LedgerBookController(
            [NotNull] UiContext uiContext,
            [NotNull] LedgerBookControllerFileOperations fileOperations,
            [NotNull] LedgerBookGridBuilderFactory uiBuilder,
            [NotNull] ILedgerService ledgerService,
            [NotNull] IReconciliationService reconService,
            [NotNull] NewWindowViewLoader newWindowViewLoader)
        {
            if (uiContext == null)
            {
                throw new ArgumentNullException(nameof(uiContext));
            }

            if (fileOperations == null)
            {
                throw new ArgumentNullException(nameof(fileOperations));
            }

            if (uiBuilder == null)
            {
                throw new ArgumentNullException(nameof(uiBuilder));
            }

            if (ledgerService == null)
            {
                throw new ArgumentNullException(nameof(ledgerService));
            }

            if (reconService == null)
            {
                throw new ArgumentNullException(nameof(reconService));
            }

            if (newWindowViewLoader == null)
            {
                throw new ArgumentNullException(nameof(newWindowViewLoader));
            }

            this.uiBuilder                    = uiBuilder;
            this.ledgerService                = ledgerService;
            this.reconService                 = reconService;
            this.newWindowViewLoader          = newWindowViewLoader;
            this.messageBox                   = uiContext.UserPrompts.MessageBox;
            this.questionBox                  = uiContext.UserPrompts.YesNoBox;
            this.inputBox                     = uiContext.UserPrompts.InputBox;
            FileOperations                    = fileOperations;
            FileOperations.LedgerService      = this.ledgerService;
            this.uiContext                    = uiContext;
            this.doNotUseNumberOfMonthsToShow = 2;

            MessengerInstance = uiContext.Messenger;
            MessengerInstance.Register <BudgetReadyMessage>(this, OnBudgetReadyMessageReceived);
            MessengerInstance.Register <StatementReadyMessage>(this, OnStatementReadyMessageReceived);

            this.ledgerService.Saved  += OnSaveNotificationReceieved;
            this.ledgerService.Closed += OnClosedNotificationReceived;
            this.ledgerService.NewDataSourceAvailable += OnNewDataSourceAvailableNotificationReceived;
        }
Beispiel #17
0
        /// <summary>
        /// 期限切れ判定タイマのタイムアウト処理完了時処理
        /// </summary>
        private void ActionTermOutTimerEventOnCompleted()
        {
            UiContext.Post(() =>
            {
                this.UpdateCurrentDateTime();

                this.DgvAllTasksOnUpdateEvent(null, null);
            });
        }
Beispiel #18
0
        static void Main()
        {
            UiContext context = new UiContext(new OrderLogic(), new ProductLogic());

            Application.SetHighDpiMode(HighDpiMode.SystemAware);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FormOrders(context));
        }
 public StylesheetEditor(string xmlFolder, UiContext context)
 {
     Title      = "Stylesheet";
     textEditor = new ColorTextEdit();
     uiContext  = context;
     path       = Path.Combine(xmlFolder, "stylesheet.xml");
     textEditor.SetText(File.ReadAllText(path));
     TextChanged();
 }
Beispiel #20
0
 public MainForm(UiContext context)
 {
     Context = context;
     InitializeComponent();
     customTheme.ApplyToToolStripManager();
     //this.BorderStyle = MetroFormBorderStyle.FixedSingle;
     //this.ShadowType = MetroFormShadowType.AeroShadow;
     this.ApplyDockPanelSkin();
 }
Beispiel #21
0
        RectangleF GetMyRectangle(UiContext context, RectangleF parentRectangle)
        {
            var myPos = context.AnchorPosition(parentRectangle, Anchor, X, Y, Width, Height);

            Update(context, myPos);
            myPos = AnimatedPosition(myPos);
            var myRect = new RectangleF(myPos.X, myPos.Y, Width, Height);

            return(myRect);
        }
Beispiel #22
0
        /// <summary>
        /// 現在時刻更新タイマイベント
        /// </summary>
        /// <param name="state">イベント引数</param>
        private void NowTimerCallBack(object state)
        {
            UiContext.Post(() =>
            {
                var now = DateTime.Now;
                this.LabelDateTime.Text = "現在日時:" + now.ToString("yyyy/MM/dd HH:mm");

                this.DgvAllTasksOnUpdateEvent(null, null);
            });
        }
Beispiel #23
0
        private void ExecuteActivate(object obj)
        {
            UiContext.FromUiContextGuid(new Guid("{CA2D40CF-F606-4FE6-ABEB-5B3E07839C55}"));
            var m = IoC.Get <IUiContextManager>();

            m.GetUiContextCookie(new Guid("{CA2D40CF-F606-4FE6-ABEB-5B3E07839C55}"), out var cookie);
            m.SetUiContext(cookie, true);

            //TestContext.IsActive = true;
        }
Beispiel #24
0
 public SpaceGameplay(FreelancerGame g, CGameSession session) : base(g)
 {
     FLLog.Info("Game", "Entering system " + session.PlayerSystem);
     g.ResourceManager.ClearTextures(); //Do before loading things
     this.session = session;
     sys          = g.GameData.GetSystem(session.PlayerSystem);
     ui           = Game.Ui;
     ui.GameApi   = uiApi = new LuaAPI(this);
     loader       = new LoadingScreen(g, g.GameData.LoadSystemResources(sys));
     loader.Init();
 }
Beispiel #25
0
 public virtual void RunOnUiThread(Action fn)
 {
     if (UiContext == null)
     {
         fn();
     }
     else
     {
         UiContext.Post(_ => fn(), null);
     }
 }
Beispiel #26
0
        protected override void OnLoadUiContext(UiContext context)
        {
            var l = "default";

            if (l == null)
            {
                return;
            }

            //biomeMapComponent1.Init(l);
        }
Beispiel #27
0
 public PickUpUiAdapter(PlayerContext player, SceneObjectContext sceneObject, MapObjectContext mapObject, SessionContext session, VehicleContext vehicle, FreeMoveContext freeMove, UserInputManager.Lib.UserInputManager userInputManager, UiContext uiContext)
 {
     this.player           = player;
     this.sceneObject      = sceneObject;
     this.mapObject        = mapObject;
     this.session          = session;
     this.vehicle          = vehicle;
     this.freeMove         = freeMove;
     this.userInputManager = userInputManager;
     this.uiContext        = uiContext;
 }
Beispiel #28
0
        public ScreenSystem(Contexts contexts)
        {
            _context = contexts.ui;

            contexts.game.GetGroup(GameMatcher.Board).OnEntityAdded +=
                (group, entity, index, component) => GoToScreen(Screen.Game);
            contexts.game.GetGroup(GameMatcher.GameOver).OnEntityAdded +=
                (group, entity, index, component) => GoToScreen(Screen.GameOver);
            contexts.game.GetGroup(GameMatcher.GameOver).OnEntityRemoved +=
                (group, entity, index, component) => GoToScreen(Screen.SelectLevel);
        }
Beispiel #29
0
 protected override void OnLoadUiContext(UiContext context)
 {
     if (_updateTimer == null)
     {
         _updateTimer = new Timer(UpdateLevelList, null, 1000, 1000);
     }
     else
     {
         _updateTimer.Change(250, 250);
     }
 }
Beispiel #30
0
 private void RegisterContext(UiContext.Identifier id, UiContext context)
 {
     if (!_contexts.ContainsKey(id))
     {
         _contexts.Add(id, context);
     }
     else
     {
         Debug.LogWarning("Context" + id + "is trying to be registered again");
     }
 }