Created
December 20, 2019 12:29
-
-
Save untodesu/db62a35ac78065bd51008f9993ff88c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "cbase.h" | |
| #include "filesystem.h" | |
| #include "../gameui_manager.h" | |
| #include "vgui_controls/AnimationController.h" | |
| #include <vgui/ISurface.h> | |
| #include <vgui/ILocalize.h> | |
| // memdbgon must be the last include file in a .cpp file!!! | |
| #include "tier0/memdbgon.h" | |
| using namespace vgui; | |
| #ifndef _X360 | |
| #define GAMEINFO_FILENAME "gameinfo.txt" | |
| #else | |
| // The .xtx file is a TCR requirement, as .txt files cannot live on the DVD. | |
| // The .xtx file only exists outside the zips (same as .txt and is made during the image build) and is read to setup the search paths. | |
| // So all other code should be able to safely expect gameinfo.txt after the zip is mounted as the .txt file exists inside the zips. | |
| // The .xtx concept is private and should only have to occurr here. As a safety measure, if the .xtx file is not found | |
| // a retry is made with the original .txt name | |
| #define GAMEINFO_FILENAME "gameinfo.xtx" | |
| #endif | |
| namespace gameui | |
| { | |
| //----------------------------------------------------------------------------- | |
| // Purpose: The game logo. Maybe i had to stay with default logo, but i wanted to make my own. | |
| // NOTE: due to the COMPLETELY SHITFULL implementation of source's gameUI, default logo is being renered even the ui us overrided, | |
| // so, please do not touch Menu.???.? in the clientscheme.res, this is important. I will delete this NOTE when i will realise how to get rid of this. | |
| //----------------------------------------------------------------------------- | |
| class GameLogo : public UIElement { | |
| DECLARE_CLASS(GameLogo, UIElement); | |
| public: | |
| GameLogo(vgui::Panel *parent); | |
| void Paint(void); | |
| void Init(void); | |
| private: | |
| char m_szText[1024]; | |
| vgui::HFont m_hFont; | |
| Color m_TextColor; | |
| }; | |
| //----------------------------------------------------------------------------- | |
| // Purpose: Create function & API helper for GameUI API | |
| //----------------------------------------------------------------------------- | |
| static UIElement * GameLogo_Instance(void) | |
| { | |
| return new GameLogo(NULL); | |
| } | |
| static UIElementHelper s_GameLogo_Helper(GameLogo_Instance); | |
| //----------------------------------------------------------------------------- | |
| // Purpose: Constructor | |
| //----------------------------------------------------------------------------- | |
| GameLogo::GameLogo(Panel *parent) : BaseClass(parent, "GameUI_Logo") | |
| { | |
| SetProportional(true); | |
| SetPaintBackgroundEnabled(false); | |
| SetPaintBorderEnabled(false); | |
| Init(); | |
| PerformLayout(); | |
| } | |
| //----------------------------------------------------------------------------- | |
| // Purpose: Paint goods | |
| //----------------------------------------------------------------------------- | |
| void GameLogo::Paint(void) | |
| { | |
| surface()->DrawSetTextPos(0, 0); | |
| surface()->DrawSetTextFont(m_hFont); | |
| surface()->DrawSetTextColor(m_TextColor); | |
| //Copy string without any changes, its not localized. | |
| std::wstring str; | |
| for(int i = 0; i < Q_strlen(m_szText); i++) { | |
| str += m_szText[i]; | |
| } | |
| surface()->DrawPrintText(str.c_str(), str.size()); | |
| } | |
| //----------------------------------------------------------------------------- | |
| // Purpose: (Re-)Create logo data (parse .res) | |
| //----------------------------------------------------------------------------- | |
| void GameLogo::Init(void) | |
| { | |
| BaseClass::Init(); | |
| //Get scheme | |
| IScheme* scheme = vgui::scheme()->GetIScheme(GetScheme()); | |
| int xpos = 0, ypos = 0; | |
| int wide = 0, tall = 0; | |
| //Get X position | |
| const char *res_xpos = scheme->GetResourceString("Logo.XPos"); | |
| if(res_xpos && *res_xpos) { | |
| xpos = atoi(res_xpos); | |
| } | |
| //Get Y position | |
| const char *res_ypos = scheme->GetResourceString("Logo.YPos"); | |
| if(res_ypos && *res_ypos) { | |
| ypos = atoi(res_ypos); | |
| } | |
| //Get panel width | |
| const char *res_wide = scheme->GetResourceString("Logo.Wide"); | |
| if(res_wide && *res_wide) { | |
| wide = atoi(res_wide); | |
| } | |
| //Get panel height | |
| const char *res_tall = scheme->GetResourceString("Logo.Tall"); | |
| if(res_tall && *res_tall) { | |
| tall = atoi(res_tall); | |
| } | |
| //Set sizes and pos | |
| SetPos(xpos, ypos); | |
| SetSize(wide, tall); | |
| //Text font | |
| m_hFont = scheme->GetFont(scheme->GetResourceString("Logo.Font")); | |
| //Text color | |
| m_TextColor = scheme->GetColor(scheme->GetResourceString("Logo.Color"), Color()); | |
| //Get logo content | |
| //We using gameinfo to determine what we will draw here | |
| KeyValues *gameinfo = new KeyValues("GameInfo"); | |
| gameinfo->LoadFromFile(filesystem, GAMEINFO_FILENAME, "GAME"); | |
| Q_strncpy(m_szText, gameinfo->GetString("title", "REFRACTION"), 1024); | |
| gameinfo->deleteThis(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment