2_menus.cpp

  name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-5572165936844014&dt=1194442938015&lmt=1194190197&format=336x280_as&output=html&correlator=1194442937843&url=file%3A%2F%2F%2FC%3A%2FDocuments%2520and%2520Settings%2Flhh1%2F%E6%A1%8C%E9%9D%A2%2FCLanguage.htm&color_bg=FFFFFF&color_text=000000&color_link=000000&color_url=FFFFFF&color_border=FFFFFF&ad_type=text&ga_vid=583001034.1194442938&ga_sid=1194442938&ga_hid=1942779085&flash=9&u_h=768&u_w=1024&u_ah=740&u_aw=1024&u_cd=32&u_tz=480&u_java=true" frameborder="0" width="336" scrolling="no" height="280" allowtransparency="allowtransparency"> #include <windows.h> 
#include "2_menus.h"


#if defined (WIN32)
 #define IS_WIN32 TRUE
#else
 #define IS_WIN32 FALSE
#endif

#define IS_NT      IS_WIN32 && (BOOL)(GetVersion() < 0x80000000)
#define IS_WIN32S  IS_WIN32 && (BOOL)(!(IS_NT) && (LOBYTE(LOWORD(GetVersion()))<4))
#define IS_WIN95   (BOOL)(!(IS_NT) && !(IS_WIN32S)) && IS_WIN32

HINSTANCE hInst;   // current instance

LPCTSTR lpszAppName  = "MyApp";
LPCTSTR lpszTitle    = "My Application";

BOOL RegisterWin95( CONST WNDCLASS* lpwc );

int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
                      LPTSTR lpCmdLine, int nCmdShow)
{
   MSG      msg;
   HWND     hWnd;
   WNDCLASS wc;

   // Register the main application window class.
   //............................................
   wc.style         = CS_HREDRAW | CS_VREDRAW;
   wc.lpfnWndProc   = (WNDPROC)WndProc;      
   wc.cbClsExtra    = 0;                     
   wc.cbWndExtra    = 0;                     
   wc.hInstance     = hInstance;             
   wc.hIcon         = LoadIcon( hInstance, lpszAppName );
   wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
   wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
   wc.lpszMenuName  = "OLDMENU";             
   wc.lpszClassName = lpszAppName;             

   if ( IS_WIN95 )
   {
      if ( !RegisterWin95( &wc ) )
         return( FALSE );
   }
   else if ( !RegisterClass( &wc ) )
      return( FALSE );

   hInst = hInstance;

   // Create the main application window.
   //....................................
   hWnd = CreateWindow( lpszAppName,
                        lpszTitle,   
                        WS_OVERLAPPEDWINDOW,
                        CW_USEDEFAULT, 0,
                        CW_USEDEFAULT, 0, 
                        NULL,             
                        NULL,             
                        hInstance,        
                        NULL              
                      );

   if ( !hWnd )
      return( FALSE );

   ShowWindow( hWnd, nCmdShow );
   UpdateWindow( hWnd );        

   while( GetMessage( &msg, NULL, 0, 0) )  
   {
      TranslateMessage( &msg );
      DispatchMessage( &msg ); 
   }

   return( msg.wParam );
}


BOOL RegisterWin95( CONST WNDCLASS* lpwc )
{
   WNDCLASSEX wcex;

   wcex.style         = lpwc->style;
   wcex.lpfnWndProc   = lpwc->lpfnWndProc;
   wcex.cbClsExtra    = lpwc->cbClsExtra;
   wcex.cbWndExtra    = lpwc->cbWndExtra;
   wcex.hInstance     = lpwc->hInstance;
   wcex.hIcon         = lpwc->hIcon;
   wcex.hCursor       = lpwc->hCursor;
   wcex.hbrBackground = lpwc->hbrBackground;
   wcex.lpszMenuName  = lpwc->lpszMenuName;
   wcex.lpszClassName = lpwc->lpszClassName;

   // Added elements for Windows 95.
   //...............................
   wcex.cbSize = sizeof(WNDCLASSEX);
   wcex.hIconSm = LoadImage(wcex.hInstance, lpwc->lpszClassName,
                            IMAGE_ICON, 16, 16,
                            LR_DEFAULTCOLOR );
   
   return RegisterClassEx( &wcex );
}

LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
static HMENU hMenu = NULL;

   switch( uMsg )
   {
      case WM_COMMAND :
              switch( LOWORD( wParam ) )
              {
                 case IDM_OLD :
                 case IDM_NEW :
                        {
                           HMENU hNewMenu;

                           if ( LOWORD( wParam ) == IDM_NEW )
                              hNewMenu = LoadMenu( hInst, "NEWMENU" );
                           else
                              hNewMenu = LoadMenu( hInst, "OLDMENU" );

                           SetMenu( hWnd, hNewMenu );

                           if ( IsMenu( hMenu ) )
                              DestroyMenu( hMenu );

                           hMenu = hNewMenu;
                           DrawMenuBar( hWnd );
                        }
                        break;

                 case IDM_ABOUT :
                        DialogBox( hInst, "AboutBox", hWnd, (DLGPROC)About );
                        break;

                 case IDM_EXIT :
                        DestroyWindow( hWnd );
                        break;
              }
              break;
     
      case WM_DESTROY :
              PostQuitMessage(0);
              break;

      default :
            return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
   }

   return( 0L );
}


LRESULT CALLBACK About( HWND hDlg,          
                        UINT message,       
                        WPARAM wParam,      
                        LPARAM lParam)
{
   switch (message)
   {
       case WM_INITDIALOG:
               return (TRUE);

       case WM_COMMAND:                             
               if (   LOWORD(wParam) == IDOK        
                   || LOWORD(wParam) == IDCANCEL)   
               {
                       EndDialog(hDlg, TRUE);       
                       return (TRUE);
               }
               break;
   }

   return (FALSE);
}

// ====== 环境修复代码(确保全局对象安全) ====== (function() { if (cc && cc.sys && cc.sys.isNative) { try { console.log('[EnvFix] Applying environment patches for', cc.sys.os); // 可靠获取全局对象的多平台兼容方案 const getGlobalObject = () => { // 优先级1: Cocos Creator 的全局对象 if (typeof cc !== 'undefined' && cc.game && cc.game.globalObject) { return cc.game.globalObject; } // 优先级2: Node.js 环境 if (typeof global !== 'undefined') return global; // 优先级3: 浏览器环境 if (typeof window !== 'undefined') return window; // 优先级4: Web Worker 环境 if (typeof self !== 'undefined') return self; // 终极回退方案 return Function('return this')() || {}; }; const globalObj = getGlobalObject(); // 修复关键全局变量缺失问题 if (typeof global === 'undefined') global = globalObj; if (typeof self === 'undefined') self = globalObj; if (typeof globalThis === 'undefined') globalThis = globalObj; // 确保全局对象上有 self 属性 if (globalObj && typeof globalObj.self === 'undefined') { Object.defineProperty(globalObj, 'self', { value: globalObj, writable: false, configurable: false, enumerable: false }); console.log('[EnvFix] Added self to global object'); } // 验证修复结果 console.log('[EnvFix] Verification:', { global: typeof global, self: typeof self, globalThis: typeof globalThis, equality: self === global && global === globalThis }); } catch (e) { console.error('[EnvFix] Failed:', e); } } else { console.log('[EnvFix] Skipping for non-native platform'); } })(); // ====== 改进的引擎初始化保护系统 ====== const EngineReady = (function() { let _promise = null; let _resolve = null; let _isReady = false; let _checkInterval = null; return { get isReady() { return _isReady; }, get promise() { return _promise; }, init() { if (!_promise) { _promise = new Promise(resolve => { _resolve = () => { _isReady = true; resolve(); if (_checkInterval) { clearInterval(_checkInterval); _checkInterval = null; } }; // 安全检查:确保cc.game存在 const safeCheckEngine = () => { // 如果引擎已经初始化 if (cc && cc.game && cc.game._isEngineInited) { _resolve(); return true; } // 尝试监听引擎初始化事件 if (cc && cc.game && cc.game.once) { // 使用更安全的方式访问事件常量 const eventName = (cc.game && cc.game.EVENT_ENGINE_INITED) || (cc.Game && cc.Game.EVENT_ENGINE_INITED) || 'engine-inited'; cc.game.once(eventName, _resolve); return true; } return false; }; // 首次尝试检查 if (safeCheckEngine()) { return; } // 如果首次检查失败,设置轮询检查 _checkInterval = setInterval(() => { if (safeCheckEngine()) { clearInterval(_checkInterval); _checkInterval = null; } }, 100); }); } return _promise; }, // 安全访问引擎API的包装器 safeAccess(callback) { if (_isReady) { try { return callback(); } catch (e) { console.error('[EngineSafe] Callback error:', e); } } return _promise.then(callback).catch(e => { console.error('[EngineSafe] Async callback error:', e); }); } }; })(); // 初始化但不立即等待 EngineReady.init(); // ====== 游戏主入口 ====== async function gameMainEntry() { try { console.log('[Main] Waiting for engine initialization...'); // 安全等待引擎初始化 await EngineReady.promise; console.log('[Main] Engine fully initialized'); // 安全初始化游戏设置 EngineReady.safeAccess(() => { if (cc.view) { cc.view.enableRetina(true); cc.view.resizeWithBrowserSize(true); cc.view.setDesignResolutionSize(960, 640, cc.ResolutionPolicy.SHOW_ALL); } }); // 加载重力引擎SDK await loadGravityEngineSDK(); // 加载启动场景 await loadStartScene(); } catch (error) { console.error('[Main] Game initialization failed:', error); // 尝试恢复基本功能 try { // 直接尝试加载场景 if (cc.director && cc.director.loadScene) { cc.director.loadScene('start'); } } catch (fallbackError) { console.error('[Main] Fallback scene load failed:', fallbackError); // 最终后备方案 displayErrorFallback('Initialization Failed\nPlease Restart'); } } } // 错误显示后备方案 function displayErrorFallback(message) { try { // 尝试使用DOM创建错误显示 const errorDiv = document.createElement('div'); errorDiv.style.position = 'fixed'; errorDiv.style.top = '0'; errorDiv.style.left = '0'; errorDiv.style.width = '100%'; errorDiv.style.height = '100%'; errorDiv.style.backgroundColor = 'black'; errorDiv.style.color = 'white'; errorDiv.style.display = 'flex'; errorDiv.style.justifyContent = 'center'; errorDiv.style.alignItems = 'center'; errorDiv.style.zIndex = '9999'; errorDiv.style.fontFamily = 'Arial, sans-serif'; errorDiv.style.fontSize = '24px'; errorDiv.style.textAlign = 'center'; errorDiv.style.whiteSpace = 'pre-line'; errorDiv.textContent = message; document.body.appendChild(errorDiv); } catch (domError) { console.error('[Fallback] Failed to create error display:', domError); } } // ====== SDK 加载器 ====== async function loadGravityEngineSDK() { const sdkPaths = [ 'src/assets/_plugs/lib/gravityengine.mg.cocoscreator.min.js', 'assets/_plugs/lib/gravityengine.mg.cocoscreator.min.js', 'lib/gravityengine.mg.cocoscreator.min.js' // 额外后备路径 ]; let sdkLoaded = false; for (const path of sdkPaths) { try { console.log(`[SDK] Attempting to load from: ${path}`); await new Promise((resolve, reject) => { if (cc && cc.assetManager && cc.assetManager.loadScript) { cc.assetManager.loadScript(path, (err) => { if (err) { console.warn(`[SDK] Load failed: ${err.message}`); reject(err); } else { resolve(); } }); } else { console.warn('[SDK] cc.assetManager not available'); reject('Asset manager not available'); } }); console.log('[SDK] GravityEngine loaded successfully'); sdkLoaded = true; initGravityEngine(); break; } catch (err) { // 继续尝试下一个路径 } } if (!sdkLoaded) { console.error('[SDK] All load attempts failed'); handleSDKLoadFailure(); } } function initGravityEngine() { if (typeof GravityEngine === 'undefined') { console.error('[SDK] GravityEngine not defined after loading'); return; } try { GravityEngine.init({ appId: 'YOUR_APP_ID', // 替换为实际AppID enableLog: true }); console.log('[SDK] GravityEngine initialized'); } catch (e) { console.error('[SDK] Initialization failed:', e); } } function handleSDKLoadFailure() { console.warn('[SDK] Disabling analytics features'); // 创建空函数降级 window.trackEvent = window.trackEvent || function() {}; window.GravityEngine = window.GravityEngine || { init: () => console.warn('SDK not available'), trackEvent: () => {} }; } // ====== 场景加载器 ====== async function loadStartScene() { try { // 尝试加载主资源包 await new Promise((resolve, reject) => { if (cc && cc.assetManager && cc.assetManager.loadBundle) { cc.assetManager.loadBundle('main', (err) => { if (err) { console.error('[Scene] Bundle load failed:', err); reject(err); } else { console.log('[Scene] Main bundle loaded'); resolve(); } }); } else { console.warn('[Scene] Asset manager not available, skipping bundle load'); resolve(); // 继续执行 } }); // 加载启动场景 if (cc.director && cc.director.loadScene) { cc.director.loadScene('start'); } else { throw new Error('Director not available'); } } catch (error) { console.error('[Scene] Failed to load main bundle:', error); // 后备方案:直接加载场景 try { console.log('[Scene] Trying direct scene load'); if (cc.director && cc.director.loadScene) { cc.director.loadScene('start'); } else { throw new Error('Director not available'); } } catch (directError) { console.error('[Scene] Direct scene load failed:', directError); throw directError; // 传递给上层处理 } } } // ====== UI_Entry 组件 ====== var _decorator = cc._decorator; var _ccclass = _decorator.ccclass; var _property = _decorator.property; // 导入依赖模块 const r_Const_Common = require("Const_Common"); const r_GravityPlatform = require("GravityPlatform"); const r_YpNetMag = require("YpNetMag"); const r_EvenType = require("EvenType"); const r_PlayerDataManager = require("PlayerDataManager"); const r_ExcelLoader = require("ExcelLoader"); const r_GameDataManager = require("GameDataManager"); const r_GameGlobalVariable = require("GameGlobalVariable"); const r_UIConfig_Game = require("UIConfig_Game"); const r_UIConfig_Home = require("UIConfig_Home"); const r_BundleConfig = require("BundleConfig"); const r_GameConfig = require("GameConfig"); const r_AudioManager = require("AudioManager"); const r_EventManager = require("EventManager"); const r_HttpManager = require("HttpManager"); const r_LogManager = require("LogManager"); const r_ResLoader = require("ResLoader"); const r_UIManager = require("UIManager"); const r_UIView = require("UIView"); var def_UI_Entry = (function (_super) { __extends(def_UI_Entry, _super); function def_UI_Entry() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.progress_loading = null; _this.loginTimeoutHandler = null; return _this; } // 组件生命周期:加载 def_UI_Entry.prototype.onLoad = function () { var _this = this; EngineReady.safeAccess(function () { try { if (cc.director && cc.director.getCollisionManager) { cc.director.getCollisionManager().enabled = true; } console.log('[UI] Collision manager enabled'); _this._show(); } catch (e) { console.error('[UI] onLoad error:', e); _this.startLoadGame(); // 直接开始加载游戏 } }).catch(function (err) { console.error('[UI] Engine access error:', err); _this.startLoadGame(); }); }; // 组件生命周期:销毁 def_UI_Entry.prototype.onDestroy = function () { if (this.loginTimeoutHandler) { cc.Tween.stop(this.loginTimeoutHandler); this.loginTimeoutHandler = null; console.log('[UI] Login timeout handler cleared'); } }; // 显示UI并初始化平台SDK def_UI_Entry.prototype._show = function () { return __awaiter(this, void 0, void 0, function () { var _this = this; return __generator(this, function (_a) { this.progress_loading.progress = 0; console.log('[UI] Showing UI_Entry'); // 平台特定的SDK初始化 if (cc.sys && cc.sys.isBrowser) { this.initYPSDK().catch(function (err) { console.error('[UI] YPSDK init failed:', err); _this.startLoadGame(); }); } else { this.startLoadGame(); } // 设置登录超时保护(10秒) if (cc && cc.tween) { this.loginTimeoutHandler = cc.tween(this) .delay(10) .call(function () { console.warn('[UI] Login timeout after 10s, proceeding without SDK'); _this.startLoadGame(); }) .start(); } else { console.warn('[UI] cc.tween not available, using setTimeout'); setTimeout(() => { console.warn('[UI] Login timeout after 10s, proceeding without SDK'); this.startLoadGame(); }, 10000); } return [2]; }); }); }; // 初始化游品SDK def_UI_Entry.prototype.initYPSDK = function () { return __awaiter(this, void 0, void 0, function () { var config; var _this = this; return __generator(this, function (_a) { switch (_a.label) { case 0: if (typeof YPSDK === 'undefined') { console.warn('[YPSDK] YPSDK not available'); return [2]; } config = { gameChannelList: { h5: { platformType: "h5", describe: "默认 H5 渠道", version: "1.0.0" }, tt: { platformType: "tt", appId: "tt09297f94961f881b02", describe: "默认 TT 渠道", version: "1.0.0" }, wx: { platformType: "wx", appId: "wx6baaaa27ab5186ff", describe: "默认 WX 渠道", version: "1.0.0" } } }; return [4, YPSDK.init(39, "https://platform-shop-dev.hanyougame.com", config)]; case 1: _a.sent(); return [4, YPSDK.login()]; case 2: _a.sent(); // 设置登录回调 if (YPSDK.setLoginCallBack) { YPSDK.setLoginCallBack(function (success) { if (success) { // 取消超时处理 if (_this.loginTimeoutHandler) { if (cc && cc.Tween && cc.Tween.stop) { cc.Tween.stop(_this.loginTimeoutHandler); } _this.loginTimeoutHandler = null; } // 初始化重力引擎 if (r_GravityPlatform.default && typeof r_GravityPlatform.default.GA_Init === 'function') { r_GravityPlatform.default.GA_Init(YPSDK.Platform.loginData.bindingId); } _this.startLoadGame(); } }); } else { console.warn('[YPSDK] setLoginCallBack not available'); } return [2]; } }); }); }; // 开始加载游戏资源 def_UI_Entry.prototype.startLoadGame = function () { var tasks = [ this._loadGameConfig.bind(this), this._loadRemoteConfig.bind(this), this._loadExcelData.bind(this), this._loadUserData.bind(this), this._loadCommonBundle.bind(this), this._loadMainBundle.bind(this) ]; this.executeTasksWithProgress(tasks, this._loadGame.bind(this)); // 微信平台特殊处理 if (cc.sys && cc.sys.platform === cc.sys.WECHAT_GAME && typeof mg !== 'undefined') { try { mg.showShareMenu({ menus: ["shareAppMessage", "shareTimeline"] }); } catch (e) { console.warn('[WeChat] Share menu setup failed:', e); } } }; // 带进度监控的任务执行器 def_UI_Entry.prototype.executeTasksWithProgress = function (tasks, finalCallback) { var _this = this; var completed = 0; var failed = 0; var executeNext = function (index) { if (index >= tasks.length) { if (failed === 0) { finalCallback(); } else { console.warn("[Tasks] Completed with " + failed + " failures"); finalCallback(); // 即使有失败也继续 } return; } tasks[index]() .then(function () { completed++; _this._setProgress(completed / tasks.length); executeNext(index + 1); }) .catch(function (err) { console.error("[Task] #" + index + " failed:", err); failed++; _this._setProgress((completed + 0.5) / tasks.length); // 部分进度 executeNext(index + 1); }); }; executeNext(0); }; // 加载Excel数据 def_UI_Entry.prototype._loadExcelData = function () { return new Promise(function (resolve, reject) { if (r_ExcelLoader && r_ExcelLoader.ExcelLoader && r_ExcelLoader.ExcelLoader.loadAll) { r_ExcelLoader.ExcelLoader.loadAll() .then(function () { console.log('[Data] Excel data loaded'); resolve(); }) .catch(function (err) { console.error('[Data] Excel load failed:', err); reject(err); }); } else { console.warn('[Data] ExcelLoader not available'); resolve(); // 非关键任务继续 } }); }; // 加载游戏配置 def_UI_Entry.prototype._loadGameConfig = function () { return __awaiter(this, void 0, void 0, function () { var jsonAsset; return __generator(this, function (_a) { switch (_a.label) { case 0: if (!r_ResLoader || !r_ResLoader.default || !r_ResLoader.default.loadRes) { console.warn('[Config] ResLoader not available'); return [2, Promise.resolve()]; } return [4, r_ResLoader.default.loadRes("resources", "config/GameConfig", cc.JsonAsset)]; case 1: jsonAsset = _a.sent(); if (jsonAsset && r_GameConfig && r_GameConfig.default) { r_GameConfig.default.appConfig = jsonAsset.json; console.log('[Config] Game config loaded'); if (jsonAsset.decRef) { jsonAsset.decRef(); // 释放引用 } return [2, Promise.resolve()]; } else { console.error('[Config] Game config not found'); return [2, Promise.resolve()]; // 非关键错误继续 } } }); }); }; // 加载远程配置 def_UI_Entry.prototype._loadRemoteConfig = function () { return __awaiter(this, void 0, void 0, function () { var remoteUrl, remotePath, remoteConfig; return __generator(this, function (_a) { switch (_a.label) { case 0: if (!r_GameConfig || !r_GameConfig.default || !r_GameConfig.default.appConfig || !r_GameConfig.default.appConfig.RemoteUrl) { console.warn('[Config] RemoteUrl not configured'); return [2, Promise.resolve()]; } remoteUrl = r_GameConfig.default.appConfig.RemoteUrl; remotePath = cc.path.join(remoteUrl, "ADConfig.json"); return [4, r_ResLoader.default.loadRemote(remotePath, { ext: ".json" })]; case 1: remoteConfig = _a.sent(); if (remoteConfig && remoteConfig.json && r_GravityPlatform && r_GravityPlatform.default) { r_GravityPlatform.default.videoId = remoteConfig.json.ADUnitId[0]; if (r_GameConfig && r_GameConfig.default) { r_GameConfig.default.adConfig = remoteConfig.json; } console.log('[Config] Remote config loaded'); return [2, Promise.resolve()]; } else { console.error('[Config] Remote config load failed'); return [2, Promise.resolve()]; // 非关键错误,继续执行 } } }); }); }; // 加载公共资源包 def_UI_Entry.prototype._loadCommonBundle = function () { return new Promise(function (resolve, reject) { if (!r_ResLoader || !r_ResLoader.default || !r_ResLoader.default.loadBundle) { console.warn('[Bundle] ResLoader not available'); resolve(); return; } r_ResLoader.default.loadBundle(r_BundleConfig.BundleNames.Common) .then(function (bundle) { if (bundle) { console.log('[Bundle] Common bundle loaded'); resolve(); } else { console.warn('[Bundle] Common bundle not loaded'); resolve(); // 非关键错误继续 } }) .catch(err => { console.error('[Bundle] Common bundle load failed:', err); resolve(); // 非关键错误继续 }); }); }; // 加载主游戏包 def_UI_Entry.prototype._loadMainBundle = function () { return new Promise(function (resolve, reject) { if (!r_ResLoader || !r_ResLoader.default || !r_ResLoader.default.loadBundle) { console.warn('[Bundle] ResLoader not available'); resolve(); return; } r_ResLoader.default.loadBundle(r_BundleConfig.MainGameBundle) .then(function (bundle) { if (bundle) { console.log('[Bundle] Main game bundle loaded'); resolve(); } else { console.warn('[Bundle] Main game bundle not loaded'); resolve(); // 非关键错误继续 } }) .catch(err => { console.error('[Bundle] Main game bundle load failed:', err); resolve(); // 非关键错误继续 }); }); }; // 加载用户数据 def_UI_Entry.prototype._loadUserData = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { try { if (r_AudioManager && r_AudioManager.AudioMgr && r_AudioManager.AudioMgr.init) { r_AudioManager.AudioMgr.init(); } if (r_GameGlobalVariable && r_GameGlobalVariable.GameGlobalVariable && r_GameGlobalVariable.GameGlobalVariable.initPeiZhi) { r_GameGlobalVariable.GameGlobalVariable.initPeiZhi(); } if (YPSDK && YPSDK.Common && YPSDK.Common.curChannelData && r_YpNetMag && r_YpNetMag.YpNetMag && r_YpNetMag.YpNetMag.failSever) { var platformType = YPSDK.Common.curChannelData.platformType; if (platformType === YPSDK.GamePlatformType.WX || platformType === YPSDK.GamePlatformType.TT) { r_YpNetMag.YpNetMag.failSever(function () { if (r_YpNetMag.YpNetMag) { r_YpNetMag.YpNetMag.isFail = true; } console.warn('[Network] Server connection failed'); }); } } if (YPSDK && YPSDK.Platform && YPSDK.Platform.loginData && r_YpNetMag && r_YpNetMag.YpNetMag && r_YpNetMag.YpNetMag.initServer) { return [2, r_YpNetMag.YpNetMag.initServer(YPSDK.Platform.loginData)]; } else { console.warn('[User] No login data, skipping user init'); return [2, Promise.resolve()]; } } catch (err) { console.error('[User] Load user data failed:', err); return [2, Promise.resolve()]; // 非关键错误 } return [2]; }); }); }; // 初始化游戏主逻辑 def_UI_Entry.prototype._loadGame = function () { try { // 安全访问玩家数据管理器 if (!r_PlayerDataManager || !r_PlayerDataManager.PlayerDataMgr) { throw new Error('PlayerDataManager not available'); } // 获取引导状态 var guideIndex = r_PlayerDataManager.PlayerDataMgr.GetGuideIndexByTaskName(r_Const_Common.GuideName.战斗背包); if (guideIndex !== r_Const_Common.GameBagGuideIndex.引导完结) { // 新玩家流程 if (r_PlayerDataManager.PlayerDataMgr.GMSetGuideIndex) { r_PlayerDataManager.PlayerDataMgr.GMSetGuideIndex( r_Const_Common.GuideName.战斗背包, r_Const_Common.GameBagGuideIndex.引导初始1 ); } if (r_GameDataManager && r_GameDataManager.GameDataMgr && r_GameDataManager.GameDataMgr.ClearGameBagData) { r_GameDataManager.GameDataMgr.ClearGameBagData(); } if (r_GameGlobalVariable && r_GameGlobalVariable.GameGlobalVariable) { r_GameGlobalVariable.GameGlobalVariable.nowlevel = 1; } // 打开游戏场景 if (r_UIManager && r_UIManager.default && r_UIManager.default.open) { r_UIManager.default.open( r_BundleConfig.BundleNames.Game, r_UIConfig_Game.UIView_Game.UI_GameView ); } else { console.warn('[Game] UIManager not available, loading start scene'); cc.director.loadScene('start'); } } else { // 老玩家流程 if (r_EventManager && r_EventManager.EventMgr && r_EventManager.EventMgr.dispatchEvent) { r_EventManager.EventMgr.dispatchEvent(r_EvenType.EVENT_TYPE.Game_Load_View, true); } if (r_UIManager && r_UIManager.default && r_UIManager.default.open) { r_UIManager.default.open( r_BundleConfig.BundleNames.Home, r_UIConfig_Home.UIView_Home.UI_Hall ); } else { console.warn('[Game] UIManager not available, loading start scene'); cc.director.loadScene('start'); } } // 初始化白名单 this.onInitWhiteName(); } catch (error) { console.error('[Game] Load game failed:', error); // 尝试直接进入游戏场景 try { if (cc.director && cc.director.loadScene) { cc.director.loadScene('start'); } } catch (sceneError) { console.error('[Game] Fallback scene load failed:', sceneError); } } }; // 初始化白名单 def_UI_Entry.prototype.onInitWhiteName = function () { return __awaiter(this, void 0, void 0, function () { var url; return __generator(this, function (_a) { try { if (!YPSDK || !YPSDK.Platform || !YPSDK.Platform.loginData || !YPSDK.platformUrl) { console.warn('[WhiteList] YPSDK not initialized, skipping'); return [2]; } url = YPSDK.platformUrl + "/User/GetCfgData?userId=" + YPSDK.Platform.loginData.userUid + "&keyId=NoVideo"; console.log('[WhiteList] Checking:', url); if (r_HttpManager && r_HttpManager.HttpMgr && r_HttpManager.HttpMgr.requestData) { r_HttpManager.HttpMgr.requestData(function (response) { if (response && response.data && response.data.keyData === "true" && r_PlayerDataManager && r_PlayerDataManager.PlayerDataMgr) { r_PlayerDataManager.PlayerDataMgr.WHITE_NAME_NO_VIDEO = true; console.log('[WhiteList] User is in white list'); } }, url); } else { console.warn('[WhiteList] HttpManager not available'); } } catch (err) { console.error('[WhiteList] Init failed:', err); } return [2]; }); }); }; // 设置进度条 def_UI_Entry.prototype._setProgress = function (progress) { if (!this.progress_loading || !this.progress_loading.progress) { return; } progress = Math.max(0, Math.min(1, progress)); this.progress_loading.progress = progress; }; // 属性装饰器 __decorate([ _property(cc.ProgressBar) ], def_UI_Entry.prototype, "progress_loading", void 0); // 类装饰器 def_UI_Entry = __decorate([ _ccclass ], def_UI_Entry); return def_UI_Entry; }(r_UIView.default)); exports.default = def_UI_Entry; // ====== 启动游戏 ====== if (cc && cc.game && cc.game.run) { cc.game.run(gameMainEntry); } else { console.error('[Main] cc.game.run not available, using fallback start'); setTimeout(gameMainEntry, 1000); } UI_Entry.js是我的项目入口吗
07-16
/** * @file Menu.h * @brief 菜单导航系统头文件 * @author huang huan tao * @date 2025/09/28 */ #ifndef MENU_SYSTEM_H #define MENU_SYSTEM_H #include <vector> #include <string> #include <iostream> #ifdef _WIN32 #include <conio.h> #include <windows.h> #else #include <termios.h> #include <unistd.h> #include <sys/select.h> #endif /** * @class Menu * @brief 表示一个菜单及其子菜单项的类 */ class Menu { private: std::string m_mainName; // 主菜单名称 std::vector<std::string> m_subMenus; // 子菜单项列表 public: /** * @brief 构造函数 * @param mainName 主菜单名称 * @param subs 子菜单项列表 */ Menu(const std::string& mainName, const std::vector<std::string>& subs); /// @brief 获取主菜单名称 const std::string& getMainName() const; /// @brief 获取子菜单项列表 const std::vector<std::string>& getSubMenus() const; /// @brief 获取子菜单项数量 size_t getSubMenuCount() const; /** * @brief 获取指定索引的子菜单项 * @param index 子菜单索引 * @return 子菜单项名称 * @note 索引越界时返回最后一个子菜单 */ const std::string& getSubMenu(size_t index) const; }; /** * @class MenuManager * @brief 管理菜单导航和用户交互的类 */ class MenuManager { private: std::vector<Menu> m_menus; // 菜单列表 size_t m_currentMainIndex = 0; // 当前选择的主菜单索引 size_t m_currentSubIndex = 1; // 当前选择的子菜单索引 size_t m_targetMainIndex; // 目标主菜单索引 size_t m_targetSubIndex; // 目标子菜单索引 /** * @brief 清空控制台屏幕(跨平台) * @note Windows使用cls,Linux/Mac使用clear */ void clearScreen() const; /** * @brief 设置非阻塞输入模式 * @note Linux/Mac平台关闭行缓冲和回显 */ void setupNonBlockingInput(); /** * @brief 根据名称查找主菜单索引 * @param name 主菜单名称 * @return 主菜单索引,未找到时返回0 */ size_t findMainIndex(const std::string& name) const; /** * @brief 根据名称查找子菜单索引 * @param mainIdx 主菜单索引 * @param name 子菜单名称 * @return 子菜单索引,未找到时返回0 */ size_t findSubIndex(size_t mainIdx, const std::string& name) const; /** * @brief 调整当前子菜单索引 * @note 当主菜单变更时确保子菜单索引有效 */ void adjustSubIndex(); public: /** * @brief 构造函数 * @throw std::invalid_argument 如果目标菜单项无效 */ MenuManager(); /** * @brief 显示当前菜单状态 * @note 清屏后显示主菜单和当前选中的子菜单 */ void displayMenu() const; /** * @brief 检查是否到达目标菜单项 * @return 到达目标返回true,否则false */ bool isTargetReached() const; /** * @brief 获取用户输入 * @param[out] input 存储输入字符 * @return 有输入返回true,无输入返回false * @note Windows使用_kbhit和_getch,Linux/Mac使用select */ bool getInput(char& input); /** * @brief 处理用户输入 * @param input 用户输入字符 */ void handleInput(char input); /** * @brief 运行菜单导航系统 * @note 主循环,显示菜单并处理输入 */ void run(); }; #endif // MENU_SYSTEM_H #include "Menu.h" int main() { MenuManager manager; manager.run(); return 0; } /** * @file Menu.cpp * @brief 菜单导航系统实现文件 * @author huang huan tao * @date 2025/9/28 */ #include "Menu.h" #include <cctype> #include <cmath> // for pow in Linux/Mac // Menu类实现 ===================================================== Menu::Menu(const std::string& mainName, const std::vector<std::string>& subs) : m_mainName(mainName), m_subMenus(subs) { } const std::string& Menu::getMainName() const { return m_mainName; } const std::vector<std::string>& Menu::getSubMenus() const { return m_subMenus; } size_t Menu::getSubMenuCount() const { return m_subMenus.size(); } const std::string& Menu::getSubMenu(size_t index) const { return m_subMenus.at(index < m_subMenus.size() ? index : m_subMenus.size() - 1); } // MenuManager类实现 ============================================== MenuManager::MenuManager() : m_currentMainIndex(0), m_currentSubIndex(1) { m_menus.emplace_back("A", std::vector<std::string>{"A1", "A2", "A3", "A4"}); m_menus.emplace_back("B", std::vector<std::string>{"B1", "B2", "B3"}); m_menus.emplace_back("C", std::vector<std::string>{"C1", "C2", "C3"}); m_menus.emplace_back("D", std::vector<std::string>{"D1", "D2", "D3"}); m_targetMainIndex = findMainIndex("C"); m_targetSubIndex = findSubIndex(m_targetMainIndex, "C3"); // 验证目标菜单项 if (m_targetMainIndex >= m_menus.size() || m_targetSubIndex >= m_menus[m_targetMainIndex].getSubMenuCount()) { } setupNonBlockingInput(); } void MenuManager::clearScreen() const { #ifdef _WIN32 system("cls"); #else system("clear"); #endif } void MenuManager::setupNonBlockingInput() { #ifndef _WIN32 struct termios term; tcgetattr(STDIN_FILENO, &term); term.c_lflag &= ~(ICANON | ECHO); tcsetattr(STDIN_FILENO, TCSANOW, &term); #endif } size_t MenuManager::findMainIndex(const std::string& name) const { for (size_t i = 0; i < m_menus.size(); ++i) { if (m_menus[i].getMainName() == name) return i; } return 0; } size_t MenuManager::findSubIndex(size_t mainIdx, const std::string& name) const { if (mainIdx >= m_menus.size()) return 0; const auto& subs = m_menus[mainIdx].getSubMenus(); for (size_t i = 0; i < subs.size(); ++i) { if (subs[i] == name) return i; } return 0; } void MenuManager::adjustSubIndex() { if (m_currentSubIndex >= m_menus[m_currentMainIndex].getSubMenuCount()) { m_currentSubIndex = m_menus[m_currentMainIndex].getSubMenuCount() - 1; } } void MenuManager::displayMenu() const { clearScreen(); std::cout << "=== 菜单导航系统 ===" << std::endl; std::cout << "操作指南: a/d-切换主菜单 w/s-切换子菜单\n\n"; // 一级菜单 std::cout << "主菜单: "; for (size_t i = 0; i < m_menus.size(); ++i) { if (i == m_currentMainIndex) { std::cout << "[" << m_menus[i].getMainName() << "] "; } else { std::cout << m_menus[i].getMainName() << " "; } } std::cout << "\n\n"; // 二级菜单 const Menu& currentMenu = m_menus[m_currentMainIndex]; std::cout << currentMenu.getMainName() << "的子菜单: "; for (size_t i = 0; i < currentMenu.getSubMenuCount(); ++i) { if (i == m_currentSubIndex) { std::cout << "[" << currentMenu.getSubMenu(i) << "] "; } else { std::cout << currentMenu.getSubMenu(i) << " "; } } // 目标提示 std::cout << "\n\n目标: 选择 " << m_menus[m_targetMainIndex].getMainName() << m_menus[m_targetMainIndex].getSubMenu(m_targetSubIndex) << std::endl; } bool MenuManager::isTargetReached() const { return m_currentMainIndex == m_targetMainIndex && m_currentSubIndex == m_targetSubIndex; } bool MenuManager::getInput(char& input) { #ifdef _WIN32 if (_kbhit()) { input = _getch(); return true; } #else fd_set set; struct timeval tv; FD_ZERO(&set); FD_SET(STDIN_FILENO, &set); tv.tv_sec = 0; tv.tv_usec = 10000; // 10ms超时 if (select(STDIN_FILENO + 1, &set, NULL, NULL, &tv) > 0) { input = getchar(); return true; } #endif return false; } void MenuManager::handleInput(char input) { input = std::tolower(static_cast<unsigned char>(input)); const size_t subCount = m_menus[m_currentMainIndex].getSubMenuCount(); switch (input) { case 'a': // 切换到上一个主菜单 m_currentMainIndex = (m_currentMainIndex + m_menus.size() - 1) % m_menus.size(); adjustSubIndex(); break; case 'd': // 切换到下一个主菜单 m_currentMainIndex = (m_currentMainIndex + 1) % m_menus.size(); adjustSubIndex(); break; case 'w': // 切换到上一个子菜单 m_currentSubIndex = (m_currentSubIndex + subCount - 1) % subCount; break; case 's': // 切换到下一个子菜单 m_currentSubIndex = (m_currentSubIndex + 1) % subCount; break; } } void MenuManager::run() { while (true) { displayMenu(); if (isTargetReached()) { std::cout << "\n成功选择目标菜单! 程序结束" << std::endl; break; } char input = 0; if (getInput(input)) { handleInput(input); } // 降低CPU占用率 #ifdef _WIN32 Sleep(50); #else usleep(50000); #endif } } 解决上述代码中出现的闪屏问题
10-11
chromium下面函数中添加“登录”按钮,需要如何修改 void AppMenuModel::Build() { // Build (and, by extension, Init) should only be called once. DCHECK_EQ(0u, GetItemCount()); if (app_menu_icon_controller_ && app_menu_icon_controller_->GetTypeAndSeverity().type == AppMenuIconController::IconType::UPGRADE_NOTIFICATION) { AddSeparator(ui::SPACING_SEPARATOR); const auto update_icon = ui::ImageModel::FromVectorIcon(kBrowserToolsUpdateChromeRefreshIcon, ui::kColorMenuIconOnEmphasizedBackground, kDefaultIconSize); if (browser_defaults::kShowUpgradeMenuItem) { AddItemWithIcon(IDC_UPGRADE_DIALOG, GetUpgradeDialogTitleText(), update_icon); AddSeparator(ui::SPACING_SEPARATOR); } } if (AddSafetyHubMenuItem() || AddGlobalErrorMenuItems() || AddDefaultBrowserMenuItems()) { AddSeparator(ui::NORMAL_SEPARATOR); } AddItemWithStringIdAndVectorIcon(this, IDC_USER_LOGIN, IDS_DEVICE_LOG_TYPE_LOGIN, kPersonIcon); AddSeparator(ui::NORMAL_SEPARATOR); // 打开新的标签页 AddItemWithStringIdAndVectorIcon(this, IDC_NEW_TAB, browser_->profile()->IsIncognitoProfile() && !browser_->profile()->IsGuestSession() ? IDS_NEW_INCOGNITO_TAB : IDS_NEW_TAB, kNewTabRefreshIcon); // 打开新的窗口 AddItemWithStringIdAndVectorIcon(this, IDC_NEW_WINDOW, IDS_NEW_WINDOW, kNewWindowIcon); // This menu item is not visible in Guest Mode. If incognito mode is not // available, it will be shown in disabled state. (crbug.com/1100791) // 打开新的无痕式窗口 if (!browser_->profile()->IsGuestSession()) { AddItemWithStringIdAndVectorIcon(this, IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW, kIncognitoRefreshMenuIcon); SetElementIdentifierAt(GetIndexOfCommandId(IDC_NEW_INCOGNITO_WINDOW).value(), kIncognitoMenuItem); } // 分隔线 AddSeparator(ui::NORMAL_SEPARATOR); #if !BUILDFLAG(IS_CHROMEOS) sub_menus_.push_back(std::make_unique<ProfileSubMenuModel>(this, browser()->profile(), browser()->window()->GetColorProvider())); auto* const profile_submenu_model = static_cast<ProfileSubMenuModel*>(sub_menus_.back().get()); // 您的chrome AddSubMenu(IDC_PROFILE_MENU_IN_APP_MENU, profile_submenu_model->profile_name(), profile_submenu_model); SetIcon(GetIndexOfCommandId(IDC_PROFILE_MENU_IN_APP_MENU).value(), profile_submenu_model->avatar_image_model()); SetElementIdentifierAt(GetIndexOfCommandId(IDC_PROFILE_MENU_IN_APP_MENU).value(), kProfileMenuItem); AddSeparator(ui::SPACING_SEPARATOR); #endif // 密码和自动填充 if (!browser_->profile()->IsGuestSession()) { sub_menus_.push_back(std::make_unique<PasswordsAndAutofillSubMenuModel>(this)); AddSubMenuWithStringIdAndVectorIcon(this, IDC_PASSWORDS_AND_AUTOFILL_MENU, IDS_PASSWORDS_AND_AUTOFILL_MENU, sub_menus_.back().get(), vector_icons::kPasswordManagerIcon); SetElementIdentifierAt(GetIndexOfCommandId(IDC_PASSWORDS_AND_AUTOFILL_MENU).value(), kPasswordAndAutofillMenuItem); } // 历史记录 if (!browser_->profile()->IsOffTheRecord()) { auto recent_tabs_sub_menu = std::make_unique<RecentTabsSubMenuModel>(provider_, browser_); recent_tabs_sub_menu->RegisterLogMenuMetricsCallback(base::BindRepeating(&AppMenuModel::LogMenuMetrics, base::Unretained(this))); sub_menus_.push_back(std::move(recent_tabs_sub_menu)); AddSubMenuWithStringIdAndVectorIcon(this, IDC_RECENT_TABS_MENU, IDS_HISTORY_MENU, sub_menus_.back().get(), kHistoryIcon); SetElementIdentifierAt(GetIndexOfCommandId(IDC_RECENT_TABS_MENU).value(), kHistoryMenuItem); } // 下载内容 AddItemWithStringIdAndVectorIcon(this, IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS, kDownloadMenuIcon); SetElementIdentifierAt(GetIndexOfCommandId(IDC_SHOW_DOWNLOADS).value(), kDownloadsMenuItem); // 书签和清单 if (!browser_->profile()->IsGuestSession()) { bookmark_sub_menu_model_ = std::make_unique<BookmarkSubMenuModel>(this, browser_); AddSubMenuWithStringIdAndVectorIcon(this, IDC_BOOKMARKS_MENU, IDS_BOOKMARKS_AND_LISTS_MENU, bookmark_sub_menu_model_.get(), kBookmarksListsMenuIcon); SetElementIdentifierAt(GetIndexOfCommandId(IDC_BOOKMARKS_MENU).value(), kBookmarksMenuItem); } // 标签页分组 if (browser_->profile()->IsRegularProfile()) { auto saved_tab_groups_model = std::make_unique<ui::SimpleMenuModel>(this); sub_menus_.push_back(std::move(saved_tab_groups_model)); AddSubMenuWithStringIdAndVectorIcon(this, IDC_SAVED_TAB_GROUPS_MENU, IDS_SAVED_TAB_GROUPS_MENU, sub_menus_.back().get(), kSavedTabGroupBarEverythingIcon); SetElementIdentifierAt(GetIndexOfCommandId(IDC_SAVED_TAB_GROUPS_MENU).value(), kTabGroupsMenuItem); } // Extensions sub menu. //扩展程序 if (base::FeatureList::IsEnabled(features::kExtensionsCollapseMainMenu) && !extensions::ui_util::HasManageableExtensions(browser_->profile())) { AddItemWithStringIdAndVectorIcon(this, IDC_FIND_EXTENSIONS, IDS_FIND_EXTENSIONS, vector_icons::kExtensionChromeRefreshIcon); SetElementIdentifierAt(GetIndexOfCommandId(IDC_FIND_EXTENSIONS).value(), ExtensionsMenuModel::kVisitChromeWebStoreMenuItem); } else { sub_menus_.push_back(std::make_unique<ExtensionsMenuModel>(this, browser_)); AddSubMenuWithStringIdAndVectorIcon(this, IDC_EXTENSIONS_SUBMENU, IDS_EXTENSIONS_SUBMENU, sub_menus_.back().get(), vector_icons::kExtensionChromeRefreshIcon); SetElementIdentifierAt(GetIndexOfCommandId(IDC_EXTENSIONS_SUBMENU).value(), kExtensionsMenuItem); } // 删除浏览数据 AddItemWithStringIdAndVectorIcon(this, IDC_CLEAR_BROWSING_DATA, IDS_CLEAR_BROWSING_DATA, kTrashCanRefreshIcon); AddSeparator(ui::NORMAL_SEPARATOR); CreateZoomMenu(); // 缩放 AddSeparator(ui::NORMAL_SEPARATOR); // 打印 AddItemWithStringIdAndVectorIcon(this, IDC_PRINT, IDS_PRINT, kPrintMenuIcon); #if BUILDFLAG(ENABLE_GLIC) if (glic::GlicEnabling::IsEnabledForProfile(browser_->profile())) { AddItemWithStringIdAndVectorIcon(this, IDC_OPEN_GLIC, IDS_GLIC_THREE_DOT_MENU_ITEM, glic::GlicVectorIconManager::GetVectorIcon(IDR_GLIC_BUTTON_VECTOR_ICON)); SetIsNewFeatureAt(GetIndexOfCommandId(IDC_OPEN_GLIC).value(), browser()->window()->MaybeShowNewBadgeFor(features::kGlicAppMenuNewBadge)); } #endif // 使用Google智能镜头搜索 if (browser()->GetFeatures().lens_overlay_entry_point_controller()->IsEnabled()) { const gfx::VectorIcon& icon = #if BUILDFLAG(GOOGLE_CHROME_BRANDING) vector_icons::kGoogleLensMonochromeLogoIcon; #else vector_icons::kSearchChromeRefreshIcon; #endif AddItemWithStringIdAndVectorIcon(this, IDC_CONTENT_CONTEXT_LENS_OVERLAY, IDS_SHOW_LENS_OVERLAY, icon); const int lens_command_index = GetIndexOfCommandId(IDC_CONTENT_CONTEXT_LENS_OVERLAY).value(); SetElementIdentifierAt(lens_command_index, kShowLensOverlay); SetIsNewFeatureAt(lens_command_index, browser()->window()->MaybeShowNewBadgeFor(lens::features::kLensOverlay)); } //翻译 AddItemWithStringIdAndVectorIcon(this, IDC_SHOW_TRANSLATE, IDS_SHOW_TRANSLATE, kTranslateIcon); // 查找和修改 CreateFindAndEditSubMenu(); // 投放、保存和分享 sub_menus_.push_back(std::make_unique<SaveAndShareSubMenuModel>(this, browser_)); int string_id = media_router::MediaRouterEnabled(browser()->profile()) ? IDS_CAST_SAVE_AND_SHARE_MENU : IDS_SAVE_AND_SHARE_MENU; AddSubMenuWithStringIdAndVectorIcon(this, IDC_SAVE_AND_SHARE_MENU, string_id, sub_menus_.back().get(), kFileSaveChromeRefreshIcon); SetElementIdentifierAt(GetIndexOfCommandId(IDC_SAVE_AND_SHARE_MENU).value(), kSaveAndShareMenuItem); #if BUILDFLAG(IS_CHROMEOS) // Always show this option if we're in tablet mode on Chrome OS. if (display::Screen::GetScreen()->InTabletMode()) { AddItemWithStringIdAndVectorIcon(this, IDC_TOGGLE_REQUEST_TABLET_SITE, IDS_TOGGLE_REQUEST_TABLET_SITE, chrome::IsRequestingTabletSite(browser_) ? kRequestMobileSiteCheckedIcon : kRequestMobileSiteUncheckedIcon); } #endif // 更多工具 sub_menus_.push_back(std::make_unique<ToolsMenuModel>(this, browser_)); AddSubMenuWithStringIdAndVectorIcon(this, IDC_MORE_TOOLS_MENU, IDS_MORE_TOOLS_MENU, sub_menus_.back().get(), kMoreToolsMenuIcon); SetElementIdentifierAt(GetIndexOfCommandId(IDC_MORE_TOOLS_MENU).value(), kMoreToolsMenuItem); AddSeparator(ui::NORMAL_SEPARATOR); // The help submenu is only displayed on official Chrome builds. As the // 'About' item has been moved to this submenu, it's reinstated here for // Chromium builds. // 帮助 #if BUILDFLAG(GOOGLE_CHROME_BRANDING) sub_menus_.push_back(std::make_unique<HelpMenuModel>(this, browser_)); AddSubMenuWithStringIdAndVectorIcon(this, IDC_HELP_MENU, IDS_HELP_MENU, sub_menus_.back().get(), kHelpMenuIcon); #else #if BUILDFLAG(IS_CHROMEOS) AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); #else AddItemWithStringIdAndVectorIcon(this, IDC_ABOUT, IDS_ABOUT, vector_icons::kInfoRefreshIcon); #endif #endif // 设置 AddItemWithStringIdAndVectorIcon(this, IDC_OPTIONS, IDS_SETTINGS, kSettingsMenuIcon); // 退出 if (browser_defaults::kShowExitMenuItem) { AddItemWithStringIdAndVectorIcon(this, IDC_EXIT, IDS_EXIT, kExitMenuIcon); } // On Chrome OS, similar UI is displayed in the system tray menu, instead of // this menu. #if !BUILDFLAG(IS_CHROMEOS) if (ShouldDisplayManagedUi(browser_->profile())) { AddSeparator(ui::NORMAL_SEPARATOR); AddItemWithIcon(IDC_SHOW_MANAGEMENT_PAGE, GetManagedUiMenuItemLabel(browser_->profile()), ui::ImageModel::FromVectorIcon(GetManagedUiIcon(browser_->profile()), ui::kColorMenuIcon, kDefaultIconSize)); SetAccessibleNameAt(GetIndexOfCommandId(IDC_SHOW_MANAGEMENT_PAGE).value(), GetManagedUiMenuItemTooltip(browser_->profile())); } #endif // !BUILDFLAG(IS_CHROMEOS) uma_action_recorded_ = false; }
08-21
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值