BOOL CLocale::UseCapitalizeInCategoryBuild() { CString csIniFile = GetGlobalPathManager()->ExpandPath(m_csINIFileName); CIniFile IniFile(csIniFile); int nShowNames = IniFile.GetInteger("Locale", "UseCapitalizeInCategoryBuild",1); return (nShowNames == 1); }
void cRoot::LoadWorlds(void) { cIniFile IniFile("settings.ini"); IniFile.ReadFile(); // First get the default world AString DefaultWorldName = IniFile.GetValueSet("Worlds", "DefaultWorld", "world"); m_pDefaultWorld = new cWorld( DefaultWorldName.c_str() ); m_WorldsByName[ DefaultWorldName ] = m_pDefaultWorld; // Then load the other worlds unsigned int KeyNum = IniFile.FindKey("Worlds"); unsigned int NumWorlds = IniFile.GetNumValues( KeyNum ); if (NumWorlds <= 0) { return; } for (unsigned int i = 0; i < NumWorlds; i++) { AString ValueName = IniFile.GetValueName(KeyNum, i ); if (ValueName.compare("World") != 0) { continue; } AString WorldName = IniFile.GetValue(KeyNum, i ); if (WorldName.empty()) { continue; } cWorld* NewWorld = new cWorld( WorldName.c_str() ); m_WorldsByName[ WorldName ] = NewWorld; } // for i - Worlds }
void cPlayer::LoadPermissionsFromDisk() { m_Groups.clear(); m_Permissions.clear(); cIniFile IniFile("users.ini"); if( IniFile.ReadFile() ) { std::string Groups = IniFile.GetValue(m_PlayerName, "Groups", ""); if( Groups.size() > 0 ) { AStringVector Split = StringSplit( Groups, "," ); for( unsigned int i = 0; i < Split.size(); i++ ) { AddToGroup( Split[i].c_str() ); } } else { AddToGroup("Default"); } m_Color = IniFile.GetValue(m_PlayerName, "Color", "-")[0]; } else { LOGWARN("WARNING: Failed to read ini file users.ini"); AddToGroup("Default"); } ResolvePermissions(); }
BOOL CMsregDllApp::UserIsBonusEnabled(void) { BOOL fResult = FALSE; CString csRegistrationCode; TRY { csRegistrationCode = UserIniFile().GetString(ApplicationName(), MSREGUSRINI_Application_RegistrationCode); if (csRegistrationCode == MODEM_REGISTRATION_CODE) { fResult = TRUE; } else { if (!csRegistrationCode.IsEmpty()) { // 6/6/97 (FF) Switched to scheme where registration code is last four digits of // Parent Part Number reversed. CString csParentPartNumber; TRY { csParentPartNumber = GetApp()->IniFile().GetString(MSREGINI_Section_Configuration, MSREGINI_Configuration_ParentPartNumber); if (csParentPartNumber.GetLength() >= 4) { csParentPartNumber.MakeReverse(); csParentPartNumber = csParentPartNumber.Left(4); Util::Trim(csRegistrationCode); if (csRegistrationCode == csParentPartNumber) { fResult = TRUE; } } } END_TRY #if 0 unsigned long lKey = (unsigned long)IniFile().GetLong(MSREGINI_Section_Configuration, MSREGINI_Configuration_Key, 0); if (lKey == KeyFromString(csRegistrationCode)) { fResult = TRUE; } #endif } } }
CString CLocale::HandleBrowserCaption(const CString& csINISection, const CString& csCaption, const CString& csFileName) { CString csIniFile = GetGlobalPathManager()->ExpandPath(m_csINIFileName); CIniFile IniFile(csIniFile); int nShowNames = IniFile.GetInteger(csINISection, "ShowFriendlyNames",1); switch (nShowNames) { case 0: // no friendly names so leave empty; return CString(""); break; case 2: return csFileName; break; case 1: default: return csCaption; } }
// Create the help window. BOOL CPmHelpWindow::Create(LPCSTR pszHelpFile, CWnd* pParentWnd, UINT nIDTemplate, UINT nStyle, UINT uID, int nNavigationTabWidth) { // Save a pointer to the window we want to notify. m_hwndNotify = pParentWnd->GetSafeHwnd(); // Create the dialog bar. BOOL fResult = CDialogBar::Create(pParentWnd, nIDTemplate, nStyle, uID); // Save our ID. m_uID = uID; // Save the width for the navigation tab. m_nNavigationTabWidth = nNavigationTabWidth; if (fResult) { // Hide the window by default. It will be shown later if needed. ShowWindow(SW_HIDE); // Clip children. ModifyStyle(0, WS_CLIPCHILDREN); // Set titlebar text (floating only) CString strTitle = "@@N Help"; GetConfiguration()->ReplaceText(strTitle); SetWindowText(strTitle); // Replace the dummy control in the template with the Html Help control. CWnd* pOldControl = GetDlgItem(IDC_HELP_CONTROL); if (pOldControl != NULL) { fResult = TRUE; // Get the size and position of the dummy control. CRect crBounds; pOldControl->GetWindowRect(crBounds); ScreenToClient(crBounds); // Compute the sizes of the border area around the // help control within the dialog bar. As the dialog // bar is resizes, these borders sizes are retained. m_crBorder.left = crBounds.left; m_crBorder.top = crBounds.top; m_crBorder.right = m_sizeDefault.cx-crBounds.right; m_crBorder.bottom = m_sizeDefault.cy-crBounds.bottom; CRect crCloseButton; crCloseButton.SetRect(0, 0, 12, 12); // size of bitmap m_btnClose.Create(crCloseButton, this, ID_VIEW_HELPWINDOW); m_btnClose.SetBitmaps("HELP_CLOSE_U", "HELP_CLOSE_D", pOurPal); m_btnClose.SetTransparentColor(RGB(255,0,255)); // Restore the previous size of the help window. CRect crHelpWindow; CIniFile IniFile(GET_PMWAPP()->m_pszProfileName); // Restore the previous Expand/Contract state. m_fExpanded = IniFile.GetInteger("HelpWindow", "Expanded", FALSE); if (IniFile.GetWindowPosition("HelpWindow", NULL, NULL, crHelpWindow)) { if (!crHelpWindow.IsRectEmpty()) { m_sizeDefault.cx = crHelpWindow.Width(); m_sizeDefault.cy = crHelpWindow.Height(); } } m_czFloating = m_czDocked = m_sizeDefault; TRY { // Remember the name of the help. m_csHelpFile = pszHelpFile; } END_TRY if ((m_csHelpFile.IsEmpty()) || (!Util::FileExists(m_csHelpFile))) { // Can't use the help file. m_csHelpFile.Empty(); } else { // Load the Html Help control. if (m_HtmlHelpControl.Load()) { // Initialize all structure members to zero. HH_WINTYPE HHWinType; ZeroMemory(&HHWinType, sizeof(HHWinType)); // Structure size in bytes. HHWinType.cbStruct = sizeof(HHWinType); // Properties of the HTML window. HHWinType.fsWinProperties = HHWIN_PROP_TRI_PANE | // use a tri-pane window HHWIN_PROP_TAB_SEARCH | // show a "Search" tab in navigation pane HHWIN_PROP_AUTO_SYNC | // automatically sync contents and index HHWIN_PROP_TRACKING | // send tracking notification messages HHWIN_PROP_NOTB_TEXT | // no text on toolbar buttons HHWIN_PROP_NOTITLEBAR | HHWIN_PROP_NODEF_STYLES | // no default window styles (only HH_WINTYPE.dwStyles) HHWIN_PROP_NODEF_EXSTYLES; // no default extended window styles (only HH_WINTYPE.dwExStyles) // Window styles. HHWinType.dwStyles = WS_VISIBLE | WS_CLIPSIBLINGS | WS_CHILD; // Extended window styles. HHWinType.dwExStyles = WS_EX_WINDOWEDGE; // Buttons on toolbar pane. HHWinType.fsToolBarFlags = HHWIN_BUTTON_EXPAND | // expand/contract button HHWIN_BUTTON_BACK | // back button HHWIN_BUTTON_HOME | // home button // HHWIN_BUTTON_ZOOM | // font button -- too flakey at the moment! HHWIN_BUTTON_PRINT; // print button // Full Paths or CHM locations of various files. CString csInitialTopic; CString csHomePage; CString csTableOfContents; CString csIndex; TRY { csInitialTopic = "contents.htm"; csHomePage = m_csHelpFile; csHomePage += "::/contents.htm"; csTableOfContents = m_csHelpFile; csTableOfContents += "::/toc.hhc"; csIndex = m_csHelpFile; csIndex += "::/index.hhk"; } END_TRY HHWinType.pszFile = csInitialTopic; HHWinType.pszHome = csHomePage; HHWinType.pszToc = csTableOfContents; HHWinType.pszIndex = csIndex; // Expansion width of navigation pane (left pane). HHWinType.iNavWidth = m_nNavigationTabWidth; // Initial display state: HHWinType.nShowState = SW_RESTORE; // TOC should be activated. HHWinType.curNavType = HHWIN_NAVTYPE_TOC; // Position of navigation tabs. HHWinType.tabpos = HHWIN_NAVTAB_TOP; // ID to use in WPARAM in WM_NOTIFY. HHWinType.idNotify = m_uID; // Title of Help Window HHWinType.pszCaption= "PrintMaster 7.0 Help Window"; // Initial state is not expanded. HHWinType.fNotExpanded = !m_fExpanded; // Indicate which fields in structure are valid. HHWinType.fsValidMembers = HHWIN_PARAM_STYLES | // valid dwStyles HHWIN_PARAM_PROPERTIES | // valid fsWinProperties HHWIN_PARAM_RECT | // valid rcWindowPos HHWIN_PARAM_TB_FLAGS | // valid fsToolBarFlags HHWIN_PARAM_NAV_WIDTH | // valid iNavWidth HHWIN_PARAM_SHOWSTATE | // valid nShowState HHWIN_PARAM_TABPOS | // valid tabpos HHWIN_PARAM_EXPANSION | // valid fNotExpanded HHWIN_PARAM_CUR_TAB; // valid curNavType // Specify the name of the new window type. HHWinType.pszType = PM_HELP_TYPE; // Allow any derived classes to modify the window type information. PreSetWinType(&HHWinType); // This call creates the new window type from the values in // the HH_WINTYPE structure. m_HtmlHelpControl.SetWinType(&HHWinType); // Display the default topic. HWND hWnd = NULL; CString csHelpFile; TRY { csHelpFile = m_csHelpFile; csHelpFile += ">" PM_HELP_TYPE; hWnd = m_HtmlHelpControl.DisplayContents(GetSafeHwnd(), csHelpFile); } END_TRY // If we have successfully created a new help window, // then get rid of the old window. if (hWnd != NULL) { // Get rid of the old control. if (pOldControl->DestroyWindow()) { #if 0 // remove the "Flat" style in the toolbar CWnd HelpWindow; HelpWindow.Attach(hWnd); CToolBarCtrl* pToolBar = (CToolBarCtrl*)(HelpWindow.GetWindow(GW_CHILD)); pToolBar->ModifyStyle(TBSTYLE_FLAT, 0); HelpWindow.Detach(); #endif // Signal that all the cached size information is accurate. m_fSizesValid = TRUE; fResult = TRUE; } } } } ASSERT(fResult); if (!fResult) { // We failed, clean up. } }
/** * @brief Constructor. * @param pause_menu the pause menu object * @param game the game */ PauseSubmenuInventory::PauseSubmenuInventory(PauseMenu &pause_menu, Game &game): PauseSubmenu(pause_menu, game) { cursor_sprite = new Sprite("menus/pause_cursor"); IniFile ini = IniFile("hud/inventory.dat", IniFile::READ); ini.set_group("items"); // set the sprites, counters and caption strings std::ostringstream oss; for (int k = 0; k < 28; k++) { // get the item, its counter property and the possession state oss.str(""); oss << "item_" << k; item_names[k] = ini.get_string_value(oss.str()); int variant = equipment.get_item_variant(item_names[k]); ItemProperties &item_properties = equipment.get_item_properties(item_names[k]); if (variant != 0 && item_properties.has_counter()) { // if the player has the item and this item has an amount, we show a counter int amount = equipment.get_item_amount(item_names[k]); int maximum = equipment.get_item_maximum(item_names[k]); int x = 60 + (k % 7) * 32; int y = 81 + (k / 7) * 32; counters[k] = new Counter(2, false, x, y); counters[k]->set_maximum(maximum); counters[k]->set_value(amount); } else { counters[k] = NULL; } // initialize the sprite and the caption string if (variant != 0) { std::ostringstream oss; // sprite sprites[k] = new Sprite("entities/items"); sprites[k]->set_current_animation(item_names[k]); sprites[k]->set_current_direction(variant - 1); // caption string oss.str(""); oss << "inventory.caption.item." << item_names[k] << "." << variant; caption_strings[k] = StringResource::get_string(oss.str()); } else { sprites[k] = NULL; } } // initialize the cursor int index = savegame.get_integer(Savegame::INVENTORY_LAST_ITEM_INDEX); int row = index / 7; int column = index % 7; set_cursor_position(row, column); item_assigned_movement = NULL; }
void cRoot::Start(void) { cDeadlockDetect dd; delete m_Log; m_Log = new cMCLogger(); m_bStop = false; while (!m_bStop) { m_bRestart = false; LoadGlobalSettings(); LOG("Creating new server instance..."); m_Server = new cServer(); LOG("Reading server config..."); cIniFile IniFile("settings.ini"); if (!IniFile.ReadFile()) { LOGWARNING("settings.ini inaccessible, all settings are reset to default values"); } m_PrimaryServerVersion = IniFile.GetValueI("Server", "PrimaryServerVersion", 0); if (m_PrimaryServerVersion == 0) { m_PrimaryServerVersion = cProtocolRecognizer::PROTO_VERSION_LATEST; } else { // Make a note in the log that the primary server version is explicitly set in the ini file LOGINFO("settings.ini: [Server].PrimaryServerVersion set to %d.", m_PrimaryServerVersion); } LOG("Starting server..."); if (!m_Server->InitServer(IniFile)) { LOGERROR("Failed to start server, shutting down."); return; } IniFile.WriteFile(); cIniFile WebIniFile("webadmin.ini"); if (!WebIniFile.ReadFile()) { LOGWARNING("webadmin.ini inaccessible, wabadmin is disabled"); } if (WebIniFile.GetValueB("WebAdmin", "Enabled", false)) { LOG("Creating WebAdmin..."); m_WebAdmin = new cWebAdmin(8080); } LOG("Loading settings..."); m_GroupManager = new cGroupManager(); m_CraftingRecipes = new cCraftingRecipes; m_FurnaceRecipe = new cFurnaceRecipe(); LOG("Loading worlds..."); LoadWorlds(); LOG("Loading plugin manager..."); m_PluginManager = new cPluginManager(); m_PluginManager->ReloadPluginsNow(); LOG("Loading MonsterConfig..."); m_MonsterConfig = new cMonsterConfig; // This sets stuff in motion LOG("Starting Authenticator..."); m_Authenticator.Start(); LOG("Starting worlds..."); StartWorlds(); LOG("Starting deadlock detector..."); dd.Start(); LOG("Starting server..."); m_Server->Start(); #if !defined(ANDROID_NDK) LOG("Starting InputThread..."); m_InputThread = new cThread( InputThread, this, "cRoot::InputThread" ); m_InputThread->Start( false ); // We should NOT wait? Otherwise we can´t stop the server from other threads than the input thread #endif LOG("Initialization done, server running now."); while (!m_bStop && !m_bRestart) // These are modified by external threads { cSleep::MilliSleep(1000); } #if !defined(ANDROID_NDK) delete m_InputThread; m_InputThread = NULL; #endif // Deallocate stuffs LOG("Shutting down server..."); m_Server->Shutdown(); LOG("Shutting down deadlock detector..."); dd.Stop(); LOG("Stopping world threads..."); StopWorlds(); LOG("Stopping authenticator..."); m_Authenticator.Stop(); LOG("Freeing MonsterConfig..."); delete m_MonsterConfig; m_MonsterConfig = NULL; LOG("Stopping WebAdmin..."); delete m_WebAdmin; m_WebAdmin = NULL; LOG("Unloading recipes..."); delete m_FurnaceRecipe; m_FurnaceRecipe = NULL; delete m_CraftingRecipes; m_CraftingRecipes = NULL; LOG("Forgetting groups..."); delete m_GroupManager; m_GroupManager = 0; LOG("Unloading worlds..."); UnloadWorlds(); LOG("Stopping plugin manager..."); delete m_PluginManager; m_PluginManager = NULL; cItemHandler::Deinit(); cBlockHandler::Deinit(); LOG("Destroying server..."); //delete HeartBeat; HeartBeat = 0; delete m_Server; m_Server = 0; LOG("Shutdown done."); } delete m_Log; m_Log = 0; }