networking
This commit is contained in:
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()
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user