📄 mes_ui.cpp
字号:
else { RETAILMSG( 1, (L"*E:Button_Dice::LoadSkin : Unknown proterty(%d,%d)\n", i, __LINE__ ) ); }
}
m_CurIconX = m_IconX;
m_CurIconY = m_IconY;
m_DiceZ = 0;
m_DiceTartgetZ = 0;
m_DirectionCur = Quaternionf::IDENTITY;
m_Rotate_Normal = Quaternionf::IDENTITY;
m_Rotate_NormalSpeed.FromAxisAngle( Vector3f(1,1,1), 1*3.14159f/180.0f );
m_Rotate_NormalSpeed.Normalize();
m_Rotate_Cursor = Quaternionf::IDENTITY;
m_Rotate_CursorSpeed= Quaternionf::IDENTITY;
return true;
}
void UnloadSkin( void )
{
if( m_DiceTexture ){ MESLauncher_UnloadTexture( m_DiceTexture ); m_DiceTexture = 0; }
if( m_TitleTexture ){ MESLauncher_UnloadImage ( m_TitleTexture ); m_TitleTexture = 0; }
if( m_TitleAlphaTexture ){ MESLauncher_UnloadImage( m_TitleAlphaTexture ); m_TitleAlphaTexture = 0; }
}
DiceButton &operator =(DiceButton &btnSource)
{
((Button)(*this)) = ((Button)btnSource);
m_DiceTexture = btnSource.m_DiceTexture;
m_TitleAlphaTexture = btnSource.m_TitleAlphaTexture;
m_CurIconX = btnSource.m_CurIconX;
m_CurIconY = btnSource.m_CurIconY;
m_DiceZ = btnSource.m_DiceZ;
m_DiceTartgetZ = btnSource.m_DiceTartgetZ;
m_DirectionCur = btnSource.m_DirectionCur;
m_Rotate_Normal = btnSource.m_Rotate_Normal;
m_Rotate_NormalSpeed = btnSource.m_Rotate_NormalSpeed;
m_Rotate_Cursor = btnSource.m_Rotate_Cursor;
m_Rotate_CursorSpeed = btnSource.m_Rotate_CursorSpeed;
return *this;
}
};
void DrawDice ( int X, int Y, int W, int H, float ZOffset );
void DrawTime ( float Bright );
void DrawBatteryLevel ( float Bright );
void DrawTitleBar ( float Bright );
int g_AnimationBackgroundColor = 0;
float g_BackgroundColor[3] = {0.0f, 1.0f, 0.0f};
float g_BackgroundColorFactor = 0.0f;
#define MINI_COLOR (0.6f)
#define MINI_COLOR_INVERSE (0.4f)
void AnimationBackgroundColor( void )
{
if( g_AnimationBackgroundColor )
{
g_BackgroundColorFactor += 1.0f/(30.0f*5);
if( g_BackgroundColorFactor >= 6.0f ){ g_BackgroundColorFactor -= 6.0f; }
if( g_BackgroundColorFactor < 1.0f )
{
// G -> G+B
g_BackgroundColor[0] = MINI_COLOR;//0;
g_BackgroundColor[1] = 1.0f;
g_BackgroundColor[2] = MINI_COLOR + MINI_COLOR_INVERSE*g_BackgroundColorFactor;
}
else if( g_BackgroundColorFactor < 2.0f )
{
// G+B -> B
g_BackgroundColor[0] = MINI_COLOR;//0;
g_BackgroundColor[1] = MINI_COLOR + MINI_COLOR_INVERSE*(2.0f-g_BackgroundColorFactor);//2.0f-g_BackgroundColorFactor;
g_BackgroundColor[2] = 1.0f;
}
else if( g_BackgroundColorFactor < 3.0f )
{
// B -> B+R
g_BackgroundColor[0] = MINI_COLOR + MINI_COLOR_INVERSE*(g_BackgroundColorFactor - 2.0f);//g_BackgroundColorFactor-2.0f;
g_BackgroundColor[1] = MINI_COLOR;//0;
g_BackgroundColor[2] = 1.0f;
}
else if( g_BackgroundColorFactor < 4.0f )
{
// B+R -> R
g_BackgroundColor[0] = 1.0f;
g_BackgroundColor[1] = MINI_COLOR;//0;
g_BackgroundColor[2] = MINI_COLOR + MINI_COLOR_INVERSE*(4.0f-g_BackgroundColorFactor);//4.0f-g_BackgroundColorFactor;
}
else if( g_BackgroundColorFactor < 5.0f )
{
// R -> R+G
g_BackgroundColor[0] = 1.0f;
g_BackgroundColor[1] = MINI_COLOR + MINI_COLOR_INVERSE*(g_BackgroundColorFactor - 4.0f);//g_BackgroundColorFactor-4.0f;
g_BackgroundColor[2] = MINI_COLOR;
}
else if( g_BackgroundColorFactor < 6.0f )
{
// R+G -> G
g_BackgroundColor[0] = MINI_COLOR + MINI_COLOR_INVERSE*(6.0f-g_BackgroundColorFactor);//6.0f-g_BackgroundColorFactor;
g_BackgroundColor[1] = 1.0f;
g_BackgroundColor[2] = MINI_COLOR;
}
}
else
{
g_BackgroundColor[0] = 1.0f;
g_BackgroundColor[1] = 1.0f;
g_BackgroundColor[2] = 1.0f;
}
}
struct Menu
{
bool m_bCurrent;
short m_Selected;
short m_Avtivated;
unsigned int m_SubItemVisibility;
float m_Ambient[4]; // Ambient light color
float m_Glow[4]; // Dice glow color
float m_MenuTextAlpha; // Alpha value for menu text
float m_ActiveMenuTextAlpha; // Alpha value for active menu text
MESLauncher_Image m_Title;
MESLauncher_Image m_TitleAlpha;
int m_TitlePos[2];
int m_TitleWidth;
int m_TitleHeight;
/*std::vector<ImageButton> m_ImageButtonList;
std::vector<DiceButton > m_DiceButtonList ;*/
SVector<ImageButton> m_ImageButtonList;
SVector<DiceButton > m_DiceButtonList ;
bool LoadSkin( HMESPARSERNODE hNode )
{
if( 0 != strcmp( MesParser_GetNodeName(hNode), "Menu" ) ){ return false; }
m_Selected = -1;
m_Avtivated= -1;
m_SubItemVisibility = 0;
m_Ambient[0] = 0;
m_Ambient[1] = 0;
m_Ambient[2] = 0;
m_Ambient[3] = 1.0f;
m_Glow[0] = 0.0f;
m_Glow[1] = 0.0f;
m_Glow[2] = 0.0f;
m_Glow[3] = 0.0f;
m_Title = 0;
m_TitleAlpha = 0;
m_bCurrent = FALSE;
m_TitlePos[0] = m_TitlePos[1] = 0;
{
int numberofproperties = MesParser_GetNumberOfProperties( hNode );
int i;
for( i=0; i<numberofproperties; i++ )
{
HMESPARSERPROPERTY hproperty = MesParser_GetProperty( hNode, i );
if ( CheckPropertyName( hproperty, "SUBITEMVISIBILITY" ) )
{
int j, count = MesParser_GetNumberOfValues( hproperty );
for( j=0; j<count; j++ )
{
const char* value = MesParser_GetIdentifier( MesParser_GetValue(hproperty,j) );
if( 0 == strcmp( value, "NULL" ) ){ m_SubItemVisibility = 0; }
else if( 0 == strcmp( value, "SUBITEMVISIBILITY_TIME" ) ){ m_SubItemVisibility |= SUBITEMVISIBILITY_TIME; }
else if( 0 == strcmp( value, "SUBITEMVISIBILITY_INPUTLOCKSTATE" ) ){ m_SubItemVisibility |= SUBITEMVISIBILITY_INPUTLOCKSTATE; }
else if( 0 == strcmp( value, "SUBITEMVISIBILITY_BATTERYLEVEL" ) ){ m_SubItemVisibility |= SUBITEMVISIBILITY_BATTERYLEVEL; }
else if( 0 == strcmp( value, "SUBITEMVISIBILITY_ALL" ) ){ m_SubItemVisibility |= SUBITEMVISIBILITY_ALL; }
else { RETAILMSG( 1, (L"*E:LoadSkin : Unknown value\n" ) ); }
}
}
else if( CheckPropertyName( hproperty, "AmbientColor" ) )
{
m_Ambient[0] = MesParser_GetFloat( MesParser_GetValue(hproperty,0) );
m_Ambient[1] = MesParser_GetFloat( MesParser_GetValue(hproperty,1) );
m_Ambient[2] = MesParser_GetFloat( MesParser_GetValue(hproperty,2) );
}
else if( CheckPropertyName( hproperty, "GlowColor" ) )
{
m_Glow[0] = MesParser_GetFloat( MesParser_GetValue(hproperty,0) );
m_Glow[1] = MesParser_GetFloat( MesParser_GetValue(hproperty,1) );
m_Glow[2] = MesParser_GetFloat( MesParser_GetValue(hproperty,2) );
}
else if( CheckPropertyName( hproperty, "MenuTextAlpha" ) ){ m_MenuTextAlpha = MesParser_GetFloat( MesParser_GetValue(hproperty,0) ); } // = 0.5f; // Alpha value for menu text
else if( CheckPropertyName( hproperty, "ActiveMenuTextAlpha" ) ){ m_ActiveMenuTextAlpha = MesParser_GetFloat( MesParser_GetValue(hproperty,0) ); } // = 1.0f; // Alpha value for active menu text
else if( CheckPropertyName( hproperty, "Title" ) )
{
m_Title = LoadImageFromFile( hproperty,0 );
m_TitleWidth = MESLauncher_GetImageWidth(m_Title);
m_TitleHeight = MESLauncher_GetImageHeight(m_Title);
}
else if( CheckPropertyName( hproperty, "TitleAlpha" ) ){ m_TitleAlpha = LoadImageFromFile( hproperty,0 ); }
else if( CheckPropertyName( hproperty, "Title_Pos" ) ){ LoadIntArray( hproperty,0,2,m_TitlePos ); }
else { RETAILMSG( 1, (L"*E:Menu::LoadSkin : Unknown proterty(%d,%d)\n", i, __LINE__ ) ); }
}
}
// load buttons
{
int numberofchildnodes = MesParser_GetNumberOfChildNodes( hNode );
int i;
for( i=0; i<numberofchildnodes; i++ )
{
HMESPARSERNODE childnode = MesParser_GetChildNode( hNode, i );
const char* nodename = MesParser_GetNodeName( childnode );
if( 0 == strcmp( nodename, "Button_Dice" ) )
{
unsigned int index = m_DiceButtonList.size();
m_DiceButtonList.push_back(DiceButton());
m_DiceButtonList[index].LoadSkin( childnode );
}
else if( 0 == strcmp( nodename, "Button_Flat" ) )
{
unsigned int index = m_ImageButtonList.size();
m_ImageButtonList.push_back(ImageButton());
m_ImageButtonList[index].LoadSkin( childnode );
}
else
{
RETAILMSG( 1, (L"*E:Menu::LoadSkin : Unknown node\n" ) );
}
}
}
return true;
}
void UnloadSkin( void )
{
if( m_Title ){ MESLauncher_UnloadImage( m_Title ); m_Title = 0; }
if( m_TitleAlpha ){ MESLauncher_UnloadImage( m_TitleAlpha ); m_TitleAlpha = 0; }
unsigned int button;
for( button=0; button<m_ImageButtonList.size(); button++ )
{
m_ImageButtonList[button].UnloadSkin();
}
for( button=0; button<m_DiceButtonList.size(); button++ )
{
m_DiceButtonList[button].UnloadSkin();
}
}
void SetCurrent(bool bCurrent)
{
m_bCurrent = bCurrent;
}
void DrawButtons( float Bright, int Mx, int My )
{
unsigned int i;
float black [] = {0.0f,0.0f,0.0f,0.0f};
float bright[] = {Bright,Bright,Bright,Bright};
//float bright[] = {1,1,1,Bright};
//float bright[] = {1,1,1,1};
glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, bright );
//if( g_AnimationBackgroundColor )
//{
//m_Ambient[0] = g_BackgroundColor[0] * 0.5f;
//m_Ambient[1] = g_BackgroundColor[1] * 0.5f;
//m_Ambient[2] = g_BackgroundColor[2] * 0.5f;
//glLightfv(GL_LIGHT0, GL_AMBIENT , m_Ambient );
//}
//if( Bright != 1.0f )
//if( Bright < 0.5f )
{
// glEnable( GL_BLEND );
//glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
// glBlendFunc( GL_ONE, GL_ONE );
}
for( i=0; i<m_DiceButtonList.size(); i++ )
{
if( m_DiceButtonList[i].m_DiceTexture )
{
glBindTexture( GL_TEXTURE_2D, m_DiceButtonList[i].m_DiceTexture );
glEnable( GL_TEXTURE_2D );
}
else
{
glDisable( GL_TEXTURE_2D );
}
bool isselected = ((m_Selected-BUTTONIDBASE_CUBE) == (int)i) &&
m_DiceButtonList[i].IsTouched(Mx,My);
if( isselected )
{
glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, m_Glow );
}
{
glPushMatrix();
Matrix3f mat;
m_DiceButtonList[i].m_DirectionCur.ToRotationMatrix( mat );
float glmat[16] =
{
mat[0][0], mat[1][0], mat[2][0], 0,
mat[0][1], mat[1][1], mat[2][1], 0,
mat[0][2], mat[1][2], mat[2][2], 0,
0,0,0,1
};
glMultMatrixf( glmat );
DrawDice( m_DiceButtonList[i].m_CurIconX, m_DiceButtonList[i].m_CurIconY, m_DiceButtonList[i].m_IconW, m_DiceButtonList[i].m_IconH, m_DiceButtonList[i].m_DiceZ );
glPopMatrix();
}
if( isselected )
{
glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, black );
}
}
glEnable( GL_BLEND );
glBlendFunc( GL_ZERO, GL_ONE_MINUS_SRC_COLOR );
for( i=0; i<m_DiceButtonList.size(); i++ )
{
bool isselected = ((m_Selected-BUTTONIDBASE_CUBE) == (int)i) &&
m_DiceButtonList[i].IsTouched(Mx,My);
if( m_DiceButtonList[i].m_TitleTexture )
{
if( isselected )
{
MESLauncher_DrawImage0( m_DiceButtonList[i].m_TitleAlphaTexture,
m_DiceButtonList[i].m_TitleX,
m_DiceButtonList[i].m_TitleY, Bright*m_ActiveMenuTextAlpha,Bright*m_ActiveMenuTextAlpha,Bright*m_ActiveMenuTextAlpha,1 );
}
else
{
MESLauncher_DrawImage0( m_DiceButtonList[i].m_TitleAlphaTexture,
m_DiceButtonList[i].m_TitleX,
m_DiceButtonList[i].m_TitleY, Bright*m_MenuTextAlpha,Bright*m_MenuTextAlpha,Bright*m_MenuTextAlpha,1 );
}
}
}
glBlendFunc( GL_SRC_ALPHA, GL_ONE );
for( i=0; i<m_DiceButtonList.size(); i++ )
{
bool isselected = ((m_Selected-BUTTONIDBASE_CUBE) == (int)i) &&
m_DiceButtonList[i].IsTouched(Mx,My);
if( m_DiceButtonList[i].m_TitleTexture )
{
if( isselected )
{
MESLauncher_DrawImage0( m_DiceButtonList[i].m_TitleTexture,
m_DiceButtonList[i].m_TitleX,
m_DiceButtonList[i].m_TitleY, Bright,Bright,Bright,m_ActiveMenuTextAlpha );
}
else
{
MESLauncher_DrawImage0( m_DiceButtonList[i].m_TitleTexture,
m_DiceButtonList[i].m_TitleX,
m_DiceButtonList[i].m_TitleY, Bright,Bright,Bright,m_MenuTextAlpha );
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -