Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class: CPlayerBalanceHUD ( CHUDImplUtils )
- {
- Fonts =
- {
- Medium = DXFont( "Ubuntu/Ubuntu-Regular.ttf", 10 );
- Medium2 = DXFont( "Ubuntu/Ubuntu-Regular.ttf", 11 );
- Small = DXFont( "Ubuntu/Ubuntu-Regular.ttf", 9 );
- };
- Colors =
- {
- White = "#ffffff";
- Black = "#000000";
- Theme = "#d19d22";
- };
- m_iX = F_SCREEN_X - 30 - 219;
- m_iY = 22;
- m_iWidth = 219;
- m_iHeight = 33;
- m_sPath = S_IMAGES_RESOURCE_HUD_PATH + "Player/balance/";
- m_iLastMoney = - 1;
- m_iLastLvl = - 1;
- m_iLastExp = - 1;
- CPlayerBalanceHUD = function( this )
- this.m_pBackground = CUILib():CreateStaticImage( this.m_sPath + "bg.png" )
- {
- X = this.m_iX;
- Y = this.m_iY;
- Width = this.m_iWidth;
- Height = this.m_iHeight;
- };
- this.m_pLabelText = this.m_pBackground:CreateLabel( "" )
- {
- X = 0;
- Y = -1;
- Width = this.m_pBackground.Width - 14;
- Height = this.m_pBackground.Height;
- Font = this.Fonts.Medium;
- Color = this.Colors.Theme;
- HorizontalAlign = { "right" };
- VerticalAlign = "center";
- };
- this.m_pLabelLevel = this.m_pBackground:CreateLabel( "" )
- {
- X = 57;
- Y = 5;
- Width = 100;
- Height = 30;
- Font = this.Fonts.Medium2;
- Color = this.Colors.White;
- };
- -- divider
- this.m_pRectDiv = this.m_pBackground:CreateRectangle()
- {
- X = 53;
- Y = "center";
- Width = 1;
- Height = 27;
- Color = this.Colors.White;
- Opacity = 0.2;
- };
- this.m_pLabelPrevExp = this.m_pBackground:CreateLabel( "" )
- {
- X = 8;
- Y = 3;
- Width = this.m_pLabelLevel.Width;
- Height = this.m_pLabelLevel.Height;
- Font = this.Fonts.Small;
- Color = this.Colors.White;
- Opacity = 1.0;
- };
- this.m_pLabelNextExp = this.m_pBackground:CreateLabel( "" )
- {
- X = this.m_pLabelPrevExp.X;
- Y = this.m_pLabelPrevExp.Y + this.m_pLabelPrevExp:GetTextHeight() - 5;
- Width = this.m_pLabelLevel.Width;
- Height = this.m_pLabelLevel.Height;
- Font = this.m_pLabelPrevExp.Font;
- Color = this.m_pLabelPrevExp.Color;
- Opacity = 1.0;
- };
- this.m_pRectProgressBg = this.m_pBackground:CreateRectangle()
- {
- X = this.m_pLabelNextExp.X;
- Y = this.m_pLabelNextExp.Y + this.m_pLabelNextExp:GetTextHeight() - 2;
- Width = 0;
- Height = 3;
- Color = this.Colors.Black;
- Opacity = 0.5;
- };
- this.m_pRectProgress = this.m_pRectProgressBg:CreateRectangle()
- {
- X = 0;
- Y = 0;
- Width = 0;
- Height = this.m_pRectProgressBg.Height;
- Color = this.Colors.White;
- Opacity = 0.5;
- };
- this:CHUD();
- end;
- _CPlayerBalanceHUD = function( this )
- this:_CHUD();
- this.m_pBackground:Delete();
- this.m_pBackground = NULL;
- end;
- OnRender = function( this )
- local iMoney = CLIENT:GetMoney();
- if ( iMoney ~= this.m_iLastMoney ) then
- this.m_iLastMoney = iMoney;
- local sMoney = math.currency( iMoney );
- this.m_pLabelText:SetText( sMoney );
- end
- local iLvl = CLIENT:GetLevel();
- if ( iLvl ~= this.m_iLastLvl ) then
- this.m_iLastLvl = iLvl;
- this.m_pLabelLevel:SetText( tostring( iLvl ) .. " " .. _( "Lvl" ) );
- end
- local iExp = CLIENT:GetExp();
- if ( iExp ~= this.m_iLastExp ) then
- this.m_iLastExp = iExp;
- local iPrevExp = CLIENT:GetMaxExpByLevel( iLvl );
- local iNextExp = CLIENT:GetMaxExpByLevel( iLvl + 1 );
- local fPercent = CPercent.Between( iPrevExp, iExp, iNextExp );
- local sPrevExp = tostring( iExp );
- local sNextExp = tostring( iNextExp );
- this.m_pLabelPrevExp:SetText( sPrevExp .. " /" );
- this.m_pLabelNextExp:SetText( sNextExp );
- local iFullWidth = this.m_pLabelPrevExp:GetTextExtent() + 2;
- -- Если меньше чем exp снизу, то берем снизу.
- if ( iFullWidth < this.m_pLabelNextExp:GetTextExtent() ) then
- iFullWidth = this.m_pLabelNextExp:GetTextExtent();
- end
- local iWidth = (int)( iFullWidth * ( fPercent / 100 ) );
- this.m_pRectProgress:SetWidth( iWidth );
- this.m_pRectProgressBg:SetWidth( iFullWidth );
- end
- end;
- OnOverrideVisible = function( this, bState )
- this.m_pBackground:SetVisible( bState, true );
- end;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement