<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.splashdamage.com/index.php?action=history&amp;feed=atom&amp;title=GUIs%3A_Materials</id>
	<title>GUIs: Materials - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.splashdamage.com/index.php?action=history&amp;feed=atom&amp;title=GUIs%3A_Materials"/>
	<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=GUIs:_Materials&amp;action=history"/>
	<updated>2026-04-07T18:45:40Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.splashdamage.com/index.php?title=GUIs:_Materials&amp;diff=1484&amp;oldid=prev</id>
		<title>192.168.0.142 at 10:33, 16 October 2007</title>
		<link rel="alternate" type="text/html" href="https://wiki.splashdamage.com/index.php?title=GUIs:_Materials&amp;diff=1484&amp;oldid=prev"/>
		<updated>2007-10-16T10:33:10Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;noinclude&amp;gt;== Overview ==&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
Material system and caching of materials.&amp;lt;includeonly&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{main|GUIs: Materials}}&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remember having to create 9 windows to draw a window with a border? Now with the ''_frame'' keyword you only need one window to draw a window with a border. There are many similar additions to help reduce the number of windows required for certain common types of window drawing. See the [[GUIs: Materials|Materials]] page for more information.&lt;br /&gt;
&lt;br /&gt;
The GUI will cache any materials defined in the materials block. Caching the materials avoids stuttering during gameplay and is needed when making binary decls.&lt;br /&gt;
&lt;br /&gt;
 materials {&lt;br /&gt;
 	[alias] [material name]&lt;br /&gt;
 }&lt;br /&gt;
Alias is the name you would use in the guis:&lt;br /&gt;
 windowDef desktop {&lt;br /&gt;
 	properties {&lt;br /&gt;
 		color	backColor	=	1, 1, 1, 0.8;&lt;br /&gt;
 		string material = [alias];&lt;br /&gt;
 	}		&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The material name may be prefixed with a code that tells the gamecode what type of material it is:&lt;br /&gt;
* &amp;quot;literal: [material name]&amp;quot; - same as [material name], no theme lookup.&lt;br /&gt;
* &amp;quot;_frame [material name]&amp;quot; - 9 part material.&lt;br /&gt;
* &amp;quot;_st [material name]&amp;quot; - Specified a rectangle on the material.&lt;br /&gt;
* &amp;quot;_3v [material name]&amp;quot; - 3 vertical parts.&lt;br /&gt;
* &amp;quot;_3h [material name]&amp;quot; - 3 horizontal parts.&lt;br /&gt;
* &amp;quot;_5h [material name]&amp;quot; - 5 horizontal parts.&lt;br /&gt;
* &amp;quot;::[material name]&amp;quot; - Lookup material directly instead of looking up for a theme.&lt;br /&gt;
&lt;br /&gt;
== Additional Parameters ==&lt;br /&gt;
If no ''::'' prefix is used then some additional comma separated values may be added after the material name:&lt;br /&gt;
* flipX - Flip texture horizontally.&lt;br /&gt;
* flipY - Flip texture vertically.&lt;br /&gt;
* rect - Specify a certain region, must be used with _st.&lt;br /&gt;
&lt;br /&gt;
'''Examples'''&lt;br /&gt;
 materials {&lt;br /&gt;
 	&amp;quot;icon_context&amp;quot; &amp;quot;guis/assets/mainmenu/sheet_fill, rect( 324, 165, 24, 24 )&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 ...&lt;br /&gt;
 // Use _st, lookup material from list of materials above.&lt;br /&gt;
 handle	iconContext = gui.cacheMaterial( &amp;quot;iconContext&amp;quot;,	&amp;quot;_st icon_context&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
== Specifying A Rectangle ==&lt;br /&gt;
Icons are almost always grouped together onto larger texture sheets to improve performance and keep things organized. It's possible to create a new material where it draws a specific area of a texture by using the rect keyword when caching materials in GUIs. Here's an example where the players rank icons are being cached, all icons use a specific rectangle on the same material (''guis/assets/icons/gdf_ranks01''):&lt;br /&gt;
 // Ranks&lt;br /&gt;
 materials {&lt;br /&gt;
 	&amp;quot;guis/assets/icons/rank01&amp;quot;	&amp;quot;guis/assets/icons/gdf_ranks01, rect( 0, 	0, 64, 64 )&amp;quot;&lt;br /&gt;
 	&amp;quot;guis/assets/icons/rank02&amp;quot;	&amp;quot;guis/assets/icons/gdf_ranks01, rect( 64, 	0, 64, 64 )&amp;quot;&lt;br /&gt;
 	&amp;quot;guis/assets/icons/rank03&amp;quot;	&amp;quot;guis/assets/icons/gdf_ranks01, rect( 128, 	0, 64, 64 )&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Frame ==&lt;br /&gt;
Frames are used for drawing dialogs, buttons, tab buttons, weapon selection buttons in the limbo menu, etc. A frame consists of 9 parts:&lt;br /&gt;
* top left&lt;br /&gt;
* top&lt;br /&gt;
* top right&lt;br /&gt;
* right&lt;br /&gt;
* bottom right&lt;br /&gt;
* bottom&lt;br /&gt;
* bottom left&lt;br /&gt;
* left&lt;br /&gt;
* center&lt;br /&gt;
&lt;br /&gt;
'''Example from ''guis/game/hud/materials.include'''''&lt;br /&gt;
&lt;br /&gt;
To draw a frame you would first cache the materials in the GUI, the suffixes _l/_r/_t/_b/_tl/_tr/_bl/_br/_c must be specified or else it won't find all the 9 parts needed for the frame:&lt;br /&gt;
 // dialog fill&lt;br /&gt;
 materials {&lt;br /&gt;
 	&amp;quot;dialog_l&amp;quot;  &amp;quot;guis/assets/mainmenu/sheet_fill, rect( 255, 187, 6, 1 )&amp;quot;&lt;br /&gt;
 	&amp;quot;dialog_r&amp;quot;  &amp;quot;guis/assets/mainmenu/sheet_fill, rect( 255, 187, 6, 1 ) flipX&amp;quot;&lt;br /&gt;
 	&amp;quot;dialog_t&amp;quot;  &amp;quot;guis/assets/mainmenu/sheet_fill, rect( 259, 182, 1, 6 )&amp;quot;&lt;br /&gt;
 	&amp;quot;dialog_b&amp;quot;  &amp;quot;guis/assets/mainmenu/sheet_fill, rect( 259, 182, 1, 6 ) flipY&amp;quot;&lt;br /&gt;
 	&amp;quot;dialog_tl&amp;quot; &amp;quot;guis/assets/mainmenu/sheet_fill, rect( 255, 182, 6, 6 )&amp;quot;&lt;br /&gt;
 	&amp;quot;dialog_tr&amp;quot; &amp;quot;guis/assets/mainmenu/sheet_fill, rect( 255, 182, 6, 6 ) flipX&amp;quot;&lt;br /&gt;
 	&amp;quot;dialog_bl&amp;quot; &amp;quot;guis/assets/mainmenu/sheet_fill, rect( 255, 182, 6, 6 ) flipY&amp;quot;&lt;br /&gt;
 	&amp;quot;dialog_br&amp;quot; &amp;quot;guis/assets/mainmenu/sheet_fill, rect( 255, 182, 6, 6 ) flipX flipY&amp;quot;&lt;br /&gt;
 	&amp;quot;dialog_c&amp;quot;  &amp;quot;guis/assets/white&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Now create a material handle for &amp;quot;dialog&amp;quot;:&lt;br /&gt;
 properties {&lt;br /&gt;
 	handle dlgFillMaterial = cacheMaterial( &amp;quot;_dlgFill&amp;quot;, &amp;quot;_frame dialog&amp;quot; );		&lt;br /&gt;
 }&lt;br /&gt;
The handle may now be used together with [[UIWindow:drawCachedMaterial|drawCachedMaterial]] to draw all 9 parts in one go!&lt;br /&gt;
&lt;br /&gt;
== 3 Parts ==&lt;br /&gt;
Similarly to frames there is vertical or horizontal 3 part materials where there is a top part drawn with a fixed size, a bottom part drawn with a fixed size and a middle part which is stretched depending on the draw rectangle it is being drawn for.&lt;br /&gt;
&lt;br /&gt;
'''Example from ''guis/game/hud/materials.include'''''&lt;br /&gt;
&lt;br /&gt;
Scroll bars use a vertical 3 part material. First the materials are cached:&lt;br /&gt;
 materials {&lt;br /&gt;
 	&amp;quot;scroll_t&amp;quot; &amp;quot;guis/assets/mainmenu/sheet_add, rect( 149, 213, 11, 11 )&amp;quot;&lt;br /&gt;
 	&amp;quot;scroll_c&amp;quot; &amp;quot;guis/assets/mainmenu/sheet_add, rect( 149, 224, 11, 11 )&amp;quot;&lt;br /&gt;
 	&amp;quot;scroll_b&amp;quot; &amp;quot;guis/assets/mainmenu/sheet_add, rect( 149, 213, 11, 11 ) flipY&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Now specify a material name for a window:&lt;br /&gt;
 string material = &amp;quot;_3v scroll&amp;quot;;&lt;br /&gt;
The gamecode automatically draws the material when the window is drawing so it is not necessary to call [[UIWindow:drawCachedMaterial|drawCachedMaterial]] to draw it.&lt;br /&gt;
&lt;br /&gt;
== 5 Parts ==&lt;br /&gt;
The 5 part material is mainly used for top and bottom items in the radial context. There is left edge with a constant width, left part that stretches between the edge part and the center part, a center part that has a constant width, a right part that stretches between the center part and the right edge part.&lt;br /&gt;
&lt;br /&gt;
'''Example from ''guis/game/quickchat.include'''''&lt;br /&gt;
&lt;br /&gt;
First the materials are cached:&lt;br /&gt;
 materials {&lt;br /&gt;
 	// bottom center radial&lt;br /&gt;
 	&amp;quot;bottom_center_r_fill_tl&amp;quot;	&amp;quot;guis/quickchat/qchat_fill, rect( 171, 84, 22, 42 )&amp;quot;&lt;br /&gt;
 	&amp;quot;bottom_center_r_fill_l&amp;quot;	&amp;quot;guis/quickchat/qchat_fill, rect( 192, 84, 1, 42 )&amp;quot;&lt;br /&gt;
 	&amp;quot;bottom_center_r_fill_c&amp;quot;	&amp;quot;guis/quickchat/qchat_fill, rect( 192, 84, 41, 42 )&amp;quot;&lt;br /&gt;
 	&amp;quot;bottom_center_r_fill_r&amp;quot;	&amp;quot;guis/quickchat/qchat_fill, rect( 192, 84, 1, 42 )&amp;quot;&lt;br /&gt;
 	&amp;quot;bottom_center_r_fill_tr&amp;quot;	&amp;quot;guis/quickchat/qchat_fill, rect( 171, 84, 22, 42 ), flipX&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
A material handle is then saved that can later be used for drawing the 5 part material:&lt;br /&gt;
 fill = gui.cacheMaterial( &amp;quot;fill&amp;quot;, &amp;quot;_5h bottom_center_r_fill&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>192.168.0.142</name></author>
		
	</entry>
</feed>