| Hello here is my code it starts with UpdateInterface() and the end is UpdateActionBarIcons() 
 
 
 
 Function CreateInterface()
;helptex = LoadTexture("Data\Textures\GUI\BG.png", 1 + 2)
	; Quit bar
;	QuitLabel = GY_CreateLabel(0, 0.5, 0.4, LanguageString$(LS_QuitProgress), 255, 255, 255, Justify_Centre)
;	QuitBar = GY_CreateProgressBar(0, 0.35, 0.43, 0.3, 0.02, 0, 100, 255, 255, 0)
	; Chat bubble
	ChatBubbleFont = GY_LoadFont("Data\UI\Fonts\Bubble", True)
	ChatBubbleEN = CreateMesh()
	Surf = CreateSurface(ChatBubbleEN)
	v1  = AddVertex(Surf, -0.1, -1.1,  0.0, 1.0, 0.0)
	v2  = AddVertex(Surf,  0.0, -1.1,  0.0, 0.9, 0.0)
	v3  = AddVertex(Surf,  1.0, -1.1,  0.0, 0.1, 0.0)
	v4  = AddVertex(Surf,  1.1, -1.1,  0.0, 0.0, 0.0)
	v5  = AddVertex(Surf, -0.1, -1.0,  0.0, 1.0, 0.1)
	v6  = AddVertex(Surf,  0.0, -1.0,  0.0, 0.9, 0.1)
	v7  = AddVertex(Surf,  1.0, -1.0,  0.0, 0.1, 0.1)
	v8  = AddVertex(Surf,  1.1, -1.0,  0.0, 0.0, 0.1)
	v9  = AddVertex(Surf, -0.1,  0.0,  0.0, 1.0, 0.66)
	v10 = AddVertex(Surf,  0.0,  0.0,  0.0, 0.9, 0.66)
	v11 = AddVertex(Surf,  1.0,  0.0,  0.0, 0.1, 0.66)
	v12 = AddVertex(Surf,  1.1,  0.0,  0.0, 0.0, 0.66)
	v13 = AddVertex(Surf, -0.1,  0.25, 0.0, 1.0, 1.0)
	v14 = AddVertex(Surf,  0.0,  0.25, 0.0, 0.9, 1.0)
	v15 = AddVertex(Surf,  1.0,  0.25, 0.0, 0.1, 1.0)
	v16 = AddVertex(Surf,  1.1,  0.25, 0.0, 0.0, 1.0)
	AddTriangle(Surf, v1,  v2,  v5)
	AddTriangle(Surf, v2,  v6,  v5)
	AddTriangle(Surf, v2,  v3,  v6)
	AddTriangle(Surf, v3,  v7,  v6)
	AddTriangle(Surf, v3,  v4,  v7)
	AddTriangle(Surf, v4,  v8,  v7)
	AddTriangle(Surf, v5,  v6,  v9)
	AddTriangle(Surf, v6,  v10, v9)
	AddTriangle(Surf, v6,  v7,  v10)
	AddTriangle(Surf, v7,  v11, v10)
	AddTriangle(Surf, v7,  v8,  v11)
	AddTriangle(Surf, v8,  v12, v11)
	AddTriangle(Surf, v9,  v10, v13)
	AddTriangle(Surf, v10, v14, v13)
	AddTriangle(Surf, v10, v11, v14)
	AddTriangle(Surf, v11, v15, v14)
	AddTriangle(Surf, v11, v12, v15)
	AddTriangle(Surf, v12, v16, v15)
	HideEntity(ChatBubbleEN)
	ChatBubbleTex = LoadTexture("Data\Textures\Bubble.png", 1 + 4)
	If ChatBubbleTex = 0 Then RuntimeError("File not found: Data\Textures\Bubble.png!")
	; Chat bar
	If ChatBar <> Null
		ChatBar\Component = CreateInterfaceQuad(GY_Cam)
		EntityTexture(ChatBar\Component, GetTexture(ChatBar\Texture))
		UnloadTexture(ChatBar\Texture)
		ScaleMesh(ChatBar\Component, ChatBar\Width# * 20.0, ChatBar\Height# * 15.0, 1.0)
		PositionEntity(ChatBar\Component, (ChatBar\X# * 20.0) - 10.0, (ChatBar\Y# * -15.0) + 7.5, 10.0)
		EntityAlpha(ChatBar\Component, ChatBar\Alpha#)
	EndIf
	; Attribute displays
	For i = 0 To 39
		If AttributeDisplays(i)\Width# > 0.0 And AttributeDisplays(i)\Height# > 0.0
			; Create bar
			
				; Game options
	F = ReadFile("Data\Options.dat")
	If F = 0 Then RuntimeError("Could not open Data\Options.dat!")
		Width = ReadShort(F)
		Height = ReadShort(F)
	CloseFile(F)
			
			
			
	;		R = AttributeDisplays(i)\R : G = AttributeDisplays(i)\G : B = AttributeDisplays(i)\B
	;		X# = Width - Width ;(winX# * 20) - 10.0 ; - winX# ; - winX# ;+ 0.05 ;AttributeDisplays(i)\X#
	;		Y# = AttributeDisplays(i)\Y#
	;		W# = AttributeDisplays(i)\Width#
	;		H# = AttributeDisplays(i)\Height#
	;		AttributeDisplays(i)\Component = GY_CreateProgressBar(0, X#, Y#, W#, H#, 50, 100, R, G, B)
			
			
			R = AttributeDisplays(i)\R : G = AttributeDisplays(i)\G : B = AttributeDisplays(i)\B
			X# = AttributeDisplays(i)\X#
			Y# = AttributeDisplays(i)\Y#
			W# = AttributeDisplays(i)\Width#
			H# = AttributeDisplays(i)\Height#
			AttributeDisplays(i)\Component = GY_CreateProgressBar(0, X#, Y#, W#, H#, 50, 100, R, G, B)			
			
			
			
			GY_GadgetAlpha(AttributeDisplays(i)\Component, 0.85, True)
			GY_DropGadget(AttributeDisplays(i)\Component)
			; Create number display
			X# = X# + (W# / 2.0)
			Y# = (Y# + (H# / 2.0)) - 0.015
		EndIf
	Next
	; Large map
	
;;	WLargeMap = GY_CreateWindow(LanguageString$(LS_Map), 0.15, 0.1, 0.6, 0.8, True, True, False, 0, False)
;############################# Money bag ####################################
Portrait = LoadTexture("Data\Textures\Menu\A_OptionsMenu.png", 1 + 2)
;WLargeMap = GY_CreateWindow(LanguageString$(LS_Map), 0.0, 0.0, 1.0, 1.0, False, False, False, Portrait)
;WLargeMap = GY_CreateWindow(0, 0.78, 0.1, 0.2, 0.4, False, False, False, Portrait)
WLargeMap = GY_CreateWindow(0, 0.01, 0.01, 1.0, 1.0, False, False, False, Portrait)
	;GY_CreateLabel_Menu(WLargeMap, 0.5, 0.125, Me\Name$, 210, 210, 210, Justify_Centre)
	
	
;	BShowGrass = GY_CreateCustomButton(WLargeMap, 0.1, 0.13, 0.8, 0.13, LoadButtonU("A_Grass"), LoadButtonD("A_Grass"), LoadButtonH("A_Grass"))	
;	BShowFlowers = GY_CreateCustomButton(WLargeMap, 0.1, 0.28, 0.8, 0.13, LoadButtonU("A_Flowers"), LoadButtonD("A_Flowers"), LoadButtonH("A_Flowers"))
;	BShowShadows= GY_CreateCustomButton(WLargeMap, 0.1, 0.43, 0.8, 0.13, LoadButtonU("A_Shadows"), LoadButtonD("A_Shadows"), LoadButtonH("A_Shadows"))	
;	BDistance= GY_CreateCustomButton(WLargeMap, 0.1, 0.58, 0.8, 0.13, LoadButtonU("A_Distance"), LoadButtonD("A_Distance"), LoadButtonH("A_Distance"))
	
	
;	BScreenRez= GY_CreateCustomButton(WLargeMap, 0.1, 0.73, 0.8, 0.13, LoadButtonU("A_Quithf"), LoadButtonD("A_Quithf"), LoadButtonH("A_Quithf"))
	
		BShowGrass = GY_CreateCustomButton(WLargeMap, 0.1, 0.14, 0.2, 0.04, LoadButtonU("A_Grass"), LoadButtonD("A_Grass"), LoadButtonH("A_Grass"))	
	BShowFlowers = GY_CreateCustomButton(WLargeMap, 0.1, 0.2, 0.2, 0.04, LoadButtonU("A_Flowers"), LoadButtonD("A_Flowers"), LoadButtonH("A_Flowers"))
	BShowShadows= GY_CreateCustomButton(WLargeMap, 0.1, 0.26, 0.2, 0.04, LoadButtonU("A_Shadows"), LoadButtonD("A_Shadows"), LoadButtonH("A_Shadows"))	
	BDistance= GY_CreateCustomButton(WLargeMap, 0.1, 0.32, 0.2, 0.04, LoadButtonU("A_Distance"), LoadButtonD("A_Distance"), LoadButtonH("A_Distance"))
	
	
	BScreenRez= GY_CreateCustomButton(WLargeMap, 0.1, 0.38, 0.2, 0.04, LoadButtonU("A_Quithf"), LoadButtonD("A_Quithf"), LoadButtonH("A_Quithf"))
		
	
;############################################################################
	; Chat entry
	ChatEntry\Component = GY_CreateChatTextField(0, ChatEntry\X#, ChatEntry\Y#, ChatEntry\Width#, 0, 100)
	ChatEntry\Alpha# = 0.0
	GY_GadgetAlpha(ChatEntry\Component, 0.0)
	; Compass
	Compass\Component = GY_CreateQuad(GY_Cam)
	Tex = LoadTexture("Data\Textures\Compass Overlay.PNG", 1 + 4)
	If Tex = 0 Then RuntimeError("File not found: Data\Textures\Compass Overlay.PNG!")
	EntityTexture(Compass\Component, Tex)
	FreeTexture(Tex)
	ScaleMesh(Compass\Component, Compass\Width# * 20.0, Compass\Height# * 15.0, 1.0)
	PositionEntity(Compass\Component, (Compass\X# * 20.0) - 10.0, (Compass\Y# * -15.0) + 7.5, 10.0)
	EntityOrder(Compass\Component, -1)
	EntityAlpha(Compass\Component, Compass\Alpha#)
	CompassBackground = GY_CreateQuad(GY_Cam)
	Tex = LoadTexture("Data\Textures\GUI\A_Blank.png", 1 + 2); took out +4
	If Tex = 0 Then RuntimeError("File not found: Data\Textures\Compass.PNG!")
	EntityTexture(CompassBackground, Tex)
	FreeTexture(Tex)
	ScaleMesh(CompassBackground, Compass\Width# * 20.0, Compass\Height# * 15.0, 1.0)
	PositionEntity(CompassBackground, (Compass\X# * 20.0) - 10.0, (Compass\Y# * -15.0) + 7.5, 10.0)
	EntityOrder(CompassBackground, -2)
	EntityAlpha(CompassBackground, Compass\Alpha#)
	EntityParent(CompassBackground, Compass\Component)
	; Actor effect icons
	IconsAcross = Floor#(BuffsArea\Width# / 0.0225)
	IconsDown = Floor#(BuffsArea\Height# / 0.03)
	X# = BuffsArea\X#
	Y# = BuffsArea\Y#
	For i = 1 To IconsDown
		For j = 1 To IconsAcross
			EIS.EffectIconSlot = New EffectIconSlot
			EIS\EN = GY_CreateQuad(GY_Cam)
			EntityOrder(EIS\EN, -1)
			PositionEntity(EIS\EN, (X# * 20.0) - 10.0, (Y# * -15.0) + 7.5, 10.0)
			ScaleMesh(EIS\EN, 0.0225 * 20.0, 0.03 * 15.0, 1.0)
			HideEntity(EIS\EN)
			X# = X# + 0.0225
		Next
		X# = BuffsArea\X#
		Y# = Y# + 0.03
	Next
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	; Action bar
	ActionBarUpTex = LoadTexture("Data\Textures\GUI\A_Up.png");#############################
	If ActionBarUpTex = 0 Then RuntimeError("File not found: Data\Textures\GUI\ArrowUp.bmp!");###############################
	ActionBarDownTex = LoadTexture("Data\Textures\GUI\A_Down.png");#######################################
	If ActionBarDownTex = 0 Then RuntimeError("File not found: Data\Textures\GUI\ArrowDown.bmp!");##########################
	ActionEN = GY_CreateQuad(GY_Cam)
	EntityOrder ActionEN, -1
	
	
	; Use fullscreen bar
	ClearTextureFilters
	TextureFilter("a_", 1 + 2)
	TextureFilter("m_", 1 + 4)
	
	;      Width = GfxModeWidth() 
  ;    Height = GfxModeHeight()
	Tex = LoadTexture("Data\Textures\GUI\a_Action Bar_full.png", 1 + 2)
	If tex = 0 Then Tex = LoadTexture("Data\Textures\GUI\Action Bar_full.bmp", 1 + 4 + 16 + 32)
	If tex <> 0
		PositionEntity ActionEN, -10.0, 7.55, 10.0
		
	;	PositionEntity ActionEN, 0.0, 0.0, 10.0
		
		ScaleMesh ActionEN, 20.0, 15.0, 1
		
	;	ScaleMesh ActionEN, winX#/50,winY#/50, 1
		
	;	GY_CreateLabelChar(ActionEN, 0.17, 0.058, Me\Name$, 176, 163, 111, Justify_Centre)
;		GY_CreateLabel_Menu(ActionEN, 0.25, 0.035, Me\Level, 210, 210, 210, Justify_Centre)
;GY_UpdateLabel(LLevel, "  " + Me\Level)
	;	If Me\HomeFaction=4 ;wild animals
;GY_CreateWindow(ActionEN, 2.01, 2.01, 2.01, 2.06, False, False, False, LoadTexture("Data\Textures\GUI\a_Action BarOverlay_full.png", 1 + 2))
	
GY_CreateWindow(ActionEN, 0.06, 0.0505, 0.15, 0.031, False, False, False, LoadTexture("Data\Textures\GUI\a_Action BarOverlay.png"))
	;Else	
	;	GY_CreateWindow(ActionEN, 0.05, 0.05, 0.05, 0.05, False, False, False, LoadTexture("Data\Textures\GUI\A_InventoryBG.png"))
	
;GY_CreateWindow(ActionEN, 0.01, 0.01, 8.01, 8.06, False, False, False, LoadTexture("Data\Textures\GUI\a_Action BarOverlay_full.png", 1 + 2))
	
;EndIf
	
		
		
	EndIf
	
	; Use the regular bar if the fullscreen bar is not available
	If tex = 0 
		Tex = LoadTexture("Data\Textures\GUI\Action Bar.dds", 1 + 2 + 16 + 32)
		If tex = 0 Then Tex = LoadTexture("Data\Textures\GUI\Action Bar.bmp", 1 + 4 + 16 + 32)
		
		PositionEntity ActionEN, -10.0, -5.0, 10.0
		ScaleMesh ActionEN, 20.0, 2.5, 1.0
	EndIf
	
;	
;	If LoadScreen = True
;		EntityTexture(ActionEN, LoadTexture("Data\Textures\GUI\A_Blank.png"))
;	FreeTexture Tex
;
;	Else
	
		EntityTexture(ActionEN, Tex)
	FreeTexture Tex
;	EndIf
	
	
	EntityTexture(ActionEN, Tex)
	FreeTexture Tex
;	XPEN = GY_CreateQuad(GY_Cam)
;	EntityOrder XPEN, -2
;	PositionEntity XPEN, -6.416015625, -5.0, 10.0 : ScaleMesh XPEN, 0.0, 0.0, 0.0
;	Tex = LoadTexture("Data\Textures\GUI\Help.bmp", 1 + 2)
;	EntityTexture(XPEN, Tex)
;	FreeTexture Tex
;	BMap = CreateActionBarButton("A_Blank2.png", 0.89) ; Option Menu for rendering
	BMap = GY_CreateCustomButton(0, 0.013, 0.03, 0.05, 0.065, LoadButtonU("A_Pack"), LoadButtonD("A_Pack"), LoadButtonH("A_Pack"), True)
	
;	BChat = CreateActionBarButton2("A_Blank2.png", 0.84)
		
;helptex = LoadTexture("Data\Textures\GUI\A_Up.png", 1 + 2)
	
;helptex = LoadTexture("Data\Textures\GUI\Tab.png", 1 + 2)
								;Select Rand(1,4)
								;	Case 1
;CryTex = LoadTexture("Data\Textures\GUI\A_Blank2.png", 1);Weapon
								;	Case 2
;CryTex = LoadTexture("Data\Textures\GUI\A_Crystal.png", 1);Weapon
								;	Case 3
;CryTex = LoadTexture("Data\Textures\GUI\A_Blank.png", 1);Weapon
								;	Case 4
;CryTex = LoadTexture("Data\Textures\GUI\A_Crystal.png", 1);Weapon
							;	End Select
	
;	CreateInventoryButton2(0, SlotI_Weapon, Tex)
;	BCrystal = CreateInventoryButton2(0, SlotI_Amulet2, CryTex)
	
	
;###################
	BCharStats = GY_CreateCustomButton(0, 0.000, 0.27,  0.02, 0.06, LoadButtonU("A_Tab"), LoadButtonD("A_Tab"), LoadButtonH("A_Tab"), True)
	BHelp =      GY_CreateCustomButton(0, 0.000, 0.345, 0.02, 0.06, LoadButtonU("A_Tab"), LoadButtonD("A_Tab"), LoadButtonH("A_Tab"), True)
	BSpells =    GY_CreateCustomButton(0, 0.000, 0.42,  0.02, 0.06, LoadButtonU("A_Tab"), LoadButtonD("A_Tab"), LoadButtonH("A_Tab"), True)
	BInventory = GY_CreateCustomButton(0, 0.000, 0.57,  0.02, 0.06, LoadButtonU("A_Tab"), LoadButtonD("A_Tab"), LoadButtonH("A_Tab"), True)
	BQuestlog =	 GY_CreateCustomButton(0, 0.000, 0.495, 0.02, 0.06, LoadButtonU("A_Tab"), LoadButtonD("A_Tab"), LoadButtonH("A_Tab"), True)
	GY_GadgetAlpha(BCharStats , 0.5)
	GY_GadgetAlpha(BHelp , 0.5)
	GY_GadgetAlpha(BSpells , 0.5)
	GY_GadgetAlpha(BInventory , 0.5)
	GY_GadgetAlpha(BQuestlog , 0.5)
;###################
	BParty = CreateActionBarButton1("A_Blank.png", 0.94)
	GY_DropGadget(BPrevBar)
	GY_DropGadget(BNextBar)
	For i = 0 To 0
	
	
	;															Starting #			Spread #
		;BActionBar(i) = CreateActionBarButton("A_EmptySlot.png", 0.59 + (Float#(i) * 0.051), False, False)
 BActionBar(i) = CreateActionBarButtonUP("A_EmptySlot.png", 0.855, False, False)
	Next
	For i = 1 To 1
	
	
	;															Starting #			Spread #
		;BActionBar(i) = CreateActionBarButton("A_EmptySlot.png", 0.59 + (Float#(i) * 0.051), False, False)
 BActionBar(i) = CreateActionBarButtonDown("A_EmptySlot.png", 0.855, False, False)
	Next
	For i = 2 To 2
	
	
	;															Starting #			Spread #
		;BActionBar(i) = CreateActionBarButton("A_EmptySlot.png", 0.59 + (Float#(i) * 0.051), False, False)
 BActionBar(i) = CreateActionBarButtonLeft("A_EmptySlot.png", 0.81, False, False)
	Next
	For i = 3 To 3
	
	
	;															Starting #			Spread #
		;BActionBar(i) = CreateActionBarButton("A_EmptySlot.png", 0.59 + (Float#(i) * 0.051), False, False)
 BActionBar(i) = CreateActionBarButtonRight("A_EmptySlot.png", 0.90, False, False)
	Next
	
	
;	For i = 4 To 4
	
	
	;crystal															Starting #			Spread #
		;BActionBar(i) = CreateActionBarButton("A_EmptySlot.png", 0.59 + (Float#(i) * 0.051), False, False)
; BActionBar(i) = CreateActionBarButtonCenter("A_Blank2.png", 0.855, False, False)
;	Next	
	
	
	
	
	
	
	
	
	
		For i = 4 To 11 ;11
	
	
	;															Starting #			Spread #
		;BActionBar(i) = CreateActionBarButton("A_EmptySlot.png", 0.59 + (Float#(i) * 0.051), False, False)
 BActionBar(i) = CreateActionBarButtonHide("A_Blank.png", 0.0, False, False)
	Next
	
	
	
	; Chat text display
	MaxChatLine = Int(Floor#(Chat\Height# / 0.025)) - 1
	Dim ChatLines(MaxChatLine)
	Y# = Chat\Y#
	;X# = winX# ;Chat\X#
	X# = Chat\X#
	If Chat\X# <= 0.5 Then X# = X# + 0.035
	For i = 0 To MaxChatLine
		ChatLines(i) = GY_CreateLabelchat(0, X#, Y#, String$(" ", 200))
		GY_UpdateLabel(ChatLines(i), "")
		GY_DropGadget(ChatLines(i))
	;	Y# = Y# + 0.025
		Y# = Y# + 0.013
	Next
	X# = Chat\X# + 0.005
	If Chat\X# > 0.5 Then X# = Chat\X# + Chat\Width# - 0.025
	BHistoryMode = GY_CreateButton(0, X#, Chat\Y# + 0.005, 0.02, 0.015, "", False, 0, 0, 0, ActionBarDownTex)
	GY_GadgetAlpha(BHistoryMode, 0.85)
	BHistoryUp = GY_CreateButton(0, X#, Chat\Y# + 0.005, 0.02, 0.015, "", False, 0, 0, 0, ActionBarUpTex)
	BHistoryDown = GY_CreateButton(0, X#, Chat\Y# + 0.025, 0.02, 0.015, "", False, 0, 0, 0, ActionBarDownTex)
	GY_GadgetAlpha(BHistoryUp, 0.0)
	GY_GadgetAlpha(BHistoryDown, 0.0)
	; Amount dialog
	Tex = LoadTexture("Data\Textures\GUI\A_Amount.png", 1 + 2)
	WAmount = GY_CreateWindow(LanguageString$(LS_ChooseAmount), 0.35, 0.4, 0.3, 0.14, False, False, False, tex)
	BAmountOK = GY_CreateButton(WAmount, 0.7, 0.38, 0.2, 0.2, "")
	TAmount = GY_CreateTextField(WAmount, 0.4, 0.35, 0.31, 2, 5)
	; Party window (NOW BOSS WINDOW)
	WParty = GY_CreateWindow(LanguageString$(LS_Party), 0.3, 0.015, 0.4, 0.13, False, False, False, LoadTexture("Data\Textures\GUI\A_PartyBG.png"))
	WBossLabel = GY_CreateLabel_Menu(WParty, 0.5, 0.1, "              ", 255, 255, 255, Justify_Centre)
	BossBloodP = GY_CreateProgressBar(WParty, 0.19, 0.43, 0.625, 0.14, 100, 100, 142, 0, 0)
	Tex = LoadTexture("Data\Textures\GUI\Backpack.bmp", 4)
;	Y# = 0.05
;	For i = 0 To 6
;		LPartyName(i) = GY_CreateLabel(WParty, 0.05, Y#, "LONGEST PLAYER NAME GOES HERE!")
;		Y# = Y# + 0.07
;	Next
;	For i = 0 To 6
;		GY_UpdateLabel(LPartyName(i), "", 255, 255, 0)
;	Next
	; Spells (abilities) window
	If RequireMemorise = 0 Then FirstSpell = 0
	WSpells = GY_CreateWindow(LanguageString$(LS_Abilities), 0.008, 0.001, 0.31, 0.73, False, False, False, LoadTexture("Data\Textures\GUI\A_AbilitiesBG.png"))
	
	BPrevSpells = GY_CreateButtonChar(WSpells, 0.26, 0.85, 0.1, 0.05, "Previous", True, 220, 220, 220)
	BNextSpells = GY_CreateButtonChar(WSpells, 0.68, 0.85, 0.1, 0.05, "Next", True, 220, 220, 220)
	
	GY_CreateLabel_Menu(WSpells, 0.12, 0.185, Me\Name$, 255, 255, 255, Justify_Left)
	GY_CreateLabelChar(WSpells, 0.66, 0.195, Me\Actor\Race$, 250, 240, 220, Justify_Left)
	LLevel = GY_CreateLabel_Menu(WSpells, 0.88, 0.15, "     ", 210, 210, 210, Justify_Centre)
	GY_UpdateLabel(LLevel, "  " + Me\Level)
	FR = GY_CreateLabelChar(WSpells, 0.66, 0.215, FactionNames$(Me\HomeFaction), 250, 240, 220, Justify_Left)
	GY_UpdateLabel(FR, FactionNames$(Me\HomeFaction))
	X# = 0.183
	Y# = 0.43
	ButtonTex = CreateTexture(2, 2)
	For i = 0 To 9
		; Create gadgets
		If i = 5 Then X# = 0.51 : Y# = 0.05 ; Move sideways to second 'page'
		BSpellImgs(i) = GY_CreateButton(WSpells, X#, Y#, 0.14, 0.07, "", False, 0, 0, 0, ButtonTex)
		LSpellNames(i) = GY_CreateLabelchar(WSpells, X# + 0.15, Y# + 0.0185, "LONGEST SPELL NAME GOES HERE!", 210, 210, 210)
	;	LSpellLevels(i) = GY_CreateLabel_blank(WSpells, X#, Y# + 0.02, LanguageString$(LS_Level) + " 00000", 10,10,10)
		Y# = Y# + 0.06
	Next
	UpdateSpellbook()
	; Spell unmemorisation confirmation box
	WSpellRemove = GY_CreateWindow(LanguageString$(LS_Unmemorise), 0.35, 0.4, 0.4, 0.1, True, True, False)
	GY_CreateLabel(WSpellRemove, 0.5, 0.05, LanguageString$(LS_UnmemoriseDetail), 255, 255, 255, Justify_Centre)
	BSpellRemoveOK = GY_CreateButton(WSpellRemove, 0.1, 0.7, 0.3, 0.2, LanguageString$(LS_Yes))
	BSpellRemoveCancel = GY_CreateButton(WSpellRemove, 0.6, 0.7, 0.3, 0.2, LanguageString$(LS_No))
	; Quest log window
	WQuestLog = GY_CreateWindow(LanguageString$(LS_Quests), 0.008, 0.001, 0.31, 0.73, False, False, False, LoadTexture("Data\Textures\GUI\A_QuestLogBG.png"))
	
			Snd_Window = LoadSound("Data\Sounds\Doors\LockpickPins3.ogg")
			SoundVolume(Snd_Window, 1.0) 
			PlaySound(Snd_Window)
			
	GY_CreateLabel_Menu(WQuestLog, 0.12, 0.185, Me\Name$, 255, 255, 255, Justify_Left)
	GY_CreateLabelChar(WQuestLog, 0.66, 0.195, Me\Actor\Race$, 250, 240, 220, Justify_Left)
	LLevel = GY_CreateLabel_Menu(WQuestLog, 0.88, 0.15, "     ", 210, 210, 210, Justify_Centre)
	GY_UpdateLabel(LLevel, "  " + Me\Level)
	FR = GY_CreateLabelChar(WQuestLog, 0.66, 0.215, FactionNames$(Me\HomeFaction), 250, 240, 220, Justify_Left)
	GY_UpdateLabel(FR, FactionNames$(Me\HomeFaction))
		
	
	For i = 0 To 16
		LQuestLines(i) = GY_CreateLabelStat(WQuestLog, 0.15, 0.4 + (Float#(i) * 0.023), String$(" ", 43))
	;	LQuestLines(i) = GY_CreateLabelchar(WQuestLog, 0.15, 0.275 + (Float#(i) * 0.023), String$(" ", 60))
	Next
;	BCompleteQuests = GY_CreateCheckBox(WQuestLog, 0.55, 0.09, LanguageString$(LS_ShowCompleted), True); was (LS_Show Completed)
	BCompleteQuests = GY_CreateCheckBox(WQuestLog, 0.75, 0.80, "", True); was (LS_Show Completed)
		
	
	;BPrevQuest = GY_CreateButton(WQuestLog, 0.45, 0.18, 0.1, 0.05, LanguageString$(LS_Up))
	;BNextQuest = GY_CreateButton(WQuestLog, 0.45, 0.78, 0.1, 0.05, LanguageString$(LS_Down))
	BPrevQuest = GY_CreateButtonChar(WQuestLog, 0.26, 0.85, 0.1, 0.05, "Previous", True, 220, 220, 220)
	BNextQuest = GY_CreateButtonChar(WQuestLog, 0.68, 0.85, 0.1, 0.05, "Next", True, 220, 220, 220)
	; Inventory
	MouseSlotEN = GY_CreateQuad(GY_Mouse) : EntityOrder MouseSlotEN, -3010
	
	PositionEntity MouseSlotEN, 0.4, -0.4, 0 : ScaleMesh MouseSlotEN, 2.5, 2.5, 1.0
	HideEntity MouseSlotEN
;	X# = InventoryWindow\X#
;	Y# = InventoryWindow\Y#
;	Width# = InventoryWindow\Width#
;	Height# = InventoryWindow\Height#
;	WInventory = GY_CreateWindow(LanguageString$(LS_Inventory), X#, Y#, Width#, Height#, False, False, False, LoadTexture("Data\Textures\GUI\InventoryBG.png"))
	WInventory = GY_CreateWindow(LanguageString$(LS_Inventory), 0.008, 0.001, 0.98, 0.73, False, False, False, LoadTexture("Data\Textures\GUI\A_InventoryBG.png"))
;EntityOrder WInventory, -1
			Snd_Window = LoadSound("Data\Sounds\Doors\LockpickPins3.ogg")
			SoundVolume(Snd_Window, 1.0) 
			PlaySound(Snd_Window)
			
	GY_CreateLabel_Menu(WInventory, 0.038, 0.185, Me\Name$, 255, 255, 255, Justify_Left)
	GY_CreateLabelChar(WInventory, 0.209, 0.195, Me\Actor\Race$, 250, 240, 220, Justify_Left)
	LLevel = GY_CreateLabel_Menu(WInventory, 0.279, 0.15, "     ", 210, 210, 210, Justify_Centre)
	GY_UpdateLabel(LLevel, "  " + Me\Level)
	FR = GY_CreateLabelChar(WInventory, 0.209, 0.215, FactionNames$(Me\HomeFaction), 250, 240, 220, Justify_Left)			
	GY_UpdateLabel(FR, FactionNames$(Me\HomeFaction))
		
			
			
		WEIL = GY_CreateLabelStat(WInventory, 0.26, 0.54, "00000/00000", 25, 190, 25, Justify_Right)
		GY_UpdateLabel(WEIL, Me\Attributes\Value[26])
		MWEIL = GY_CreateLabelStat(WInventory, 0.26, 0.497, "00000/00000", 190, 25, 25, Justify_Right)
		GY_UpdateLabel(MWEIL, Me\Attributes\Value[2] * 3)
	
		ATTL = GY_CreateLabelStat(WInventory, 0.26, 0.587, "00000/00000", 250, 240, 220, Justify_Right)
		GY_UpdateLabel(ATTL, Me\Attributes\Value[28])
		DEFL = GY_CreateLabelStat(WInventory, 0.26, 0.628, "00000/00000", 250, 240, 220, Justify_Right)
		GY_UpdateLabel(DEFL, Me\Attributes\Value[29])
		RESL = GY_CreateLabelStat(WInventory, 0.26, 0.673, "00000/00000", 250, 240, 220, Justify_Right)
		GY_UpdateLabel(RESL, Me\Attributes\Value[13])
		
		
		
		
		STRL = GY_CreateLabelStat(WInventory, 0.26, 0.718, "00000/00000", 250, 240, 220, Justify_Right)
		GY_UpdateLabel(STRL, Me\Attributes\Value[2])
		AGIL = GY_CreateLabelStat(WInventory, 0.26, 0.765, "00000/00000", 250, 240, 220, Justify_Right)
		GY_UpdateLabel(AGIL, Me\Attributes\Value[4])
		SWIL = GY_CreateLabelStat(WInventory, 0.26, 0.812, "00000/00000", 250, 240, 220, Justify_Right)
		GY_UpdateLabel(SWIL, Me\Attributes\Value[5])
		CHAL = GY_CreateLabelStat(WInventory, 0.26, 0.86, "00000/00000", 250, 240, 220, Justify_Right)
		GY_UpdateLabel(CHAL, Me\Attributes\Value[34])
	
	Tex = LoadTexture("Data\Textures\GUI\Backpack.bmp", 4)
	BInventoryDrop = GY_CreateButton_Blank(WInventory, InventoryDrop\X#, InventoryDrop\Y#, InventoryDrop\Width#, InventoryDrop\Height#, LanguageString$(LS_Drop), True, 0, 0, 0, tex)
	Tex = LoadTexture("Data\Textures\GUI\Backpack.bmp", 4)	
	BInventoryEat = GY_CreateButton_Blank(WInventory, InventoryEat\X#, InventoryEat\Y#, InventoryEat\Width#, InventoryEat\Height#, LanguageString$(LS_Use), True, 0, 0, 0, tex)
	
	Tex = LoadTexture("Data\Textures\GUI\A_Blank.png", 1);Weapon
	CreateInventoryButton(WInventory, SlotI_Weapon, Tex)
	Tex = LoadTexture("Data\Textures\GUI\A_Blank.png", 1);Shield
	CreateInventoryButton(WInventory, SlotI_Shield, Tex)
	Tex = LoadTexture("Data\Textures\GUI\A_Blank.png", 1);Hat
	CreateInventoryButton(WInventory, SlotI_Hat, Tex)
	Tex = LoadTexture("Data\Textures\GUI\A_Blank.png", 1);Chest
	CreateInventoryButton(WInventory, SlotI_Chest, Tex)
	Tex = LoadTexture("Data\Textures\GUI\A_Blank.png", 1);Hand
	CreateInventoryButton(WInventory, SlotI_Hand, Tex)
	
	
	Tex = LoadTexture("Data\Textures\GUI\A_Blank.png", 1)
	CreateInventoryButton(WInventory, SlotI_Belt, Tex)
	Tex = LoadTexture("Data\Textures\GUI\A_Blank.png", 1);Legs
	CreateInventoryButton(WInventory, SlotI_Legs, Tex)
	Tex = LoadTexture("Data\Textures\GUI\A_Blank.png", 1);Feet
	CreateInventoryButton(WInventory, SlotI_Feet, Tex)
	Tex = LoadTexture("Data\Textures\GUI\A_Blank.png", 1);Ring
	CreateInventoryButton(WInventory, SlotI_Ring1, Tex)
	CreateInventoryButton(WInventory, SlotI_Ring2, Tex)
	CreateInventoryButton(WInventory, SlotI_Ring3, Tex)
;	CreateInventoryButton(WInventory, SlotI_Ring4, Tex)
	
	
	Tex = LoadTexture("Data\Textures\GUI\A_Blank.png", 1);Amulet
	
	
	CreateInventoryButton(WInventory, SlotI_Amulet1, Tex)
;	CreateInventoryButton(WInventory, SlotI_Amulet2, Tex)
	
	
	Tex = LoadTexture("Data\Textures\GUI\Backpack.bmp", 4)
	If GetFlag(Me\Actor\InventorySlots, Slot_Backpack - 1) = True
		For i = SlotI_Backpack To SlotI_Backpack + 31
			CreateInventoryButton(WInventory, i, Tex)
		Next
	EndIf
	; Trading
	WTrading = GY_CreateWindow("Trading", 0.15, 0.2, 0.25, 0.45, False, False, False, LoadTexture("Data\Textures\GUI\A_Trading.png"))
;	LTradingGold = GY_CreateLabel(WTrading, 0.02, 0.81, LanguageString$(LS_Money) + " 00000000000000000000000000000000000000000000000000000000")
;	LTradingCost = GY_CreateLabel(WTrading, 0.02, 0.87, LanguageString$(LS_Cost) + " 00000000000000000000000000000000000000000000000000000000")
;	BCostUp = GY_CreateButton(WTrading, 0.02, 0.93, 0.2, 0.045, LanguageString$(LS_IncreaseCost))
;	BCostDown = GY_CreateButton(WTrading, 0.25, 0.93, 0.2, 0.045, LanguageString$(LS_DecreaseCost))
BTradingOK = GY_CreateCustomButton(WTrading,  0.55, 0.87, 0.4, 0.09, LoadButtonU("Take"), LoadButtonD("Take"), LoadButtonH("Take"))
BTradingCancel = GY_CreateCustomButton(WTrading, 0.05, 0.87, 0.4, 0.09, LoadButtonU("Cancel"), LoadButtonD("Cancel"), LoadButtonH("Cancel"))
;	BTradingOK = GY_CreateButton(WTrading, 0.88, 0.93, 0.1, 0.045, LanguageString$(LS_Accept))
;	BTradingCancel = GY_CreateButton(WTrading, 0.75, 0.93, 0.1, 0.045, LanguageString$(LS_Cancel))
	X# = 0.08 : Y# = 0.05
	For i = 0 To 31
	BSlotsMine(i) = GY_CreateButton(WTrading, 0, 0, 0.001, 0.001, "", True, 0, 0, 0, Tex)
BSlotsHis(i) = GY_CreateButton(WTrading, X#, Y#, 0.2, 0.15, "", True, 0, 0, 0, Tex)
	;	BSlotsMine(i) = GY_CreateButton(WTrading, X#, Y#, 0.05625, 0.1, "", True, 0, 0, 0, Tex)
		;BSlotsHis(i) = GY_CreateButton(WTrading, X# + 0.5, Y#, 0.05625, 0.1, "", True, 0, 0, 0, Tex)
		X# = X# + 0.21
	;	If X# > 0.42 Then X# = 0.02 : Y# = Y# + 0.125
		If X# > 0.77 Then X# = 0.02 : Y# = Y# + 0.125
	Next
	; Hide all windows
	GY_GadgetAlpha(WCharStats, 0.0, True)
	GY_GadgetAlpha(WQuestLog, 0.0, True)
	GY_GadgetAlpha(WParty, 0.0, True)
	GY_GadgetAlpha(WInventory, 0.0, True)
	GY_GadgetAlpha(WAmount, 0.0, True)
	GY_GadgetAlpha(WSpells, 0.0, True)
	
;	GY_GadgetAlpha(WASpells, 0.0, True);#################################################
	
	
	GY_GadgetAlpha(WSpellRemove, 0.0, True)
	GY_GadgetAlpha(WTrading, 0.0, True)
	GY_GadgetAlpha(WHelp, 0.0, True)
	GY_GadgetAlpha(WLargeMap, 0.0, True)
	
	;############################## Added ######################
	GY_GadgetAlpha(WMoney, 0.0, True)
	;###########################################################
	LastMouseMove = MilliSecs()
	LastLeftClick = MilliSecs()
End Function
; Creates a quad mesh
Function CreateInterfaceQuad(P = 0)
	If P Then EN = CreateMesh(P) Else EN = CreateMesh()
	s = CreateSurface(EN)
	v1 = AddVertex(s, 0.0, -1.0, 0.0, 1.0, 1.0)
	v2 = AddVertex(s, 1.0, -1.0, 0.0, 0.0, 1.0)
	v3 = AddVertex(s, 1.0, 0.0, 0.0, 0.0, 0.0)
	v4 = AddVertex(s, 0.0, 0.0, 0.0, 1.0, 0.0)
	AddTriangle(s, v3, v2, v1)
	AddTriangle(s, v4, v3, v1)
	Return EN
End Function
; Enables/disables all the buttons for empty inventory slots
Function EnableInventoryBlanks(Disable = False)
	GY_LockGadget(BInventoryDrop, Disable)
	GY_LockGadget(BInventoryEat, Disable)
	For i = 0 To Slots_Inventory
		If BSlots(i) <> 0
			If Me\Inventory\Items[i] = Null Then GY_LockGadget(BSlots(i), Disable)
		EndIf
	Next
End Function
; Sets picking modes
Function SetPickModes(Scenery = 0, Actors = 0, NonCombatants = True, DroppedItems = 0)
	If Scenery = 0
		For S.Scenery = Each Scenery
			Collides = GetEntityType(S\EN)
			If Collides = C_Sphere
				EntityPickMode(S\EN, 3, True); was 1 (wanted box rather then sphere)
			ElseIf Collides = C_Triangle
				EntityPickMode(S\EN, 2, True)
			ElseIf Collides = C_Box
				EntityPickMode(S\EN, 3, True);, fixed bug, was 2
			EndIf
		Next
		For T.Terrain = Each Terrain : EntityPickMode(T\EN, 2, True) : Next
	ElseIf Scenery = -1
		For S.Scenery = Each Scenery : EntityPickMode(S\EN, 0, True) : Next
		For T.Terrain = Each Terrain : EntityPickMode(T\EN, 0, True) : Next
	Else
		For S.Scenery = Each Scenery : EntityPickMode(S\EN, Scenery, True) : Next
		For T.Terrain = Each Terrain : EntityPickMode(T\EN, Scenery, True) : Next
	EndIf
	For AI.ActorInstance = Each ActorInstance
		If Actors = 4
			If AI\Attributes\Value[HealthStat] > 0
				EntityPickMode AI\EN, 0, True
				EntityPickMode AI\CollisionEN, 1
			Else
				EntityPickMode AI\EN, 0, False
				EntityPickMode AI\CollisionEN, 0
			EndIf
		Else
			If AI <> Me And AI\Rider = Null
				If AI\Attributes\Value[HealthStat] <= 0 Or (AI\Actor\Aggressiveness = 3 And NonCombatants = False) Or (AI\RNID = True And PvPEnabled = False And NonCombatants = False)
					EntityPickMode AI\EN, 0, True
					EntityPickMode AI\CollisionEN, 0
				ElseIf Actors = 1
					EntityPickMode AI\EN, 0, True
					EntityPickMode AI\CollisionEN, 1
				ElseIf Actors = 2
					EntityPickMode AI\EN, 2, True
					EntityPickMode AI\CollisionEN, 0
				ElseIf Actors = 3
					EntityPickMode AI\EN, 0, True
					EntityPickMode AI\CollisionEN, 1
				Else
					EntityPickMode AI\EN, 0, True
					EntityPickMode AI\CollisionEN, 0
				EndIf
			Else
				EntityPickMode AI\EN, 0, True
				EntityPickMode AI\CollisionEN, 0
			EndIf
		EndIf
	Next
	For D.DroppedItem = Each DroppedItem
		EntityPickMode(D\EN, DroppedItems)
	Next
End Function
; Creates an action bar button
Function CreateActionBarButton(TexName$, X#, Toggle = True, FreeTex = True)
       imagewidth = 0.5
       imageheight = 0.8
        X = GraphicsWidth()/2 - (imagewidth/2)
        Y = GraphicsHeight()/2 - (imageheight/2) 
	Tex = LoadTexture("Data\Textures\GUI\" + TexName$, 1)
	
	Button = GY_CreateButton(0, X, Y, imageheight, imagewidth, "", Toggle, 0, 0, 0, Tex)
	If FreeTex = True Then FreeTexture(Tex)
	GY_DropGadget(Button)
	Return Button
End Function
Function CreateActionBarButtonHide(TexName$, X#, Toggle = True, FreeTex = True)
       imagewidth = 0.5
       imageheight = 0.8
        X = GraphicsWidth()/2 - (imagewidth/2)
        Y = GraphicsHeight()/2 - (imageheight/2) 
	Tex = LoadTexture("Data\Textures\GUI\" + TexName$, 1)
	
	Button = GY_CreateButton(0, X, Y, imageheight, imagewidth, "", Toggle, 0, 0, 0, Tex)
	If FreeTex = True Then FreeTexture(Tex)
	GY_DropGadget(Button)
	Return Button
End Function
Function CreateActionBarButtonUP(TexName$, X#, Toggle = True, FreeTex = True)
       imagewidth = 0.5
       imageheight = 0.8
        X = GraphicsWidth()/2 - (imagewidth/2)
        Y = GraphicsHeight()/2 - (imageheight/2) 
	Tex = LoadTexture("Data\Textures\GUI\" + TexName$, 1)
	
	Button = GY_CreateButton(0, X, Y, imageheight, imagewidth, "", Toggle, 0, 0, 0, Tex)
	If FreeTex = True Then FreeTexture(Tex)
	GY_DropGadget(Button)
	Return Button
End Function
Function CreateActionBarButtonDown(TexName$, X#, Toggle = True, FreeTex = True)
       imagewidth = 0.5
       imageheight = 0.8
        X = GraphicsWidth()/2 - (imagewidth/2)
        Y = GraphicsHeight()/2 - (imageheight/2) 
	Tex = LoadTexture("Data\Textures\GUI\" + TexName$, 1)
	
	Button = GY_CreateButton(0, X, Y, ImageHeight, ImageWidth, "", Toggle, 0, 0, 0, Tex)
	If FreeTex = True Then FreeTexture(Tex)
	GY_DropGadget(Button)
	Return Button
End Function
Function CreateActionBarButtonLeft(TexName$, X#, Toggle = True, FreeTex = True)
       imagewidth = 0.5
       imageheight = 0.8
        X = GraphicsWidth()/2 - (imagewidth/2)
        Y = GraphicsHeight()/2 - (imageheight/2) 
	Tex = LoadTexture("Data\Textures\GUI\" + TexName$, 1)
	
	Button = GY_CreateButton(0, X, Y, imageheight, imagewidth, "", Toggle, 0, 0, 0, Tex)
	If FreeTex = True Then FreeTexture(Tex)
	GY_DropGadget(Button)
	Return Button
End Function
Function CreateActionBarButtonRight(TexName$, X#, Toggle = True, FreeTex = True)
       imagewidth = 0.5
       imageheight = 0.8
        X = GraphicsWidth()/2 - (imagewidth/2)
        Y = GraphicsHeight()/2 - (imageheight/2) 
	Tex = LoadTexture("Data\Textures\GUI\" + TexName$, 1)
	
	Button = GY_CreateButton(0, X, Y, imageheight, imagewidth, "", Toggle, 0, 0, 0, Tex)
	If FreeTex = True Then FreeTexture(Tex)
	GY_DropGadget(Button)
	Return Button
End Function
;Function CreateActionBarButtonRight(TexName$, X#, Toggle = True, FreeTex = True)
       ;imagewidth = 0.5
      ; imageheight = 0.8
      ;  X = GraphicsWidth()/2 - (imagewidth/2)
      ;  Y = GraphicsHeight()/2 - (imageheight/2) 
;
	;Tex = LoadTexture("Data\Textures\GUI\" + TexName$, 1)
	
	;Button = GY_CreateButton(0, X, Y, imageheight, imagewidth, "", Toggle, 0, 0, 0, Tex)
	;If FreeTex = True Then FreeTexture(Tex)
	;GY_DropGadget(Button)
	;Return Button
;End Function
;######################################### Added for Edit ###########################################################
Function CreateActionBarButton1(TexName$, X#, Toggle = True, FreeTex = True)
	imagewidth = 0.5
       imageheight = 0.8
        X = GraphicsWidth()/2 - (imagewidth/2)
        Y = GraphicsHeight()/2 - (imageheight/2) 
	Tex = LoadTexture("Data\Textures\GUI\" + TexName$, 1)
	
	Button = GY_CreateButton(0, X, Y, ImageHeight, ImageWidth, "", Toggle, 0, 0, 0, Tex)
	If FreeTex = True Then FreeTexture(Tex)
	GY_DropGadget(Button)
	Return Button
End Function
Function CreateActionBarButton2(TexName$, X#, Toggle = True, FreeTex = True)
	imagewidth = 0.5
       imageheight = 0.8
        X = GraphicsWidth()/2 - (imagewidth/2)
        Y = GraphicsHeight()/2 - (imageheight/2) 
	Tex = LoadTexture("Data\Textures\GUI\" + TexName$, 1)
	
	Button = GY_CreateButton(0, X, Y, ImageHeight, ImageWidth, "", Toggle, 0, 0, 0, Tex)
	If FreeTex = True Then FreeTexture(Tex)
	GY_DropGadget(Button)
	Return Button
End Function
;Function CreateActionBarButtonAbilities(TexName$, X#, Toggle = True, FreeTex = True)
;	Tex = LoadTexture("Data\Textures\GUI\" + TexName$, 1)
;	Button = GY_CreateButton(0, X# + 0.003, 0.871, 0.06 - 0.0055, 0.08 - 0.0055, "", Toggle, 0, 0, 0, Tex)
;	If FreeTex = True Then FreeTexture(Tex)
;	GY_DropGadget(Button)
;	Return Button
;End Function
;Function CreateActionBarButtonInventory(TexName$, X#, Toggle = True, FreeTex = True)
;	Tex = LoadTexture("Data\Textures\GUI\" + TexName$, 1)
;	Button = GY_CreateButton(0, X# + 0.003, 0.874, 0.05 - 0.0055, 0.07 - 0.0055, "", Toggle, 0, 0, 0, Tex)
;	If FreeTex = True Then FreeTexture(Tex)
;	GY_DropGadget(Button)
;	Return Button
;End Function
Function CreateActionBarButtonHotkey(TexName$, X#, Toggle = True, FreeTex = True)
	imagewidth = 0.5
       imageheight = 0.8
        X = GraphicsWidth()/2 - (imagewidth/2)
        Y = GraphicsHeight()/2 - (imageheight/2) 
	Tex = LoadTexture("Data\Textures\GUI\" + TexName$, 1)
	
	Button = GY_CreateButton(0, X, Y, imageheight, imagewidth, "", Toggle, 0, 0, 0, Tex)
	If FreeTex = True Then FreeTexture(Tex)
	GY_DropGadget(Button)
	Return Button
End Function
;####################################################################################################################
; Creates an inventory slot button
Function CreateInventoryButton(W, S, Tex)
	BSlots(S) = GY_CreateButton(W, InventoryButtons(S)\X#, InventoryButtons(S)\Y#, InventoryButtons(S)\Width#, InventoryButtons(S)\Height#, "", True, 0, 0, 0, Tex)
End Function
Function CreateInventoryButton2(W, S, Tex)
	BSlots(S) = GY_CreateButton(0, 0.846, 0.797, 0.059, 0.071, "", True, 0, 0, 0, Tex)
End Function
; Resets the text on the quest log
Function RedrawQuestLog()
	; Clear all labels
	For i = 0 To 16
		GY_UpdateLabel(LQuestLines(i), "")
	Next
	; Buttons
	If QuestLogVisible Then GY_GadgetAlpha(WQuestLog, 1.0, True); was .85
	GY_LockGadget(BPrevQuest, False) : GY_LockGadget(BNextQuest, False)
	MaxQuest = CountQuests(QuestLog) - 1
	If MaxQuest < 0
		GY_GadgetAlpha(BPrevQuest, 0.0) : GY_LockGadget(BPrevQuest, True)
		GY_GadgetAlpha(BNextQuest, 0.0) : GY_LockGadget(BNextQuest, True)
		GY_UpdateLabel(LQuestLines(0), LanguageString$(LS_NoQuestsAvailable))
		Return
	EndIf
	If FirstQuest = 0 Then GY_GadgetAlpha(BPrevQuest, 0.0) : GY_LockGadget(BPrevQuest, True)
	If FirstQuest >= MaxQuest Then FirstQuest = MaxQuest : GY_GadgetAlpha(BNextQuest, 0.0) : GY_LockGadget(BNextQuest, True)
	DrawDone = GY_CheckBoxDown(BCompleteQuests)
	; Find first quest to draw
	Num = 0
	Start = -1
	For i = 0 To 499
		If QuestLog\EntryName$[i] <> ""
			If DrawDone = True Or Asc(Mid$(QuestLog\EntryStatus$[i], 4, 1)) <> 254
				If Num = FirstQuest Then Start = i : Exit
				Num = Num + 1
			EndIf
		EndIf
	Next
	; If there wasn't one (usually when not displaying completed)
	If Start < 0
		GY_GadgetAlpha(BPrevQuest, 0.0) : GY_LockGadget(BPrevQuest, True)
		GY_GadgetAlpha(BNextQuest, 0.0) : GY_LockGadget(BNextQuest, True)
		GY_UpdateLabel(LQuestLines(0), LanguageString$(LS_NoQuestsAvailable))
		Return
	EndIf
	; Draw until we run out of lines
	CurrentLine = 0
	For CurrentQuest = Start To 499
		If CurrentLine > 16 Then Exit
		If QuestLog\EntryName$[CurrentQuest] <> "" And (DrawDone = True Or Asc(Mid$(QuestLog\EntryStatus$[CurrentQuest], 4, 1)) <> 254)
			GY_UpdateLabel(LQuestLines(CurrentLine), QuestLog\EntryName$[CurrentQuest] + " -", 255, 255, 255)
			CurrentLine = CurrentLine + 1
			Status$ = QuestLog\EntryStatus$[CurrentQuest]
			cR = RCE_IntFromStr(Mid$(Status$, 1, 1))
			cG = RCE_IntFromStr(Mid$(Status$, 2, 1))
			cB = RCE_IntFromStr(Mid$(Status$, 3, 1))
			Status$ = Mid$(Status$, 4)
			If Status$ = Chr$(254)
				Status$ = "  " + LanguageString$(LS_Completed)
				cR = 255 : cG = 225 : cB = 100
			Else
				Status$ = "  " + Status$
			EndIf
			While Status$ <> "" And CurrentLine <= 16
				; Word wrap
				If Len(Status$) > 43
					SplitChar = 0
					For i = 43 To 1 Step -1
						If Mid$(Status$, i, 1) = " " Then SplitChar = i : Exit
					Next
					If SplitChar > 0
						GY_UpdateLabel(LQuestLines(CurrentLine), Left$(Status$, SplitChar - 1), cR, cG, cB)
					;	GY_UpdateLabel(LQuestLines(CurrentLine), Left$(Status$, SplitChar - 1), 0, 255, 0)
						Status$ = Mid$(Status$, SplitChar + 1)
					Else
						GY_UpdateLabel(LQuestLines(CurrentLine), Left$(Status$, 25), cR, cG, cB)
					;	GY_UpdateLabel(LQuestLines(CurrentLine), Left$(Status$, 25), 0, 255, 0)
						Status$ = Mid$(Status$, 26)
					EndIf
					CurrentLine = CurrentLine + 1
				Else
					GY_UpdateLabel(LQuestLines(CurrentLine), Status$, cR, cG, cB)
				;	GY_UpdateLabel(LQuestLines(CurrentLine), Status$, 0, 255, 0)
					Status$ = ""
				EndIf
			Wend
			CurrentLine = CurrentLine + 2
		EndIf
	Next
End Function
; Updates the button icons for the action bar quick-slots
Function UpdateActionBarIcons()
	If ActionBarStart = 2
		Offset = 12
	ElseIf ActionBarStart = 3
		Offset = 24
	EndIf
	
	For i = 0 To 11
		
		
		; Spell
		If ActionBarSlots(i + Offset) < 0
			If RequireMemorise
				Num = ActionBarSlots(i + Offset) + 5
				Sp.Spell = SpellsList(Me\KnownSpells[Me\MemorisedSpells[Num]])
			Else
				Num = ActionBarSlots(i + Offset) + 1000
				Sp.Spell = SpellsList(Me\KnownSpells[Num])
			EndIf
			GYG.GY_Gadget = Object.GY_Gadget(BActionBar(i))
			EntityTexture(GYG\EN, GetTexture(Sp\ThumbnailTexID))
		; Item
		ElseIf ActionBarSlots(i + Offset) < 65535
			It.Item = ItemList(ActionBarSlots(i + Offset))
			GYG.GY_Gadget = Object.GY_Gadget(BActionBar(i))
			EntityTexture GYG\EN, GetTexture(It\ThumbnailTexID)
		Else
			GYG.GY_Gadget = Object.GY_Gadget(BActionBar(i))
			GYB.GY_Button = Object.GY_Button(GYG\TypeHandle)
			EntityTexture GYG\EN, GYB\UserTexture
		EndIf
	Next
End Function
 
 |