⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mes_ui.cpp

📁 windows ce 下的3D桌面
💻 CPP
📖 第 1 页 / 共 5 页
字号:

	// load globals
	{
		int numberofproperties = MesParser_GetNumberOfProperties( rootnode );
		int i;
		for( i=0; i<numberofproperties; i++ )
		{
			HMESPARSERPROPERTY hproperty = MesParser_GetProperty( rootnode, i );
			if     ( CheckPropertyName( hproperty, "WALLPAPER"              ) ){ WALLPAPER      = LoadImageFromFile( hproperty,0 ); }
			else if( CheckPropertyName( hproperty, "BACKGRUOND"             ) ){ BACKGROUND     = LoadImageFromFile( hproperty,0 ); }			
			else if( CheckPropertyName( hproperty, "CURSOR"             ) ){ CURSOR     = LoadImageFromFile( hproperty,0 ); }
			else if( CheckPropertyName( hproperty, "BATTERYLEVEL"           ) ){ g_BatteryLevel = LoadImageFromFile( hproperty,0 ); }
			else if( CheckPropertyName( hproperty, "BATTERYLEVEL_ALPHAIMAGE") ){ g_BatteryLevelAlpha = LoadImageFromFile( hproperty,0 ); }
			else if( CheckPropertyName( hproperty, "BATTERYLEVEL_POS"       ) ){ BATTERYLEVEL_X = MesParser_GetInt( MesParser_GetValue(hproperty,0) ); BATTERYLEVEL_Y = MesParser_GetInt( MesParser_GetValue(hproperty,1) ); }
			else if( CheckPropertyName( hproperty, "BATTERYLEVEL_W"         ) ){ BATTERYLEVEL_W         = MesParser_GetInt( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "BATTERYLEVEL_H"         ) ){ BATTERYLEVEL_H         = MesParser_GetInt( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "BATTERYLEVEL_ALPHA"     ) ){ BATTERYLEVEL_ALPHA     = MesParser_GetFloat( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "TIMEDIGIT"              ) ){ g_TimeDigit = LoadImageFromFile( hproperty,0 ); }
			else if( CheckPropertyName( hproperty, "TIMEDIGIT_ALPHAIMAGE"   ) ){ g_TimeDigitAlpha = LoadImageFromFile( hproperty,0 ); }
			else if( CheckPropertyName( hproperty, "TIMEDIGIT_X0"           ) ){ TIMEDIGIT_X0           = MesParser_GetInt( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "TIMEDIGIT_X1"           ) ){ TIMEDIGIT_X1           = MesParser_GetInt( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "TIMEDIGIT_X2"           ) ){ TIMEDIGIT_X2           = MesParser_GetInt( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "TIMEDIGIT_X3"           ) ){ TIMEDIGIT_X3           = MesParser_GetInt( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "TIMEDIGIT_Y"            ) ){ TIMEDIGIT_Y            = MesParser_GetInt( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "TIMEDIGIT_W"            ) ){ TIMEDIGIT_W            = MesParser_GetInt( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "TIMEDIGIT_H"            ) ){ TIMEDIGIT_H            = MesParser_GetInt( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "TIMEDIGIT_ALPHA"        ) ){ TIMEDIGIT_ALPHA        = MesParser_GetFloat( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "TIMEAMPM"               ) ){ g_TimeAMPM = LoadImageFromFile( hproperty,0 ); }
			else if( CheckPropertyName( hproperty, "TIMEAMPM_ALPHAIMAGE"    ) ){ g_TimeAMPMAlpha = LoadImageFromFile( hproperty,0 ); }
			else if( CheckPropertyName( hproperty, "TIMEAMPM_X"             ) ){ TIMEAMPM_X             = MesParser_GetInt( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "TIMEAMPM_Y"             ) ){ TIMEAMPM_Y             = MesParser_GetInt( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "TIMEAMPM_W"             ) ){ TIMEAMPM_W             = MesParser_GetInt( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "TIMEAMPM_H"             ) ){ TIMEAMPM_H             = MesParser_GetInt( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "TIMEAMPM_ALPHA"         ) ){ TIMEAMPM_ALPHA         = MesParser_GetFloat( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "OVERLAY_VOLUMELEVEL"    ) ){ g_OverlayVolumeLevel = LoadImageFromFile( hproperty,0 ); }
			else if( CheckPropertyName( hproperty, "OVERLAY_VOLUMELEVEL_X"  ) ){ OVERLAY_VOLUMELEVEL_X  = MesParser_GetInt( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "OVERLAY_VOLUMELEVEL_Y"  ) ){ OVERLAY_VOLUMELEVEL_Y  = MesParser_GetInt( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "OVERLAY_VOLUMELEVEL_W"  ) ){ OVERLAY_VOLUMELEVEL_W  = MesParser_GetInt( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "OVERLAY_VOLUMELEVEL_H"  ) ){ OVERLAY_VOLUMELEVEL_H  = MesParser_GetInt( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "APPWAIT_TEXT"           ) ){ APPWAIT_TEXT   = LoadImageFromFile( hproperty,0 );                    }
			else if( CheckPropertyName( hproperty, "APPWAIT_TEXTAREA"       ) ){ LoadIntArray( hproperty,0,4,APPWAIT_TEXTAREA );                       }
			else if( CheckPropertyName( hproperty, "USBSTORAGE_ALPHA"       ) ){ USBSTORAGE_ALPHA   = LoadImageFromFile( hproperty,0 );                }
			else if( CheckPropertyName( hproperty, "USBSTORAGE_OVERLAY"     ) ){ USBSTORAGE_OVERLAY   = LoadImageFromFile( hproperty,0 );              }
			else if( CheckPropertyName( hproperty, "USBSTORAGE_TEXT"        ) ){ USBSTORAGE_TEXT   = LoadImageFromFile( hproperty,0 );                 }
			else if( CheckPropertyName( hproperty, "USBSTORAGE_BACKAREA"    ) ){ LoadIntArray( hproperty,0,4,USBSTORAGE_BACKAREA );                    }
			else if( CheckPropertyName( hproperty, "USBSTORAGE_TEXTAREA"    ) ){ LoadIntArray( hproperty,0,4,USBSTORAGE_TEXTAREA );                    }
			else if( CheckPropertyName( hproperty, "LOWBATTERY_BACK"        ) ){ LOWBATTERY_BACK   = LoadImageFromFile( hproperty,0 );                 }
			else if( CheckPropertyName( hproperty, "LOWBATTERY_TEXT"        ) ){ LOWBATTERY_TEXT   = LoadImageFromFile( hproperty,0 );                 }
			else if( CheckPropertyName( hproperty, "LOWBATTERY_AREA"        ) ){ LoadIntArray( hproperty,0,4,LOWBATTERY_AREA );                        }
			else if( CheckPropertyName( hproperty, "LOWBATTERY_TEXTAREA"    ) ){ LoadIntArray( hproperty,0,4,LOWBATTERY_TEXTAREA );                    }
			else if( CheckPropertyName( hproperty, "COLORANIMATION"         ) ){ g_AnimationBackgroundColor  = MesParser_GetInt( MesParser_GetValue(hproperty,0) ); }
			else if( CheckPropertyName( hproperty, "TITLE"                  ) ){ TITLE   = LoadImageFromFile( hproperty,0 );                 }
			else if( CheckPropertyName( hproperty, "TITLE_ALPHA"            ) ){ TITLE_ALPHA   = LoadImageFromFile( hproperty,0 );                 }
			else if( CheckPropertyName( hproperty, "TITLE_POS"              ) ){ LoadIntArray( hproperty,0,2,TITLE_POS );                    }
			else { RETAILMSG( 1, (L"*E:LoadSkin : Unknown proterty(%d,%d)\n", i, __LINE__ ) ); }
		}
	}



	// load menus
	{
		int numberofchildnodes = MesParser_GetNumberOfChildNodes( rootnode );
		int i;
		for( i=0; i<numberofchildnodes; i++ )
		{
			HMESPARSERNODE hnode = MesParser_GetChildNode( rootnode, i );
			const char* nodename = MesParser_GetNodeName( hnode );

			if( 0 == strcmp( nodename, "Menu" ) )
			{
				int index = g_MenuList.size();
				g_MenuList.push_back(Menu());
				if( ! g_MenuList[index].LoadSkin( hnode ) ){ return FALSE; }
			}
			else if( 0 == strcmp( nodename, "Button_Slide_Unlock" ) )
			{
				g_UnlockSlideButton.LoadSkin( hnode );
			}
			else if( 0 == strcmp( nodename, "Button_Slide_PowerOff" ) )
			{
				g_PowerOffSlideButton.LoadSkin( hnode );
			}
			else if( 0 == strcmp( nodename, "Button_Push_PowerOffCancel" ) )
			{
				g_PowerOffCancelButton.LoadSkin( hnode );
			}			
			else
			{
				RETAILMSG( 1, (L"*E:Menu::LoadSkin : Unknown node\n" ) );
			}
		}
	}

	if( (int)g_MenuList.size() > g_CurrentMenu && g_CurrentMenu >= 0 )
	{
		g_MenuList[0].SetCurrent(TRUE);
		glLightfv(GL_LIGHT0, GL_AMBIENT , g_MenuList[g_CurrentMenu].m_Ambient );
	}

	return TRUE;
}


void MESUI_UnloadSkin( void )
{
	if( INVALIDBUFFEROBJECT != g_DiceVertexBuffer )
	{
		glDeleteHWBuffersOES(1, &g_DiceVertexBuffer);
		g_DiceVertexBuffer = INVALIDBUFFEROBJECT;
	}

	unsigned int menu;
	for( menu=0; menu<g_MenuList.size(); menu++ )
	{
		g_MenuList[menu].UnloadSkin();
	}
	g_MenuList.clear();

	g_UnlockSlideButton.UnloadSkin();
	g_PowerOffSlideButton.UnloadSkin();
	g_PowerOffCancelButton.UnloadSkin();

	if( WALLPAPER      ){ MESLauncher_UnloadImage( WALLPAPER      ); WALLPAPER      = 0; }
	if( BACKGROUND     ){ MESLauncher_UnloadImage( BACKGROUND     ); BACKGROUND     = 0; }	
	if( g_BatteryLevel ){ MESLauncher_UnloadImage( g_BatteryLevel ); g_BatteryLevel = 0; }
	if( g_BatteryLevelAlpha ){ MESLauncher_UnloadImage( g_BatteryLevelAlpha ); g_BatteryLevelAlpha = 0; }
	if( g_TimeDigit    ){ MESLauncher_UnloadImage( g_TimeDigit    ); g_TimeDigit    = 0; }
	if( g_TimeDigitAlpha){ MESLauncher_UnloadImage( g_TimeDigitAlpha ); g_TimeDigitAlpha= 0; }
	if( g_TimeAMPM     ){ MESLauncher_UnloadImage( g_TimeAMPM     ); g_TimeAMPM     = 0; }
	if( g_TimeAMPMAlpha){ MESLauncher_UnloadImage( g_TimeAMPMAlpha ); g_TimeAMPMAlpha= 0; }
	if( g_OverlayVolumeLevel  ){ MESLauncher_UnloadImage( g_OverlayVolumeLevel  ); g_OverlayVolumeLevel  = 0; }
	if( APPWAIT_TEXT ){ MESLauncher_UnloadImage(APPWAIT_TEXT); APPWAIT_TEXT = 0;}
	if( USBSTORAGE_ALPHA   ){ MESLauncher_UnloadImage(USBSTORAGE_ALPHA  ); USBSTORAGE_ALPHA = 0; }
	if( USBSTORAGE_OVERLAY ){ MESLauncher_UnloadImage(USBSTORAGE_OVERLAY); USBSTORAGE_OVERLAY = 0; }
	if( USBSTORAGE_TEXT    ){ MESLauncher_UnloadImage(USBSTORAGE_TEXT   ); USBSTORAGE_TEXT = 0; }
	if( LOWBATTERY_BACK    ){ MESLauncher_UnloadImage(LOWBATTERY_BACK   ); LOWBATTERY_BACK = 0; }
	if( LOWBATTERY_TEXT    ){ MESLauncher_UnloadImage(LOWBATTERY_TEXT   ); LOWBATTERY_TEXT = 0; }
	if( TITLE    ){ MESLauncher_UnloadImage(TITLE   ); TITLE = 0; }
	if( TITLE_ALPHA    ){ MESLauncher_UnloadImage(TITLE_ALPHA   ); TITLE_ALPHA = 0; }

	g_LowBatteryShow     = false;
	g_LowBatteryShowPos  = 0.0f;
	g_LowBatteryShowSpeed= 0.0f;
	g_AnimationBackgroundColor = 0;
}

void MESUI_MessageProc( MESUISTATE CurState, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam )
{
	int x = LOWORD(lParam); 
    int y = HIWORD(lParam);
	//Menu CurMenu = g_MenuList[g_CurrentMenu];
	Menu *pCurMenu = &(g_MenuList[g_CurrentMenu]);
	if(g_DrawMouse && (WM_TIMER == Msg) && (MOUSE_STOP_TIMER == wParam))
	{
		KillTimer( hWnd, MOUSE_STOP_TIMER );
		g_DrawMouse = FALSE;
	}
	switch( CurState )
	{
	case MESUISTATE_MENU          :
		switch( Msg )
		{
		case WM_LBUTTONDBLCLK:
		case WM_LBUTTONDOWN:
			pCurMenu->OnSelect( x, y );
			g_MouseButton[0] = true;
			SetLightPosition( x, y );
			g_MouseMove[0] = 0;
			g_MouseMove[1] = 0;
			g_MousePos[0] = x;
			g_MousePos[1] = y;
			break;
		case WM_MOUSEMOVE:
			if( g_MouseButton[0] )
			{
				SetLightPosition( x, y );
			}
			g_MouseMove[0] = x - g_MousePos[0];
			g_MouseMove[1] = y - g_MousePos[1];
			g_MousePos[0] = x;
			g_MousePos[1] = y;
			g_DrawMouse = TRUE;
			SetTimer( hWnd, MOUSE_STOP_TIMER, MOUSE_STOP_INTERVAL, NULL );
			break;
		case WM_LBUTTONUP:
		{
			//unsigned int nMenu = g_MenuList.size();
			for(unsigned int i=0; i<g_MenuList.size(); i++)
			{
				Menu *pTempMenu = &(g_MenuList[i]);
				if((y < pTempMenu->m_TitlePos[1]) || (y > pTempMenu->m_TitlePos[1] + pTempMenu->m_TitleHeight))
				{
					break;
				}
				else if((x >= pTempMenu->m_TitlePos[0]) && (x < pTempMenu->m_TitlePos[0] + pTempMenu->m_TitleWidth))
				{
					pCurMenu->SetCurrent(FALSE);
					g_CurrentMenu = i;
					pCurMenu = pTempMenu;
					pCurMenu->SetCurrent(TRUE);
					break;
				}
			}
			g_MouseButton[0] = false;
			g_MousePos[0] = x;
			g_MousePos[1] = y;
			SetLightPosition( x, y );
			{
				const Button* pActiveButton = pCurMenu->OnAction( x, y );
				if( pActiveButton )
				{
					switch( pActiveButton->m_ActionType )
					{
					case 0:// none
						//assert(false);
						break;
					case 1:// run application
						PostMessage( hWnd, MESUIMSG_ONBUTTONCLICK, pActiveButton->m_ActionParam, (LPARAM)pActiveButton->m_MessageString );
						break;
					case 2:// run sub menu
						ChangeSceneFromMenuToMenu ( pActiveButton->m_ActionParam );
						break;
					case 3:// post MESUIMSG_EXIT message
						PostMessage( hWnd, MESUIMSG_EXIT, pActiveButton->m_ActionParam, (LPARAM)pActiveButton->m_MessageString );//.c_str()
						break;
					}				
				}
			}
			break;
		}
		case SYSTEMEVENT_KEYDOWN_MENU: // keydown event of menu key
			{
				const Button* pActiveButton = pCurMenu->GetActiveButton();
				if( pActiveButton )
				{
					int cx,cy;
					if( pActiveButton )
					{
						cx = pActiveButton->m_IconX + (pActiveButton->m_IconW/2);
						cy = pActiveButton->m_IconY + (pActiveButton->m_IconH/2);
					}
					else
					{
						cx = (g_ScreenWidth /2);
						cy = (g_ScreenHeight/2);
					}
					pCurMenu->m_Selected = pCurMenu->m_Avtivated;
					pCurMenu->OnAction( cx, cy );
					SetLightPosition( cx, cy );
					switch( pActiveButton->m_ActionType )
					{
					case 0:// none
						//assert(false);
						break;
					case 1:// run application					
						PostMessage( hWnd, MESUIMSG_ONBUTTONCLICK, pActiveButton->m_ActionParam, (LPARAM)pActiveButton->m_MessageString );
						break;
					case 2:// run sub menu
						ChangeSceneFromMenuToMenu ( pActiveButton->m_ActionParam );
						break;
					}				
				}
			}
			break;
		}	
		break;
	case MESUISTATE_WAITAPP       :
		break;
	case MESUISTATE_APP           :
		break;
	case MESUISTATE_USBSTORAGE    :
		break;
	case MESUISTATE_POWERSAVE     :
		break;
	case MESUISTATE_UNLOCKQUERY   :
		switch( Msg )
		{
		case WM_LBUTTONDBLCLK:
		case WM_LBUTTONDOWN:
			g_UnlockSlideButton.OnLButtonDown( x, y );
			break;
		case WM_MOUSEMOVE:
			g_UnlockSlideButton.OnMouseMove( x, y );
			break;
		case WM_LBUTTONUP:
			if( g_UnlockSlideButton.OnLButtonUp( x, y ) )
			{
				g_UnlockSlideButton.Hold();
				PostMessage( hWnd, MESUIMSG_ONUNLOCK, 0, 0 );
			}
			break;
		}
		break;
	case MESUISTATE_POWERDOWNQUERY:
		switch( Msg )
		{
		case WM_LBUTTONDBLCLK:
		case WM_LBUTTONDOWN:
			g_PowerOffSlideButton.OnLButtonDown( x, y );
			g_PowerOffCancelButton.OnLButtonDown( x, y );
			break;
		case WM_MOUSEMOVE:
			g_PowerOffSlideButton.OnMouseMove( x, y );
			g_PowerOffCancelButton.OnMouseMove( x, y );
			break;
		case WM_LBUTTONUP:
			if( g_PowerOffSlideButton.OnLButtonUp( x, y ) )
			{
				g_PowerOffSlideButton.Hold();
				PostMessage( hWnd, MESUIMSG_ONPOWERDOWNOK, 0, 0 );
			}
			if( g_PowerOffCancelButton.OnLButtonUp( x, y ) )
			{
				g_PowerOffCancelButton.Hold();
				PostMessage( hWnd, MESUIMSG_ONPOWERDOWNCANCEL, 0, 0 );
			}
			break;
		}
		break;
	}

}

unsigned int MESUI_GetMenuState( void )
{
	Menu& CurMenu = g_MenuList[g_CurrentMenu];
	return ((g_CurrentMenu&0xFF)<<16) | (CurMenu.m_Avtivated & 0xFFFF);
}

void MESUI_SetMenuState( unsigned int MenuState )
{
	g_CurrentMenu = (MenuState>>16) & 0xFF;
	Menu& CurMenu = g_MenuList[g_CurrentMenu];
	CurMenu.m_Avtivated = static_cast<short>(MenuState & 0xFFFF);
}

void MESUI_DrawMenu ( void )
{
	glClear( GL_COLOR_BUFFER_BIT );
	Menu& CurMenu = g_MenuList[g_CurrentMenu];
	for( unsigned int i=0; i<CurMenu.m_DiceButtonList.size(); i++ )
	{
		CurMenu.m_DiceButtonList[i].m_Rotate_Normal = CurMenu.m_DiceButtonList[i].m_Rotate_Normal * CurMenu.m_DiceButtonList[i].m_Rotate_NormalSpeed;
		CurMenu.m_DiceButtonList[i].m_CurIconX = CurMenu.m_DiceButtonList[i].m_IconX;
		CurMenu.m_DiceButtonList[i].m_CurIconY = CurMenu.m_DiceButtonList[i].m_IconY;
		if( g_MouseButton[0] )
		{
			int X = CurMenu.m_DiceButtonList[i].m_IconX;
			int Y = CurMenu.m_DiceBu

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -