Posted by: -+Arcadian+-
Date posted: Jun 17 2003 User Rating: N/A | Number of views: 2429 Number of comments: 0 | Description: Quick & Simple |
This article shows you how to quickly change the default 320 & 640 .tga image sizes to fit whatever resolution a player is using. This does not tell you how to use VGUI at all, you should use the tutorials found here for that.
The default vgui in half-life is set up to use the same images for any resolution over 640x480. So if you had your resolution set to say 1024x768 the images would look considerably smaller. What if you wanted them to be bigger & look better? Well it's simple.
First off let me explain something you should already know if working with VGUI. The code prepends a "320_" or "640_" to whatever image you use. Like for example if your .tga name is "MyImage" (in the code) the code will look for "640_MyImage.tga" in the gfx/vgui folder. With that in mind...
Go into vgui_CustomObjects.cpp
Look for:
| | | // Get the name of TGA file, without a gamedir char *GetTGANameForRes(const char *pszName) { int i; char sz[256]; static char gd[256]; if (ScreenWidth < 640) i = 320; else i = 640; sprintf(sz, pszName, i); sprintf(gd, "gfx/vgui/%s.tga", sz); return gd; }
|
As you can see .. the if (ScreenWidth < 640) tells the game if the screen width is less than 640 to prepend 320 to the .tga file. All we need to do is remove a few lines and and change one of them so the code will look for other images at higher resolutions.
Change that code to:
| | | // Get the name of TGA file, without a gamedir char *GetTGANameForRes(const char *pszName) { static char gd[256]; sprintf(sz, pszName, ScreenWidth); //Use the resolution sprintf(gd, "gfx/vgui/%d_%s.tga", ScreenWidth, sz); return gd; }
|
This tells the code to look for images depending on your resolution.. if your res is 800x600 it will use the 800_MyImage.tga, or if higher it will use the 1024_MyImage.tga.
[EDIT: Mind you, you're going to have to create TGAs for each possible resolution in order for nobody to be missing out. If you have a lot of TGA images, this could become a pain, and take a lot of memory.]
Pretty simple stuff.. and you can easily change it to go higher if you wanted. Maybe now people wont have such small HUDs when the screensize is 1024 Any questions you can find me in #wavelength on gamesnet. |
|
User Comments
No User Comments
You must register to post a comment. If you have already registered, you must login.
|
296 Approved Articless
5 Pending Articles
3940 Registered Members
4 People Online (27 guests)
|
|