Skip to content
This repository was archived by the owner on Apr 30, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions mp/src/game/client/NeotokyoSource/VGUI/neobutton.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include "cbase.h"
#include "neobutton.h"
#include <vgui/ISurface.h>

namespace vgui
{

CNButton::CNButton( Panel *parent, const char *panelName, const char *text ) : Button( parent, panelName, text )
{
SetPaintBackgroundEnabled( false );

m_iButtonNormalId = surface()->CreateNewTextureID();
surface()->DrawSetTextureFile( m_iButtonNormalId, "vgui/buttons/button_normal", true, false );

m_iButtonPressedId = surface()->CreateNewTextureID();
surface()->DrawSetTextureFile( m_iButtonPressedId, "vgui/buttons/button_pressed", true, false );

m_iButtonMouseoverId = surface()->CreateNewTextureID();
surface()->DrawSetTextureFile( m_iButtonMouseoverId, "vgui/buttons/button_mouseover", true, false );

m_iButtonDisabledId = surface()->CreateNewTextureID();
surface()->DrawSetTextureFile( m_iButtonDisabledId, "vgui/buttons/button_disabled", true, false );

m_iButtonArmedId = surface()->CreateNewTextureID();
surface()->DrawSetTextureFile( m_iButtonArmedId, "vgui/buttons/button_armed", true, false );

m_fUnknown = 0.f;
}

CNButton::~CNButton()
{
}

void CNButton::OnMousePressed( MouseCode code )
{
BaseClass::OnMousePressed( code );
}

void CNButton::PaintBackground()
{
}

void CNButton::PaintBorder()
{
}

void CNButton::DrawFocusBorder( int tx0, int ty0, int tx1, int ty1 )
{
BaseClass::DrawFocusBorder( tx0, ty0, tx1, ty1 - 2 );
}

}
39 changes: 39 additions & 0 deletions mp/src/game/client/NeotokyoSource/VGUI/neobutton.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#ifndef NEO_BUTTON_H
#define NEO_BUTTON_H

#ifdef _WIN32
#pragma once
#endif

#include <vgui_controls/Button.h>

namespace vgui
{

class CNButton : public Button
{
DECLARE_CLASS_SIMPLE( CNButton, Button );

public:
CNButton( Panel *parent, const char *panelName, const char *text );
virtual ~CNButton();

public:
virtual void OnMousePressed( MouseCode code );
virtual void PaintBackground();
virtual void PaintBorder();
virtual void DrawFocusBorder( int tx0, int ty0, int tx1, int ty1 );

private:
int m_iButtonNormalId;
int m_iButtonPressedId;
int m_iButtonMouseoverId;
int m_iButtonDisabledId;
int m_iButtonArmedId;

float m_fUnknown;
};

}

#endif // NEO_BUTTON_H
259 changes: 259 additions & 0 deletions mp/src/game/client/NeotokyoSource/VGUI/neoclassmenu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
#include "cbase.h"
#include "neoclassmenu.h"
#include "clientmode_neonormal.h"
#include "c_neoplayer.h"
#include "neoimagebutton.h"
#include "IGameUIFuncs.h"

static const char* s_ClassMenuClassesJinrai[ 18 ]
{
"vgui/cm/none",
"vgui/cm/none",
"vgui/cm/none",
"vgui/cm/jinrai_scout01",
"vgui/cm/jinrai_scout02",
"vgui/cm/jinrai_scout03",
"vgui/cm/jinrai_assault01",
"vgui/cm/jinrai_assault02",
"vgui/cm/jinrai_assault03",
"vgui/cm/jinrai_heavy01",
"vgui/cm/jinrai_heavy02",
"vgui/cm/jinrai_heavy03",
"vgui/cm/none",
"vgui/cm/none",
"vgui/cm/none",
"vgui/cm/none",
"vgui/cm/none",
"vgui/cm/none"
};

static const char* s_ClassMenuClassesNsf[ 18 ]
{
"vgui/cm/none",
"vgui/cm/none",
"vgui/cm/none",
"vgui/cm/nsf_scout01",
"vgui/cm/nsf_scout02",
"vgui/cm/nsf_scout03",
"vgui/cm/nsf_assault01",
"vgui/cm/nsf_assault02",
"vgui/cm/nsf_assault03",
"vgui/cm/nsf_heavy01",
"vgui/cm/nsf_heavy02",
"vgui/cm/nsf_heavy03",
"vgui/cm/none",
"vgui/cm/none",
"vgui/cm/none",
"vgui/cm/none",
"vgui/cm/none",
"vgui/cm/none"
};

// This can get really a lot simpler, let's keep it this way for now. Also we need to think on a better name
const char* GetNameOfClass( int teamId, int classId, int variant )
{
if ( teamId == 2 && classId < 6 && variant < 3 )
{
return s_ClassMenuClassesJinrai[ classId + variant + 2 * classId ];
}

else if ( teamId == 3 && classId < 6 && variant < 3 )
{
return s_ClassMenuClassesNsf[ classId + variant + 2 * classId ];
}

return "vgui/cm/none";
}


CNeoClassMenu::CNeoClassMenu( IViewPort *pViewPort ) : CNeoFrame( PANEL_CLASS )
{
m_pViewPort = pViewPort;

m_iJumpKey = 0;
m_iScoreboardKey = 0;

m_bNeedsUpdate = false;

LoadControlSettings( "Resource/UI/ClassMenu.res" );
InvalidateLayout();

m_fCreationTime = gpGlobals->curtime;
}

CNeoClassMenu::~CNeoClassMenu()
{
}

void CNeoClassMenu::ApplySchemeSettings( vgui::IScheme* pScheme )
{
BaseClass::ApplySchemeSettings( pScheme );
}

void CNeoClassMenu::OnCommand( const char* command )
{
if ( GetClientModeNEONormal()->IsNEODev() )
engine->ClientCmd( "iamantdev" );

if ( !V_stricmp( command, "vguicancel" ) || !V_stricmp( command, "Close" ) )
{
Close();
gViewPortInterface->ShowBackGround( false );
}

else if ( !V_stricmp( command, "playerready" ) )
{
engine->ClientCmd( command );
Close();
gViewPortInterface->ShowBackGround( false );
}

else if ( !V_stricmp( command, "SetVariant 0" ) )
{
C_NEOPlayer::GetLocalNEOPlayer()->m_iOldClassType = 0;

if ( m_bUnknown )
{
engine->ClientCmd( command );
Close();
gViewPortInterface->ShowBackGround( false );
}
}

else if ( !V_stricmp( command, "SetVariant 1" ) )
{
C_NEOPlayer::GetLocalNEOPlayer()->m_iOldClassType = 1;

if ( m_bUnknown )
{
engine->ClientCmd( command );
Close();
gViewPortInterface->ShowBackGround( false );
}
}

else if ( !V_stricmp( command, "SetVariant 2" ) )
{
C_NEOPlayer::GetLocalNEOPlayer()->m_iOldClassType = 2;

if ( m_bUnknown )
{
engine->ClientCmd( command );
Close();
gViewPortInterface->ShowBackGround( false );
}
}

else if ( !V_stricmp( command, "setclass 1" ) )
{
m_bUnknown = true;
CreateImagePanels( 1 );
engine->ClientCmd( command );
}

else if ( !V_stricmp( command, "setclass 2" ) )
{
m_bUnknown = true;
CreateImagePanels( 2 );
engine->ClientCmd( command );
}

else if ( !V_stricmp( command, "setclass 3" ) )
{
m_bUnknown = true;
CreateImagePanels( 3 );
engine->ClientCmd( command );
}

engine->ClientCmd( command );
BaseClass::OnCommand( command );
}

void CNeoClassMenu::OnKeyCodePressed( vgui::KeyCode code )
{
if ( !m_iScoreboardKey || m_iScoreboardKey != code )
BaseClass::OnKeyCodePressed( code );
}

void CNeoClassMenu::Update()
{
C_NEOPlayer* localPlayer = C_NEOPlayer::GetLocalNEOPlayer();

if ( localPlayer && (localPlayer->GetTeamNumber() == 2 || localPlayer->GetTeamNumber() == 3) )
{
m_bNeedsUpdate = false;
CreateImagePanels( localPlayer->m_iClassType );
}
}

void CNeoClassMenu::ShowPanel( bool bShow )
{
gViewPortInterface->ShowPanel( PANEL_SCOREBOARD, false );

if ( IsVisible() == bShow )
return;

if ( bShow )
{
Activate();
SetMouseInputEnabled( true );

if ( !m_iJumpKey )
m_iJumpKey = gameuifuncs->GetButtonCodeForBind( "jump" );

if ( !m_iScoreboardKey )
m_iScoreboardKey = gameuifuncs->GetButtonCodeForBind( "showscores" );

MoveToCenterOfScreen();

int classId = C_NEOPlayer::GetLocalNEOPlayer()->m_iClassType;

if ( classId == 0 )
{
classId = 1;
engine->ClientCmd( "setclass 1" );
}

m_bUnknown = true;

CreateImagePanels( classId );
CreateImagePanels( classId );
}

else
{
SetVisible( false );
SetMouseInputEnabled( false );
}

m_pViewPort->ShowBackGround( bShow );
}

void CNeoClassMenu::CreateImagePanels( int classId )
{
if ( classId < 1 )
classId = 1;

if ( classId > 3 )
classId = 3;

C_NEOPlayer* localPlayer = C_NEOPlayer::GetLocalNEOPlayer();

if ( !localPlayer )
return;

if ( localPlayer->GetTeamNumber() != 2 && localPlayer->GetTeamNumber() != 3 )
{
m_bNeedsUpdate = true;
classId = 0;
}

vgui::CNImageButton* imagePanel = (vgui::CNImageButton*) FindChildByName( "Model_ImagePanel" );
imagePanel->SetTexture( GetNameOfClass( localPlayer->GetTeamNumber(), classId, 0 ) );

vgui::CNImageButton* imagePanel2 = (vgui::CNImageButton*) FindChildByName( "Model_ImagePanel2" );
imagePanel2->SetTexture( GetNameOfClass( localPlayer->GetTeamNumber(), classId, 1 ) );

vgui::CNImageButton* imagePanel3 = (vgui::CNImageButton*) FindChildByName( "Model_ImagePanel3" );
imagePanel3->SetTexture( GetNameOfClass( localPlayer->GetTeamNumber(), classId, 2) );
}
Loading