Пример #1
0
    public void CleanUp()
    {
        DataModel   = new SettingDataModel();
        BackUpModel = new SettingDataModel();

        DataModel.SystemSetting.Sound[0] = PlayerPrefs.GetInt(SoundManager.BGMPrefsKey, 1) == 0;
        DataModel.SystemSetting.Sound[1] = PlayerPrefs.GetInt(SoundManager.SFXPrefsKey, 1) == 0;
        SoundManager.Instance.EnableBGM  = !DataModel.SystemSetting.Sound[0];
        SoundManager.Instance.EnableSFX  = !DataModel.SystemSetting.Sound[1];

        var QualityLevel = PlayerPrefs.GetInt(GameSetting.GameQuilatyKey, GameSetting.Instance.GameQualityLevel);

        DataModel.SystemSetting.QualityToggle = QualityLevel;
        var resolutionLevel = PlayerPrefs.GetInt(GameSetting.GameResolutionKey, GameSetting.Instance.GameResolutionLevel);

        DataModel.SystemSetting.Resolution = resolutionLevel;

        var lowFps = PlayerPrefs.GetInt(GameSetting.LowFpsKey, 30);

        DataModel.SystemSetting.Other[7] = (lowFps == 30);

        RegisterPropertyChanged();

        var tbConfig = Table.GetClientConfig(1007);
        var lowfps   = tbConfig.Value.ToInt();

        if (lowfps > 1)
        {
            lowFrameTime = 1f / lowfps;
        }
    }
Пример #2
0
        public IActionResult Settings(SettingViewModel settingViewModel)
        {
            SettingDataModel settingDataModel = applicationContext.Settings.FirstOrDefault(o => o.Id == 1);

            if (ModelState.IsValid)
            {
                if (!(settingViewModel.Logo == null || settingViewModel.Logo.Length <= 0))
                {
                    using (var memoryStream = new MemoryStream())
                    {
                        settingViewModel.Logo.CopyTo(memoryStream);
                        settingDataModel.Logo = memoryStream.ToArray();
                    }
                }

                if (!(settingViewModel.Background == null || settingViewModel.Background.Length <= 0))
                {
                    System.IO.File.Delete(".//wwwroot//images//Background.png");
                    using (var fileStream = new FileStream(".//wwwroot//images//Background.png", FileMode.Create))
                    {
                        settingViewModel.Background.CopyTo(fileStream);
                    }
                }

                settingDataModel.Title = settingViewModel.Title;

                this.applicationContext.Update(settingDataModel);
                this.applicationContext.SaveChanges();
            }

            ViewBag.LogoToBytes = settingDataModel.Logo;

            return(View(settingViewModel));
        }
Пример #3
0
        public IActionResult Settings(SettingViewModel settingViewModel)
        {
            SettingDataModel settingDataModel = applicationDbContext.Settings.FirstOrDefault(o => o.Id == 1);

            if (ModelState.IsValid)
            {
                if (!(settingViewModel.Logo == null || settingViewModel.Logo.Length <= 0))
                {
                    using (var memoryStream = new MemoryStream())
                    {
                        settingViewModel.Logo.CopyTo(memoryStream);
                        settingDataModel.Logo = memoryStream.ToArray();
                    }
                }

                settingDataModel.Title = settingViewModel.Title;

                this.applicationDbContext.Update(settingDataModel);
                this.applicationDbContext.SaveChanges();
            }

            ViewBag.LogoToBytes = settingDataModel.Logo;

            return(View(settingViewModel));
        }
Пример #4
0
        /// <summary>
        /// 設定を保存します。
        /// </summary>
        /// <param name="data"></param>
        public static void Save(SettingDataModel data)
        {
            var json = JsonConvert.SerializeObject(data);

            using var wr = new StreamWriter(SettingPath, false);

            wr.WriteLine(json);
        }
Пример #5
0
        public IActionResult Settings()
        {
            SettingDataModel settingDataModel = applicationContext.Settings.FirstOrDefault(o => o.Id == 1);

            SettingViewModel settingViewModel = new SettingViewModel();

            settingViewModel.Title = settingDataModel.Title;

            ViewBag.LogoToBytes = settingDataModel.Logo;

            return(View(settingViewModel));
        }
Пример #6
0
        private void OnEnable()
        {
        #if !UNITY_EDITOR
            try
            {
        #endif
            if (deleteBind)
            {
                EventDispatcher.Instance.AddEventListener(CloseUiBindRemove.EVENT_TYPE, OnEvent_CloseUI);
                EventDispatcher.Instance.AddEventListener(SettingUIModifyPlayerNameEvent.EVENT_TYPE, OnSettingUIModifyPlayerNameEvent);

                var controllerBase = UIManager.Instance.GetController(UIConfig.SettingUI);
                if (controllerBase == null)
                {
                    return;
                }
                var source    = controllerBase.GetDataModel("");
                var dataModel = source as SettingDataModel;
                settingDataModel = dataModel;
                if (dataModel != null)
                {
                    var quality = dataModel.SystemSetting.QualityToggle;
                    QualityLabel.text = QualityList.items[quality - 1];
                    // QualityList.value = QualityLabel.text;
                    // var resolution = dataModel.SystemSetting.Resolution;
                    // ResolutionLabel.text = ResolutionList.items[resolution - 1];
                    // ResolutionList.value = ResolutionLabel.text;
                }
                Binding.SetBindDataSource(source);
                Binding.SetBindDataSource(PlayerDataManager.Instance.PlayerDataModel);
            }
            deleteBind = true;

        #if !UNITY_EDITOR
        }

        catch (Exception ex)
        {
            Logger.Error(ex.ToString());
        }
        #endif
        }
Пример #7
0
        /// <summary>
        /// 設定をロードします。ファイルがない場合は既定値で新しく生成します。
        /// </summary>
        /// <returns></returns>
        public static SettingDataModel Load()
        {
            var json = string.Empty;

            if (!File.Exists(SettingPath))
            {
                var def = new SettingDataModel();
                Save(def);
                return(def);
            }

            using (var sr = new StreamReader(SettingPath))
            {
                json = sr.ReadToEnd();
            }

            var data = JsonConvert.DeserializeObject <SettingDataModel>(json);

            return(data);
        }
Пример #8
0
        public static async Task MainAsync(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

            try
            {
                using (var scope = host.Services.CreateScope())
                {
                    using (var applicationContext = scope.ServiceProvider.GetService <ApplicationDbContext>())
                    {
                        await applicationContext.Database.EnsureCreatedAsync();

                        BlogDataModel   blogDataModel   = null;
                        ApplicationUser applicationUser = null;

                        using (var roleManager = scope.ServiceProvider.GetService <RoleManager <IdentityRole> >())
                        {
                            if (!await roleManager.RoleExistsAsync("Administrator"))
                            {
                                await roleManager.CreateAsync(new IdentityRole("Administrator"));
                            }

                            if (!await roleManager.RoleExistsAsync("Writer"))
                            {
                                await roleManager.CreateAsync(new IdentityRole("Writer"));
                            }
                        }

                        using (var userManager = scope.ServiceProvider.GetService <UserManager <ApplicationUser> >())
                        {
                            if (!applicationContext.Users.Any())
                            {
                                applicationUser          = new ApplicationUser();
                                applicationUser.UserName = "******";
                                applicationUser.Email    = "*****@*****.**";
                                applicationUser.Image    = System.IO.File.ReadAllBytes(".//wwwroot//images//ProfilPicture.png");

                                await userManager.CreateAsync(applicationUser, "adminPassword");

                                await userManager.AddToRoleAsync(applicationUser, "Administrator");
                            }
                        }

                        if (!applicationContext.Blogs.Any())
                        {
                            blogDataModel = new BlogDataModel
                            {
                                Cover       = System.IO.File.ReadAllBytes(".//wwwroot//images//Logo.png"),
                                Created     = DateTime.Now,
                                Description = "Welcome to Reddnet a Asp.Net Core mini Reddit",
                                Name        = "Welcome"
                            };

                            applicationContext.Blogs.Add(blogDataModel);
                        }

                        if (!applicationContext.Posts.Any())
                        {
                            PostDataModel postDataModel = new PostDataModel
                            {
                                Pinned    = true,
                                Archieved = true,
                                Blog      = blogDataModel,
                                Author    = applicationUser,
                                Title     = "Welcome to r/Welcome and Reddnet a Asp.Net Core mini Reddit",
                                Preview   = "Hello visitor this is not an serious Project that goes online",
                                Content   = "Hello visitor this is not an serious Project that goes online! <br> i only want to make an mini Reddit Clone to learn Asp.Net Core <br> And i wan´t to share it with your all!",
                                Link      = "https://github.com/cetoxx/Reddnet",
                                Cover     = System.IO.File.ReadAllBytes(".//wwwroot//images//Logo.png")
                            };

                            applicationContext.Posts.Add(postDataModel);
                        }

                        if (!applicationContext.Settings.Any())
                        {
                            SettingDataModel settingDataModel = new SettingDataModel
                            {
                                Title = "Reddnet",
                                Logo  = System.IO.File.ReadAllBytes(".//wwwroot//images//Logo.png")
                            };

                            applicationContext.Settings.Add(settingDataModel);
                        }

                        await applicationContext.SaveChangesAsync();
                    }
                }
            } catch { }
            await host.RunAsync();
        }