Beispiel #1
0
 public HIstoryRepository()
 {
     OperationsList     = new List <Operations>();
     OperationHistories = new List <OperationHistory>();
     LoadingData.LoadOperation();
     LoadingData.LoadHistory();
 }
Beispiel #2
0
        void LoadSimulation(string path)
        {
            Forms.Flowsheet form = null;

            Application.Instance.Invoke(() =>
            {
                form = new Forms.Flowsheet();
            });

            OpenForms   += 1;
            form.Closed += (sender2, e2) =>
            {
                OpenForms -= 1;
            };

            AddUserCompounds(form.FlowsheetObject);

            var loadingdialog = new LoadingData();

            loadingdialog.loadingtext.Text = "Please wait, loading data...\n(" + Path.GetFileNameWithoutExtension(path) + ")";
            loadingdialog.Show();

            Task.Factory.StartNew(() =>
            {
                if (System.IO.Path.GetExtension(path).ToLower() == ".dwxmz")
                {
                    var xdoc = form.FlowsheetObject.LoadZippedXML(path);
                }
                else if (System.IO.Path.GetExtension(path).ToLower() == ".dwxml")
                {
                    form.FlowsheetObject.LoadFromXML(XDocument.Load(path));
                }
                else if (System.IO.Path.GetExtension(path).ToLower() == ".xml")
                {
                    form.FlowsheetObject.LoadFromMXML(XDocument.Load(path));
                }
                form.FlowsheetObject.FilePath = path;
                form.FlowsheetObject.FlowsheetOptions.FilePath = path;
            }).ContinueWith((t) =>
            {
                Application.Instance.Invoke(() =>
                {
                    loadingdialog.Close();
                    var surface = (DWSIM.Drawing.SkiaSharp.GraphicsSurface)form.FlowsheetObject.GetSurface();
                    surface.ZoomAll(ClientSize.Width, ClientSize.Height);
                    surface.ZoomAll(ClientSize.Width, ClientSize.Height);
                    form.FlowsheetObject.UpdateInterface();
                    form.Title = form.FlowsheetObject.Options.SimulationName + " [" + form.FlowsheetObject.Options.FilePath + "]";
                    form.Show();
                    if (!GlobalSettings.Settings.MostRecentFiles.Contains(path))
                    {
                        MostRecentList.Items.Add(new ListItem {
                            Text = path, Key = path
                        });
                        GlobalSettings.Settings.MostRecentFiles.Add(path);
                    }
                    form.FlowsheetObject.ProcessScripts(Interfaces.Enums.Scripts.EventType.SimulationOpened, Interfaces.Enums.Scripts.ObjectType.Simulation, "");
                });
            });
        }
    void Start()
    {
        //If the player wants a game to load, start by trying to load the data
        if (!LocalData.startNewGame)
        {
            //Load game
            gameData = SaveSystem.instance.LoadGame();

            //If there is a save file
            if (gameData != null)
            {
                //Load the saved scene
                LocalData.NextSceneLoader(gameData.getSceneIndex());
            }

            //If not, a load file was not found. Just start a new game
            else
            {
                //Load first level
                LocalData.NextSceneLoader(3);
            }
        }

        //If the player wants a new game, simply load in the first level
        else
        {
            //Load first level
            LocalData.NextSceneLoader(3);
        }
    }
Beispiel #4
0
        private static string[] GetByLoadingData(LoadingData ld)
        {
            var value = levelToControllerIds.Keys.Single(
                k => k.ToString().Equals(ld.ToString(), StringComparison.CurrentCultureIgnoreCase));

            return(levelToControllerIds[value]);
        }
        public void Test1()
        {
            var response = LoadingData.LoadD(3);

            Assert.NotNull(response.Result);
            Assert.IsNotEmpty(response.Result);
            Assert.AreEqual(3, response.Result.Count);
        }
Beispiel #6
0
    void Start()
    {
        //Load level info
        saveData = SaveSystem.instance.LoadGame();

        countText.text = "Keys: " + saveData.getKeys().ToString();
        winStats.SetActive(false);
    }
        public static GameSettings GetDefaultGameSettings(LoadingData loadingData)
        {
            var settings = Dispatcher.Loader.GetCompetitions(loadingData).Logic.CreateDefaultSettings();

            settings.LoadingData = loadingData;
            AddDefaultLogSettings(settings);
            return(settings);
        }
Beispiel #8
0
 public Repository()
 {
     GetPersonals = new ObservableCollection <Personal>();
     GetDeposits  = new ObservableCollection <Deposit>();
     GetCredits   = new ObservableCollection <Credits>();
     GetTypes     = new List <AccountType>();
     ListAccount  = new ObservableCollection <Accounts>();
     LoadingData.LoadData();
 }
Beispiel #9
0
        private void Update(LoadingData data)
        {
            var loadingData = data;

            if (_loadingWindow != null)
            {
                _loadingWindow.Fill(loadingData);
            }
        }
Beispiel #10
0
    public void SaveGame(LoadingData saveData)
    {
        FileStream dataStream = new FileStream(filePath, FileMode.Create);

        BinaryFormatter converter = new BinaryFormatter();

        converter.Serialize(dataStream, saveData);

        dataStream.Close();
    }
Beispiel #11
0
    private void OpenPlay()
    {
        //ScreenPlay.Open ();
        LoadingData loadingData = new LoadingData();

        loadingData.nextScreen         = "Play";
        loadingData.isNextScreenCached = true;
        loadingData.coroutines.Add(Wait());
        ScreenLoading.Open(loadingData);
    }
 private int decrementLoadCount(string resourceName)
 {
     if (loadingCounts.ContainsKey(resourceName))
     {
         LoadingData value = loadingCounts[resourceName];
         value.Count--;
         loadingCounts[resourceName] = value;
         return(loadingCounts[resourceName].Count);
     }
     return(0);
 }
        private void incrementLoadCount(string resourceName, bool isDecoration)
        {
            if (!loadingCounts.ContainsKey(resourceName))
            {
                loadingCounts.Add(resourceName, new LoadingData(0, isDecoration));
            }
            LoadingData value = loadingCounts[resourceName];

            value.Count++;
            loadingCounts[resourceName] = value;
        }
Beispiel #14
0
    public void Initialize()
    {
        this.loadingDataToDisplay = null;
        this.loadingDatas         = new List <LoadingData>();
        this.repositoryPath       = DirectoryFunction.CombinePath(DirectoryFunction.GetMyDocumentsPath(), SaveInformation.root);
        DirectoryFunction.CreateRepository(this.repositoryPath);

        this.InitializeLoadingDatas();
        this.GetMostRecentSave();
        this.partyName = "";
    }
        private void OnLoaded1(LoadingData loadingData, Object obj, int count)
        {
            if (obj == null)
            {
                Debug.LogErrorFormat("[ResourcesHolder] Fail to load file '{0}' !", HashString.GetString(loadingData.key));
                return;
            }
            ResourcesData data = CreateResourcesData(loadingData.type, obj);

            data.refCount = count;
            mLoaded.Add(loadingData.key, data);
            mResourcesToPath.Add(GetResourcesKey(loadingData.type, obj), loadingData.key);
        }
        private void OnLoaded2(LoadingData loadingData, Object obj)
        {
            int  key  = loadingData.key;
            bool flag = mLoadings.Remove(key);

            loadingData.Clear();
            cached_loading_lists.Enqueue(loadingData);
            if (!flag)
            {
                Debug.LogErrorFormat("[ResourcesHolder] in OnLoaded() No callbacks found for '{0}' !",
                                     HashString.GetString(key));
            }
        }
    public static LoadingData UpdateTimer(LoadingData gameData)
    {
        gameData.setTimer(gameData.getTimer() + Time.deltaTime);
        gameData.setSeconds((int)(gameData.getTimer() % 60));

        //If the seconds are equal to or more than 60, a minute has passed. Update accordingly
        if (gameData.getTimer() >= 60)
        {
            gameData.setTimer(0);
            gameData.setMinutes(gameData.getMinutes() + 1);
        }

        return(gameData);
    }//end of UpdateTimer
Beispiel #18
0
        public static void LoadPreviousTime()
        {
            TimeSpan           totalTime;
            List <int>         delays = null;
            List <LoadingData> date   = new List <LoadingData>();

            foreach (var mainPath in MainPaths)
            {
                LoadingData current = new LoadingData();

                using (var sr =
                           new StreamReader(new FileStream(Path.Combine(mainPath, SavingDirectory) + "\\[TOTAL_TIME].txt", FileMode.OpenOrCreate),
                                            Encoding.Unicode))
                {
                    TimeSpan.TryParse(sr.ReadLine()?.Replace(totalTimeAnchor, ""), out current.TotalTime);
                    sr.ReadLine();
                    current.Delays = sr.ReadLine()?.Split(':').Where(t => t.Length > 0).Select(int.Parse).ToList();
                }

                date.Add(current);
            }

            totalTime = date.Select(t => t.TotalTime).Max();

            foreach (var list in date.Select(t => t.Delays).Where(t => t != null).Where(t => t.Any()))
            {
                if (delays == null)
                {
                    delays = list;
                }
                else if (delays.Distinct().Sum() > list.Distinct().Sum())
                {
                    delays = list;
                }
            }

            if (DateTime.Now - totalTime < _startTime)
            {
                _startTime = DateTime.Now - totalTime;
            }

            if (delays != null)
            {
                if (NotificationDelays.Distinct().Sum() > delays.Distinct().Sum())
                {
                    NotificationDelays = delays;
                }
            }
        }
 private bool GetLoadDelegateList(int key, out LoadingData callbackList)
 {
     callbackList = null;
     //List<OnResourcesLoadedDelegate<Object>> callbacks;
     if (mLoadings.TryGetValue(key, out callbackList))
     {
         return(true);
     }
     callbackList = 0 < cached_loading_lists.Count ? cached_loading_lists.Dequeue() : new LoadingData();
     callbackList.onPreCallbacks  = OnLoaded1;
     callbackList.onPostCallbacks = OnLoaded2;
     mLoadings.Add(key, callbackList);
     callbackList.Clear();
     return(false);
 }
Beispiel #20
0
        public MainForm()
        {
            InitializeComponent();
            //dataGridView1.DoubleBuffered(true);  its hiden atm so no need to have it double buffered
            dataGridView2.DoubleBuffered(true);
            panel1.DoubleBuffered(true);
            dataGridView3.DoubleBuffered(true);
            LoadingData.GetListSma(treeView1);
            LoadingData.GetListDat(treeView2);

            toolStripLabel1.Text    = "Sma Count: " + treeView1.GetNodeCount(false).ToString();
            DataGridViewLBL.Text    = "";
            BitmapLBL.Text          = "";
            tabControl1.SelectedTab = tabPage1;
        }
Beispiel #21
0
    public void InitializeLoadingDatas()
    {
        this.directories = DirectoryFunction.GetSubDirectories(this.repositoryPath);
        this.directories.Sort((a, b) => { return((Directory.GetLastWriteTime(a) > Directory.GetLastWriteTime(b)) ? 1 : -1); });
        this.loadingDatas.Clear();

        foreach (string directory in directories)
        {
            LoadingData loadingData = new LoadingData();

            loadingData = SerializationTemplate.Load <LoadingData>(DirectoryFunction.CombinePath(
                                                                       DirectoryFunction.CombinePath(this.repositoryPath, directory), SaveInformation.loadingData));

            this.loadingDatas.Add(loadingData);
        }
    }
    // Update is called once per frame
    void Update()
    {
        //Update in-game timer
        saveData = LocalData.UpdateTimer(saveData);

        //If there are less than 10 seconds in the minute, add a 0 to the front for the width to be consistent
        if (saveData.getSeconds() < 10)
        {
            timerText.text = "" + saveData.getMinutes() + ":0" + saveData.getSeconds();
        }

        else
        {
            timerText.text = "" + saveData.getMinutes() + ":" + saveData.getSeconds();
        }

        CheckKeyCollection();
        CheckWinState();
    }
Beispiel #23
0
        public GameManager()
        {
            root         = null;
            renderWindow = null;
            viewport     = null;
            log          = null;
            timer        = null;

            inputMgr         = null;
            keyboard         = null;
            mouse            = null;
            appStateMgr      = null;
            soundMgr         = null;
            VideoMode        = new NameValuePairList();
            isEditMode       = false;
            isCheatMode      = false;
            loadingData      = new LoadingData(LoadingType.NONE, null, null, null);
            GlobalValueTable = new Dictionary <string, object>();
        }
Beispiel #24
0
    public LoadingData LoadGame()
    {
        if (File.Exists(filePath))
        {
            // File exists
            FileStream dataStream = new FileStream(filePath, FileMode.Open);

            BinaryFormatter converter = new BinaryFormatter();
            LoadingData     saveData  = converter.Deserialize(dataStream) as LoadingData;

            dataStream.Close();
            return(saveData);
        }
        else
        {
            // File does not exist
            Debug.LogError("Save file not found in " + filePath);
            return(null);
        }
    }
Beispiel #25
0
        public GameManager()
        {
            root         = null;
            renderWindow = null;
            viewport     = null;
            log          = null;
            timer        = null;

            inputMgr       = null;
            keyboard       = null;
            mouse          = null;
            trayMgr        = null;
            appStateMgr    = null;
            soundMgr       = null;
            AllGameObjects = new Dictionary <int, GameObject>();
            GameHashMap    = new Dictionary <string, uint>();
            videoMode      = new NameValuePairList();
            isEditMode     = false;
            isCheatMode    = false;
            loadingData    = new LoadingData(LoadingType.NONE, null, null, null);
        }
Beispiel #26
0
    // Use this for initialization
    void Start()
    {
        if (!serverIsRunned)
        {
            Server();
            serverIsRunned = true;
        }
        LoadingData data = new LoadingData();

        data.AssemblyName = AssemblyName;
        data.Level        = Level;

        Element.InitUi();
        var c = new Canvas(new Vector2(100, 100));
        var w = new Window(Sprite, "CVARC Pudge Wars", new Rect(0, 0, kMenuWidth, kMenuHeight));
        var buttonOpenTutorial = new Button(
            () => Dispatcher.GameManager.RequestTutorial(data), SpriteButton, new Rect(50, 50, kButtonWidth, kButtonHeight), "Tutorial");

        w.AddElement(buttonOpenTutorial);
        c.AddElement(w.Head);
    }
Beispiel #27
0
        void LoadSimulation(XDocument xdoc)
        {
            Forms.Flowsheet form = null;

            Application.Instance.Invoke(() =>
            {
                form = new Forms.Flowsheet();
            });

            OpenForms   += 1;
            form.Closed += (sender2, e2) =>
            {
                OpenForms -= 1;
            };

            AddUserCompounds(form.FlowsheetObject);

            var loadingdialog = new LoadingData();

            loadingdialog.loadingtext.Text = "Please wait, loading data...";
            loadingdialog.Show();

            Task.Factory.StartNew(() =>
            {
                form.FlowsheetObject.LoadFromXML(xdoc);
            }).ContinueWith((t) =>
            {
                Application.Instance.Invoke(() =>
                {
                    loadingdialog.Close();
                    var surface = (DWSIM.Drawing.SkiaSharp.GraphicsSurface)form.FlowsheetObject.GetSurface();
                    surface.ZoomAll(ClientSize.Width, ClientSize.Height);
                    surface.ZoomAll(ClientSize.Width, ClientSize.Height);
                    form.FlowsheetObject.UpdateInterface();
                    form.Title = form.FlowsheetObject.Options.SimulationName + " [" + form.FlowsheetObject.Options.FilePath + "]";
                    form.Show();
                    form.FlowsheetObject.ProcessScripts(Interfaces.Enums.Scripts.EventType.SimulationOpened, Interfaces.Enums.Scripts.ObjectType.Simulation, "");
                });
            });
        }
Beispiel #28
0
 public static Dictionary <LoadingData, string[]> GetControllersIdList()
 {
     if (LevelToControllerIds != null)
     {
         return(LevelToControllerIds);
     }
     try
     {
         var service = new TcpClient();
         service.Connect(MultiplayerProxyConfigurations.ServiceEndPoint);
         service.WriteJson(ServiceUnityCommand.GetCompetitionsList);
         LevelToControllerIds =
             service.ReadJson <Dictionary <string, string[]> >()
             .ToDictionary(kvp => LoadingData.Parse(kvp.Key), kvp => kvp.Value);
         return(LevelToControllerIds);
     }
     catch (Exception e)
     {
         log.Error("cant load list of controllers id", e);
         return(null);
     }
 }
Beispiel #29
0
        private IWorld CreateTutorialGame()
        {
            var loadingData = tutorialLoadingData;

            tutorialLoadingData = null;
            var settings = DefaultWorldInfoCreator.GetDefaultGameSettings(loadingData);

            //заполняем ActorSettings, чтобы потом работал ReplayDebugger
            settings.ActorSettings = Dispatcher.Loader.GetCompetitions(loadingData).Logic.Actors.Keys.Select(z => new ActorSettings
            {
                IsBot          = false,
                ControllerId   = z,
                PlayerSettings = new PlayerSettings
                {
                    CvarcTag = Guid.Empty
                }
            }).ToList();

            return(Dispatcher.Loader.CreateWorld(
                       settings,
                       new TutorialControllerFactory(),
                       DefaultWorldInfoCreator.GetDefaultWorldState(loadingData)));
        }
Beispiel #30
0
        public static async Task StartGame(ClientWithSettings[] clientsWithSettings, LoadingData levelName)
        {
            log.Debug("StartGame call");
            var settings = CreateGameSettings(clientsWithSettings, levelName);

            try
            {
                var mainConnection = ConnnectToServer();
                log.Info(JsonConvert.SerializeObject(settings));
                mainConnection.WriteJson(settings);
                mainConnection.WriteJson(WorldState.MakeUndefined());

                foreach (var client in clientsWithSettings.Select(c => c.Client))
                {
                    CreateConnectionBetweenPlayerAndServer(client);
                }

                await GetResultAndSendToWeb(mainConnection, settings);
            }
            catch (SocketException e)
            {
                log.Error("Socket error", e);
            }
            catch (Exception e)
            {
                log.Fatal("UNKNOWN ERROR!", e);
                Console.WriteLine("fatal error");
            }
            finally
            {
                foreach (var clientsWithSetting in clientsWithSettings)
                {
                    clientsWithSetting.Client.Close();
                }
            }
        }