BOOL CSkin::LoadFromXML(CXMLElement* pXML, const CString& strPath) { if ( ! pXML->IsNamed( _T("skin") ) ) return FALSE; BOOL bSuccess = FALSE; for ( POSITION pos = pXML->GetElementIterator() ; pos ; ) { CXMLElement* pSub = pXML->GetNextElement( pos ); bSuccess = FALSE; if ( pSub->IsNamed( _T("commandImages") ) ) { if ( ! LoadCommandImages( pSub, strPath ) ) break; } else if ( pSub->IsNamed( _T("commandMap") ) ) { if ( ! LoadCommandMap( pSub ) ) break; } else if ( pSub->IsNamed( _T("menus") ) ) { if ( ! LoadMenus( pSub ) ) break; } else if ( pSub->IsNamed( _T("toolbars") ) ) { if ( ! LoadToolbars( pSub ) ) break; } bSuccess = TRUE; } return bSuccess; }
static int OnModulesLoded(WPARAM, LPARAM) { HookEvent(ME_CLIST_CONTACTICONCHANGED, OnContactIconChanged); HookEvent(ME_SKIN_ICONSCHANGED, OnSkinIconsChanged); HookEvent(ME_CLUI_CONTACTDRAGGING, OnContactDrag); HookEvent(ME_CLUI_CONTACTDROPPED, OnContactDrop); HookEvent(ME_CLUI_CONTACTDRAGSTOP, OnContactDragStop); HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnContactSettingChanged); HookEvent(ME_DB_CONTACT_DELETED, OnContactDeleted); HookEvent(ME_OPT_INITIALISE, OnOptionsInitialize); HookEvent(ME_CLIST_STATUSMODECHANGE, OnStatusModeChange); HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPrebuildContactMenu); hwndMiranda = pcli->hwndContactList; mir_subclassWindow(hwndMiranda, newMirandaWndProc); // No thumbs yet bEnableTip = ServiceExists("mToolTip/ShowTip"); RegisterWindowClass(); GetScreenRect(); LoadDBSettings(); CreateBackgroundBrush(); CreateThumbsFont(); LoadContacts(); LoadMenus(); if (fcOpt.bToTop) { fcOpt.ToTopTime = (fcOpt.ToTopTime < 1) ? 1 : fcOpt.ToTopTime; fcOpt.ToTopTime = (fcOpt.ToTopTime > TOTOPTIME_MAX) ? TOTOPTIME_MAX : fcOpt.ToTopTime; ToTopTimerID = SetTimer(NULL, 0, fcOpt.ToTopTime*TOTOPTIME_P, ToTopTimerProc); } return 0; }
void Gui::ReloadMenus() { UnloadMenus(); LoadMenus(m_guiPath, nullptr); m_activeMenu = m_startupMenu; m_activeMenu->SetActive(); }
extern "C" int __declspec(dllexport) Load() { mir_getLP(&pluginInfoEx); mir_getCLI(); Icon_RegisterT(hInst, _T(MODULE), g_iconList, _countof(g_iconList)); LoadMenus(); InitOptions(); for (int i = 0; i < _countof(s_fonts); i++) { LOGFONT lf; SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, FALSE); if (i == FLT_FONTID_OFFINVIS || i == FLT_FONTID_INVIS) lf.lfItalic = !lf.lfItalic; COLORREF defColor = GetSysColor((i == FLT_FONTID_NOTONLIST) ? COLOR_3DSHADOW : COLOR_WINDOWTEXT); char szId[20]; mir_snprintf(szId, "Font%d", i); FontService_RegisterFont(MODULE, szId, LPGENT("Floating contacts"), s_fonts[i], NULL, NULL, i + 1, false, &lf, defColor); } HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoded); HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreshutdown); return 0; }
bool Gui::Startup(const char * a_guiPath, const DataPack * a_dataPack) { // Cache off the gui path for later use when loading menus strncpy(m_guiPath, a_guiPath, strlen(a_guiPath) + 1); // Load in the gui config file char fileName[StringUtils::s_maxCharsPerLine]; sprintf(fileName, "%s%s", a_guiPath, "gui.cfg"); if (a_dataPack != NULL && a_dataPack->IsLoaded()) { if (DataPackEntry * guiConfig = a_dataPack->GetEntry(fileName)) { m_configFile.Load(guiConfig); } } else { m_configFile.Load(fileName); } // Setup the debug menu root element m_debugRoot.SetName("DebugMenu"); m_debugRoot.SetActive(false); m_debugRoot.SetDebugWidget(); // Load menus from data LoadMenus(a_guiPath, a_dataPack); // There are no menus loaded if (m_menus.GetLength() == 0) { Log::Get().Write(LogLevel::Warning, LogCategory::Engine, "No menus loaded, a default menu has been created."); // Create one and add it to the list Widget * defaultMenu = new Widget(); defaultMenu->SetName("New Menu"); sprintf(fileName, "%s%s", a_guiPath, "newMenu.mnu"); defaultMenu->SetFilePath(fileName); defaultMenu->SetActive(false); MenuListNode * newMenuNode = new MenuListNode(); newMenuNode->SetData(defaultMenu); m_menus.Insert(newMenuNode); } // Default the active menu if (m_startupMenu == NULL) { Log::Get().WriteGameErrorNoParams("No menu found with beginLoaded set to true, defaulting to the first menu loaded!"); m_startupMenu = m_menus.GetHead()->GetData(); } m_activeMenu = m_startupMenu; m_activeMenu->SetActive(); // Setup the mouse cursor element if present in config file m_cursor.SetActive(false); if (GameFile::Object * configObj = m_configFile.FindObject("config")) { if (GameFile::Property * mouseCursorProp = configObj->FindProperty("mouseCursorTexture")) { m_cursor.SetTexture(TextureManager::Get().GetTexture(mouseCursorProp->GetString(), TextureCategory::Gui)); m_cursor.SetAlignment(AlignX::Middle, AlignY::Centre); m_cursor.SetOffset(Vector2(0.0f, 0.0f)); m_cursor.SetSize(Vector2(0.16f / RenderManager::Get().GetViewAspect(), 0.16f)); m_cursor.SetActive(true); } } // Setup input callbacks for handling events, left mouse buttons activate gui elements InputManager & inMan = InputManager::Get(); inMan.RegisterMouseCallback(this, &Gui::MouseInputHandler, MouseButton::Left); inMan.RegisterMouseCallback(this, &Gui::MouseInputHandler, MouseButton::Right); return true; }