public static void switchDBForUpdate() { MessageBox.Show("Есть новая версия базы данных панели." + Environment.NewLine + "Будет произведено обновление с версии " + INIT.USER_BD_VERSION + " до версии " + ACTUAL_DB_VERSION); Thread.Sleep(500); System.Data.SQLite.SQLiteConnection.ClearAllPools(); FileManager.MoveWithReplace(TEMP_DB_SQLITE_FILE, INIT.USER_DB_FILE); // MessageBox.Show(TEMP_DB_SQLITE_FILE + " " + INIT.USER_DB_FILE); Thread.Sleep(500); SQLiteManager userDatarestore = new SQLiteManager(); userDatarestore.setENBInDB(INIT.CURRENT_ENB_OPTION); userDatarestore.setShaderInDB(INIT.CURRENT_SHADER_OPTION); userDatarestore.ConnectionClose(); foreach (int i in INIT.USER_UPDATES_INSTALLED) { SQLiteManager userupd = new SQLiteManager(); userupd.setUpdateInstalled("WINDOW_UPDATES", i); userupd.ConnectionClose(); } MessageBox.Show("Обновление базы данных прошло успешно"); Logger.addLine(true, "Обновление БД панели с версии " + INIT.USER_BD_VERSION + " до версии " + ACTUAL_DB_VERSION); INIT.USER_BD_VERSION = ACTUAL_DB_VERSION; }
private static void setUserSettings(SQLiteManager mngrs) { DataTable userData = mngrs.getListItems("USER_DATA"); CURRENT_ENB_OPTION = userData.Rows[0][0].ToString(); CURRENT_SHADER_OPTION = userData.Rows[0][1].ToString(); }
public static DataTable getENBPresets() { SQLiteManager mngr = new SQLiteManager(); DataTable enb = mngr.getListItems("ENB"); mngr.ConnectionClose(); return(enb); }
private static void setUserGlobals(SQLiteManager mngrs) { DataTable globals = mngrs.getListItems("GLOBALS"); GAME_TITLE = globals.Rows[0][0].ToString(); USER_GAME_VERSION = float.Parse(globals.Rows[0][2].ToString(), CultureInfo.InvariantCulture.NumberFormat); USER_BD_VERSION = Convert.ToInt32(globals.Rows[0][3]); REGISTRY_HIVE = globals.Rows[0][1].ToString(); LOAD_ORDER_FILE = globals.Rows[0][2].ToString(); PLUGINS_TXT_PATH = getpath("plugins_txt"); }
private static void setPathsAndFilesForCheck(SQLiteManager mngrs) { PATHS = new Dictionary <string, string>(); FILES_TO_CHECK = new List <string>(); DataTable data = new DataTable(); data = mngrs.getListItems("FILES"); foreach (DataRow dtRow in data.Rows) { bool fileNeedForCheck = false; string path = ""; if (Convert.ToBoolean(dtRow[3].ToString())) { fileNeedForCheck = true; } if ((dtRow[1].ToString().Equals("gameroot"))) { path = GAME_ROOT + dtRow[2]; } else { if ((dtRow[1].ToString().Equals("userdocs"))) { path = USER_DOCS + dtRow[2]; } else { if ((dtRow[1].ToString().Equals("appdata"))) { path = APPDATA_LOCAL_DIR + dtRow[2]; } else { if ((dtRow[1].ToString().Equals("link"))) { path = dtRow[2].ToString(); } else { } } } } PATHS.Add(dtRow[0].ToString(), path); if (fileNeedForCheck) { FILES_TO_CHECK.Add(path); } } }
private static void setUserInstalledUpdates(SQLiteManager mngrs) { DataTable updateslist = mngrs.getListItems("WINDOW_UPDATES"); USER_UPDATES_INSTALLED = new List <int>(); foreach (DataRow dr in updateslist.Rows) { if (Convert.ToBoolean(dr[5])) { USER_UPDATES_INSTALLED.Add(Convert.ToInt32(dr[0])); } } }
public static void initUserBDGame() { // CTRL_PANEL_DIR = @"J:\Games\TES 5 Skyrim - ESSE 0.6\Control Panel\"; // CTRL_PANEL_DIR = @"D:\TES_DEV\!!!!!!!!!!!!!!!!!!MASS\Control Panel\"; // bumagi // CTRL_PANEL_DIR = @"D:\OblivionPR\Control Panel\"; //корневая директория панели управления - временно // CTRL_PANEL_DIR = AppDomain.CurrentDomain.BaseDirectory; CTRL_PANEL_DIR = Directory.GetParent(Assembly.GetExecutingAssembly().Location) + @"\"; RES_DIR = CTRL_PANEL_DIR + @"Resources\"; //корневая директория ресурсов панели ENB_DIR = CTRL_PANEL_DIR + @"ENB\"; //корневая директория ENB-пресетов SHADER_DIR = CTRL_PANEL_DIR + @"SHADER\"; //корневая директория вариантов шейдеров GAME_ROOT = Path.GetFullPath(Path.Combine(CTRL_PANEL_DIR, @"..\")); DATA_DIR = GAME_ROOT + @"Data\"; ESP_SETTINGS_DIR = RES_DIR + @"esp settings\"; //корневая директория esp файлов для настроеек USER_DOCS = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\"; APPDATA_LOCAL_DIR = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\"; INIT.CURRENT_SHIFTED_PLUGIN_IN_LO = ""; LOG_FILE = CTRL_PANEL_DIR + "cp_log.txt"; GAME_TYPE.init(); SQLiteManager userBDSQLManager = new SQLiteManager(); setPathsAndFilesForCheck(userBDSQLManager); setUserGlobals(userBDSQLManager); setUserSettings(userBDSQLManager); setUserInstalledUpdates(userBDSQLManager); int stylesAmount = userBDSQLManager.getListItems("STYLES").Rows.Count; userBDSQLManager.ConnectionClose(); Random rnd = new Random(); try { STYLE.init(rnd.Next(1, stylesAmount + 1)); DEFAULT_VISUAL_STYLE = false; } catch { DEFAULT_VISUAL_STYLE = true; Logger.addLine(false, "Не удалось загрузить стили оформления. Будет использован стиль по умолчанию"); } }
public static void getnewBD() { if (File.Exists(TEMP_DB_SQLITE_FILE)) { FileManager.remove(TEMP_DB_SQLITE_FILE); } try { new WebClient().DownloadFile(GAME_TYPE.UPDATE_DB_DOWNLOAD_LINK, TEMP_DB_SQLITE_FILE); } catch { throw new NoInternetConnectionException(); } if (File.Exists(TEMP_DB_SQLITE_FILE)) { SQLiteManager newBD = new SQLiteManager(TEMP_DB_CONNECTION_STRING); DataTable dt = newBD.getListItems("GLOBALS"); ACTUAL_DB_VERSION = Convert.ToInt32(dt.Rows[0][3].ToString()); ACTUAL_GAME_VERSION = float.Parse(dt.Rows[0][2].ToString(), CultureInfo.InvariantCulture.NumberFormat); newBD.ConnectionClose(); if (INIT.USER_GAME_VERSION != ACTUAL_GAME_VERSION) { throw new gameBuildInvalidVersionForUpdateException(ACTUAL_GAME_VERSION, INIT.USER_GAME_VERSION); } else { if (INIT.USER_BD_VERSION < ACTUAL_DB_VERSION) { switchDBForUpdate(); } else { return; } } } else { return; } }
public void enable() { if (!noPreset) { DirectoryInfo source = new DirectoryInfo(path); DirectoryInfo target = new DirectoryInfo(INIT.GAME_ROOT); FileManager.CopyAllDirectoryContent(source, target); } ENB_MANAGER.restoreEnbCoreFiles(); SQLiteManager mngr = new SQLiteManager(); mngr.setENBInDB(name); mngr.ConnectionClose(); INIT.CURRENT_ENB_OPTION = name; IsChecked = true; activeNow = true; }
public static void init(int _styleNumber) { styleNumber = _styleNumber; string table = "STYLES"; SQLiteManager mngr = new SQLiteManager(); DataRowCollection styleRows = mngr.getStyle(table, styleNumber); BG_IMAGE_PATH = INIT.RES_DIR + @"Styles\" + styleNumber + @"\mainbg.png"; BUTTON_IMAGE_PATH = INIT.RES_DIR + @"Styles\" + styleNumber + @"\button.png"; ICON_IMAGE_PATH = INIT.RES_DIR + @"Styles\" + styleNumber + @"\favicon.ico"; MUSIC_FILE_PATH = INIT.RES_DIR + @"Styles\" + styleNumber + @"\music.wav"; BG = getImage(IMAGE_TYPES.BG); BUTTON = getImage(IMAGE_TYPES.BUTTON); MAIN_MENU_FOREGROUND = (SolidColorBrush) new BrushConverter().ConvertFromString(styleRows[0][2].ToString()); MAIN_MENU_BORDER_COLOR = (SolidColorBrush) new BrushConverter().ConvertFromString(styleRows[0][4].ToString()); MAIN_MENU_BG_CONTRAST_COLOR = (SolidColorBrush) new BrushConverter().ConvertFromString(styleRows[0][5].ToString()); }
public static void ResetSettings() { try { MessageBox.Show("настройки будут сброшены"); Logger.addLine(true, "Начат сброс настроек" + " : " + DateTime.Now.ToString()); registryFix(INIT.REGISTRY_HIVE, INIT.GAME_ROOT); string table = "RESET"; List <Tuple <string, string> > sourceToTargetList = new List <Tuple <string, string> >(); List <string> removeTargets = new List <string>(); List <string> dirsToCreate = new List <string>(); SQLiteManager mngr = new SQLiteManager(); DataTable data = mngr.getListItems(table); foreach (DataRow dtRow in data.Rows) { if ((dtRow[0].ToString().Equals("copy"))) { string source = INIT.getpath(dtRow[1].ToString()); string target = INIT.getpath(dtRow[2].ToString()); sourceToTargetList.Add(new Tuple <string, string>(source, target)); } else { if ((dtRow[0].ToString().Equals("remove"))) { string fileToRemove = INIT.getpath(dtRow[1].ToString()); removeTargets.Add(fileToRemove); } else { if ((dtRow[0].ToString().Equals("create_dir"))) { string dirToCreate = INIT.getpath(dtRow[1].ToString()); dirsToCreate.Add(dirToCreate); } } } } mngr.ConnectionClose(); FileManager.remove(removeTargets.ToArray()); foreach (string dirs in dirsToCreate) { FileManager.createDirectory(dirs); } foreach (Tuple <string, string> pair in sourceToTargetList) { FileManager.copyFiles(pair.Item1, pair.Item2); } MessageBox.Show("Сброс настроек произведен"); Logger.addLine(true, "Сброс настроек произведен" + " : " + DateTime.Now.ToString()); } catch (Exception) { Logger.addLine(false, "Сброс настроек произвеcти не удалось!" + " : " + DateTime.Now.ToString()); Logger.addLine(true, "Завершение приложения: " + DateTime.Now.ToString()); Environment.Exit(1); } }