networking
This commit is contained in:
32
fgui/__build.cpp
Normal file
32
fgui/__build.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "helper.h"
|
||||
#include "c.h"
|
||||
#include "ld.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "tier1/commandline.h"
|
||||
|
||||
CUtlVector<CUtlString> fgui_CompiledFiles = {
|
||||
"fgui/fgui.cpp",
|
||||
"fgui/widget.cpp",
|
||||
"fgui/rectangle.cpp",
|
||||
"fgui/label.cpp",
|
||||
};
|
||||
CUtlString fgui_lib;
|
||||
|
||||
int fgui_build()
|
||||
{
|
||||
CCProject compileProject = {};
|
||||
CLDProject ldProject = {};
|
||||
|
||||
compileProject.m_szName = "fgui";
|
||||
compileProject.files = fgui_CompiledFiles;
|
||||
compileProject.includeDirectories = all_IncludeDirectories;
|
||||
compileProject.bFPIC = true;
|
||||
ldProject = compileProject.Compile();
|
||||
ldProject.linkType = ELINK_STATIC_LIBRARY;
|
||||
|
||||
CUtlString outputProject = ldProject.Link();
|
||||
fgui_lib = outputProject;
|
||||
|
||||
return 0;
|
||||
};
|
||||
DECLARE_BUILD_STAGE(fgui, fgui_build);
|
||||
140
fgui/fgui.cpp
140
fgui/fgui.cpp
@@ -1 +1,139 @@
|
||||
#include "fgui/fgui.h"
|
||||
#include "fgui/fgui.h"
|
||||
#include "filesystem.h"
|
||||
#include "rendering.h"
|
||||
#include "tier1/utlvector.h"
|
||||
#include "fgui/widget.h"
|
||||
|
||||
|
||||
IGraphicsPipeline *fgui_RectPipeline;
|
||||
IGraphicsPipeline *fgui_TextPipeline;
|
||||
|
||||
void IFGUI::Init( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void IFGUI::Frame( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CUtlVector<CFGUI_Widget*> fgui_widgets;
|
||||
void IFGUI::AppendWidget( CFGUI_Widget *pWidget )
|
||||
{
|
||||
fgui_widgets.AppendTail(pWidget);
|
||||
}
|
||||
|
||||
void IFGUI::DestroyWidget( CFGUI_Widget *pWidget )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void IFGUI::SetRectColor( float r, float g, float b, float a )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void IFGUI::DrawRect( int32_t iPosX, int32_t iPosY, uint32_t uSizeX, uint32_t uSizeY )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CUtlVector<CFont*> fgui_fonts;
|
||||
CFont *fgui_pCurrentFont;
|
||||
|
||||
CFont *IFGUI::LoadFont( CUtlString szFontPath )
|
||||
{
|
||||
for (auto &font: fgui_fonts)
|
||||
{
|
||||
if (font->szName == szFontPath)
|
||||
return font;
|
||||
};
|
||||
CFont *pFont = new CFont;
|
||||
pFont->szName = szFontPath;
|
||||
pFont->pTexture = ITextureManager::LoadTexture(CUtlString("%s.png", szFontPath.GetString()));
|
||||
FileHandle_t f = IFileSystem::Open(CUtlString("%s.fontdata", szFontPath.GetString()), IFILE_READ);
|
||||
CUtlBuffer<char> b = IFileSystem::Size(f)+1;
|
||||
IFileSystem::Read(f, b.GetMemory(), IFileSystem::Size(f));
|
||||
IFileSystem::Close(f);
|
||||
char cCharacterSet[256] = {};
|
||||
uint32_t nElementsWidth;
|
||||
uint32_t nElementsHeight;
|
||||
V_sscanf(b, "%u %u %255s", &nElementsWidth, &nElementsHeight, cCharacterSet);
|
||||
V_printf("%i %i\n", nElementsWidth, nElementsHeight);
|
||||
return pFont;
|
||||
}
|
||||
|
||||
void IFGUI::SetTextFont( CFont *pFont )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void IFGUI::SetTextPos( float x, float y )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void IFGUI::SetTextColor( float r, float g, float b, float a )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void IFGUI::DrawText( CUtlString psz )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class CFGUI_Rendering: public IRenderingPipelineStep
|
||||
{
|
||||
public:
|
||||
virtual void Init() override;
|
||||
virtual void Frame( float fDelta ) override;
|
||||
virtual void Deinit() override;
|
||||
};
|
||||
DECLARE_UI_RENDERING_STAGE(CFGUI_Rendering, fgui_rendering);
|
||||
|
||||
void CFGUI_Rendering::Init()
|
||||
{
|
||||
fgui_RectPipeline = IRenderer::CreateGraphicsPipeline(
|
||||
{
|
||||
{"gfx/fgui_rect_vert.shader", SHADER_TYPE_VERTEX},
|
||||
{"gfx/fgui_rect_frag.shader", SHADER_TYPE_FRAGMENT},
|
||||
},
|
||||
{},
|
||||
24,
|
||||
8,
|
||||
{{0,0,EVertexFormat::VERTEX_FORMAT_X32Y32}},
|
||||
{EImageFormat::IMAGE_FORMAT_R8G8B8A8},
|
||||
true
|
||||
);
|
||||
fgui_TextPipeline = IRenderer::CreateGraphicsPipeline(
|
||||
{
|
||||
{"gfx/fgui_text_vert.shader", SHADER_TYPE_VERTEX},
|
||||
{"gfx/fgui_text_frag.shader", SHADER_TYPE_FRAGMENT},
|
||||
},
|
||||
{
|
||||
{SHADER_INPUT_TYPE_TEXTURES, 0},
|
||||
},
|
||||
25,
|
||||
8,
|
||||
{{0,0,EVertexFormat::VERTEX_FORMAT_X32Y32}},
|
||||
{EImageFormat::IMAGE_FORMAT_R8G8B8A8},
|
||||
true
|
||||
);
|
||||
};
|
||||
|
||||
void CFGUI_Rendering::Frame( float fDelta )
|
||||
{
|
||||
IRenderer::ResetState();
|
||||
IRenderer::SetDepthMode(DEPTH_MODE_LESS);
|
||||
for (auto &widget: fgui_widgets)
|
||||
{
|
||||
widget->Draw();
|
||||
}
|
||||
};
|
||||
|
||||
void CFGUI_Rendering::Deinit()
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
38
fgui/label.cpp
Normal file
38
fgui/label.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "fgui/label.h"
|
||||
#include "fgui/fgui.h"
|
||||
|
||||
CFGUI_Label::CFGUI_Label()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CFGUI_Label::SetFont( CUtlString font )
|
||||
{
|
||||
IFGUI::LoadFont(font);
|
||||
}
|
||||
|
||||
void CFGUI_Label::SetLabel( CUtlString text )
|
||||
{
|
||||
m_szText = text;
|
||||
}
|
||||
|
||||
void CFGUI_Label::SetLabelSize( uint32_t nSize )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CFGUI_Label::Event( FGUI_Event_t event )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CFGUI_Label::Draw()
|
||||
{
|
||||
IFGUI::SetTextColor(1, 1, 1, 1);
|
||||
IFGUI::DrawText(m_szText);
|
||||
}
|
||||
|
||||
CFGUI_Label::~CFGUI_Label()
|
||||
{
|
||||
|
||||
}
|
||||
0
fgui/rectangle.cpp
Normal file
0
fgui/rectangle.cpp
Normal file
30
fgui/widget.cpp
Normal file
30
fgui/widget.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "fgui/widget.h"
|
||||
#include "fgui/fgui.h"
|
||||
|
||||
CFGUI_Widget::CFGUI_Widget()
|
||||
{
|
||||
IFGUI::AppendWidget(this);
|
||||
}
|
||||
|
||||
CFGUI_Widget::~CFGUI_Widget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CFGUI_Widget::SetPosition( int32_t nX, int32_t nY )
|
||||
{
|
||||
m_iPosition[0] = nX;
|
||||
m_iPosition[1] = nY;
|
||||
}
|
||||
|
||||
void CFGUI_Widget::SetSize( uint32_t nX, uint32_t nY )
|
||||
{
|
||||
m_iSize[0] = nX;
|
||||
m_iSize[1] = nY;
|
||||
}
|
||||
|
||||
void CFGUI_Widget::SetParent( CFGUI_Widget *pParent )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user