Example #1
0
        public bool CheckForUpdates()
        {
            // try to download version control
            try
            {
                using (System.Net.WebClient client = new System.Net.WebClient())
                {
                    client.DownloadFile(downloadLocation + "versioncontrol.txt", basePath + "vc.txt");
                }
            }
            catch
            {
                // if failed then just ignore auto-update
                return(false);
            }

            Stream stream = new FileStream(basePath + "vc.txt", FileMode.Open);

            config = new Burntime.Platform.IO.ConfigFile();
            config.Open(stream);
            stream.Close();

            newVersion = config[""].GetString("version");
            int current = ParseVersionNumber(newVersion);

            savegameCompatible = config[curVersion].GetBool("savegame_compatible");

            File.Delete(basePath + "vc.txt");

            return(current > version);
        }
Example #2
0
        public Updater(string basePath)
        {
            this.basePath = basePath;
            systemPath    = basePath + "system/";
            gamePath      = basePath + "game/";
            if (IsUpdateMode)
            {
                systemPath = basePath = "../system/";
                gamePath   = basePath = "../game/";
            }

            // open settings
            FileStream settingsStream = new FileStream(systemPath + "settings.txt", FileMode.Open);

            settings = new Burntime.Platform.IO.ConfigFile();
            settings.Open(settingsStream);
            settingsStream.Close();

            // read settings
            alwaysCheck      = settings["autoupdate"].GetBool("always_check");
            alwaysAsk        = settings["autoupdate"].GetBool("always_ask");
            downloadLocation = settings["autoupdate"].GetString("location");

            // read local version
            curVersion = settings["autoupdate"].GetString("version");
            version    = ParseVersionNumber(curVersion);

            // delete previous temporary copy if necessary
            DeleteTemporaryCopy();
        }
Example #3
0
        void infoDownloader_DoWork(object sender, DoWorkEventArgs e)
        {
            // download supported language info
            HttpHelper http   = new HttpHelper();
            Stream     stream = http.DownloadFileToMemory(downloadPath + "lang.txt");

            if (stream != null)
            {
                // read supoorted language info
                Burntime.Platform.IO.ConfigFile languageInfo = new Burntime.Platform.IO.ConfigFile();
                languageInfo.Open(stream);
                supportedLanguage = languageInfo[""].GetStrings("supported");
                defaultLanguage   = languageInfo[""].GetString("default");

                // select default language
                language = defaultLanguage;

                // choose language
                foreach (string code in supportedLanguage)
                {
                    if (code.Equals(Program.VFS.LocalizationCode, StringComparison.InvariantCultureIgnoreCase))
                    {
                        language = Program.VFS.LocalizationCode;
                        break;
                    }
                }

                language = language.ToLower();

                // open config
                stream    = http.DownloadFileToMemory(downloadPath + "downloads.txt");
                downloads = new Burntime.Platform.IO.ConfigFile();
                downloads.Open(stream);
                stream.Close();
                stream = http.DownloadFileToMemory(downloadPath + this.language + "/lang.txt");
                text   = new Burntime.Platform.IO.ConfigFile();
                text.Open(stream);
                stream.Close();
            }

            readyFlag = true;
        }
Example #4
0
        public MenuScene(Module App)
            : base(App)
        {
            Background = "sta.pac";
            Music      = "15_MUS 15_HSC.ogg";
            Position   = (app.Engine.GameResolution - new Vector2(320, 200)) / 2;

            // face
            PlayerOneFace           = new FaceWindow(App);
            PlayerOneFace.MaxFaceID = 5;
            PlayerOneFace.Position  = new Vector2(33, 28);
            PlayerOneFace.Group     = 3;
            Windows                += PlayerOneFace;
            PlayerTwoFace           = new FaceWindow(App);
            PlayerTwoFace.MaxFaceID = 5;
            PlayerTwoFace.Position  = new Vector2(223, 28);
            PlayerTwoFace.Group     = 3;
            Windows                += PlayerTwoFace;

            // face slides
            Image image = new Image(App, "sta.ani?10-16");

            image.Position = new Vector2(30, 26);
            image.Layer++;
            PlayerOneSlide = image.Background.Animation;
            Windows       += image;
            image          = new Image(App, "sta.ani?10-16");
            image.Position = new Vector2(220, 26);
            image.Layer++;
            PlayerTwoSlide = image.Background.Animation;
            Windows       += image;

            PlayerOneSlide.Speed = 10;
            PlayerTwoSlide.Speed = 10;

            PlayerOneSlide.Endless = false;
            PlayerOneSlide.Stop();
            PlayerOneSlide.GoLastFrame();
            PlayerTwoSlide.Endless = false;
            PlayerTwoSlide.Stop();
            PlayerTwoSlide.GoLastFrame();

            // buttons
            Button button = new Button(App);

            button.Position   = new Vector2(131, 42);
            button.Image      = "sta.ani?17";
            button.HoverImage = "sta.ani?18";
            button.Command   += OnButtonStart;
            Windows          += button;
            button            = new Button(App);
            button.Position   = new Vector2(131, 15);
            button.Image      = "sta.ani?19";
            button.HoverImage = "sta.ani?20";
            button.Command   += OnButtonLoad;
            Windows          += button;

            // exit button
            button            = new Button(App);
            button.Image      = "gfx/menu_exit.png";
            button.HoverImage = "gfx/menu_exit_hover.png";
            button.Position   = new Vector2(276, 163);
            button.Command   += OnButtonExit;
            Windows          += button;

            // player names
            PlayerOneSwitch              = new NameWindow(App);
            PlayerOneSwitch.Position     = new Vector2(15, 92);
            PlayerOneSwitch.Image        = "sta.ani?6";
            PlayerOneSwitch.DownImage    = "sta.ani?7";
            PlayerOneSwitch.DownCommand += OnPlayerOneDown;
            PlayerOneSwitch.UpCommand   += OnPlayerOneUp;
            PlayerOneSwitch.Command     += OnPlayerOneClick;
            PlayerOneSwitch.Font         = new GuiFont(BurntimeClassic.FontName, new PixelColor(184, 184, 184));
            Windows                     += PlayerOneSwitch;
            PlayerTwoSwitch              = new NameWindow(App);
            PlayerTwoSwitch.Position     = new Vector2(204, 92);
            PlayerTwoSwitch.Image        = "sta.ani?6";
            PlayerTwoSwitch.DownImage    = "sta.ani?7";
            PlayerTwoSwitch.DownCommand += OnPlayerTwoDown;
            PlayerTwoSwitch.UpCommand   += OnPlayerTwoUp;
            PlayerTwoSwitch.Command     += OnPlayerTwoClick;
            PlayerTwoSwitch.Font         = new GuiFont(BurntimeClassic.FontName, new PixelColor(184, 184, 184));
            Windows                     += PlayerTwoSwitch;

            // color
            Radio radio = new Radio(App);

            radio.Position  = new Vector2(45, 121);
            radio.Image     = "sta.ani?8";
            radio.DownImage = "sta.ani?9";
            radio.Mode      = RadioMode.Round;
            radio.Group     = 2;
            Color           = radio;
            Windows        += radio;
            radio           = new Radio(App);
            radio.IsDown    = true;
            radio.Position  = new Vector2(237, 121);
            radio.Image     = "sta.ani?8";
            radio.DownImage = "sta.ani?9";
            radio.Mode      = RadioMode.Round;
            radio.Group     = 2;
            Windows        += radio;

            // difficulty
            for (int i = 0; i < 3; i++)
            {
                radio = new Radio(App);
                if (i == 0)
                {
                    radio.IsDown = true;
                    Difficulty   = radio;
                }
                radio.Position   = new Vector2(100 + 45 * i, 149);
                radio.Image      = "sta.ani?" + (i * 2).ToString();
                radio.HoverImage = "sta.ani?" + (i * 2 + 1).ToString();
                radio.DownImage  = "sta.ani?" + (i * 2 + 1).ToString();
                radio.Group      = 1;
                Windows         += radio;
            }

            // input conversion
            conversionTable = new Burntime.Platform.IO.ConfigFile();
            conversionTable.Open(Burntime.Platform.IO.FileSystem.GetFile("conversion_table.txt"));
            PlayerOneSwitch.Table = conversionTable;
            PlayerTwoSwitch.Table = conversionTable;
        }