using System; using Woodpecker.Data; namespace Woodpecker.Core { /// /// Keeps settings loaded from woodpecker_config for usage by the application. /// public static class Config { #region Declares /// /// The set of characters that the client is allowed to use in the session. /// public static string Client_characterSet; /// /// The default motto that users gain at registration. /// public static string Registration_Motto; /// /// The amount of credits that users gain at registration. /// public static int Registration_Credits; /// /// The amount of tickets that users gain at registration. /// public static int Registration_Tickets; /// /// The amount of films that users gain at registration. /// public static int Registration_Films; /// /// Indicates if to log transactions by users. (purchases of items etc) /// public static bool logTransactions; /// /// The max amount of rooms to show when opening a category in the Hotel Navigator. /// public static int Rooms_Navigator_openCategory_maxResults; /// /// The max amount of rooms to show when searching a guestroom in the Hotel Navigator. /// public static int Rooms_Navigator_searchGuestroom_maxResults; /// /// The max amount of guestrooms that a user can have. When this amount is reached, no new rooms can be created until one is destroyed. /// public static int Rooms_guestRooms_maxPerUser; /// /// The max amount of rooms that a user can have in it's favorite rooms list. When this amount is reached, no new rooms can be added until one is removed from the list. /// public static int Rooms_Favorites_maxPerUser; #endregion #region Methods /// /// Initializes various settings from the woodpeckerconfig table and stores them in this class. /// public static void Init() { Logging.logHolyInfo("Initializing configuration..."); Client_characterSet = getStringEntry("client.charset"); Registration_Motto = getStringEntry("users.registration.motto"); Registration_Credits = getNumericEntry("users.registration.credits"); Registration_Tickets = getNumericEntry("users.registration.tickets"); Registration_Films = getNumericEntry("users.registration.films"); logTransactions = (getStringEntry("users.transactions.enabled") == "1"); Rooms_Navigator_openCategory_maxResults = getNumericEntry("rooms.navigator.opencategory.max"); Rooms_Navigator_searchGuestroom_maxResults = getNumericEntry("rooms.navigator.searchguestroom.max"); Rooms_guestRooms_maxPerUser = getNumericEntry("rooms.guestrooms.maxperuser"); Rooms_Favorites_maxPerUser = getNumericEntry("rooms.favorites.maxperuser"); Logging.logHolyInfo("Configuration initialized."); } /// /// Gets the value from a config entry in woodpecker_config table, and returns it as a string. /// /// The key of the config entry. public static string getStringEntry(string Key) { return Database.runRead("SELECT cvalue FROM woodpecker_config WHERE ckey = '" + Key + "'"); } /// /// Gets the value from a config entry in woodpecker_config table, and returns it as an integer. /// /// The key of the config entry. public static int getNumericEntry(string Key) { return Database.runReadInteger("SELECT cvalue FROM woodpecker_config WHERE ckey = '" + Key + "'"); } #endregion } }