#ifndef __INTERFACEUTIL
#define __INTERFACEUTIL

#include "vectors.h"
#include "fileio.h"

enum{
	kInterfaceMenuItemDisabled=1<<0,
	kInterfaceMenuItemArrowInput=1<<1,
	kInterfaceMenuItemTypeable=1<<2,
	kInterfaceMenuItemTypeHidden=1<<3,
	kInterfaceMenuItemSlider=1<<4,
	kInterfaceMenuItemFixedPos=1<<5
};

enum{
	kInterfaceMenuEsc=1<<31,
	kInterfaceMenuLeftArrow=1<<30,
	kInterfaceMenuRightArrow=1<<29,
	kInterfaceMenuOK=1<<28,
	kInterfaceMenuEasterEgg=1<<27,
	kInterfaceMenuReplayKey=1<<26,
	kInterfaceMenuSpaceFlag=1<<25,
};

#define kInterfaceBackgroundTexture "background.tif"

#define kInterfaceMenuSlideBarTexture "bar.tif"
#define kInterfaceMenuSlideBarHeight 0.01
#define kInterfaceMenuSlideBarStart 0.35
#define kInterfaceMenuSlideBarWidth 0.45

#define kInterfaceMenuSliderTexture "slider.tif"
#define kInterfaceMenuSliderSize 0.02
#define kInterfaceKeyImageSize 0.06

#define kBackgroundXStretch 0.622
#define kBackgroundYStretch 0.43

#define kInterfaceStatusTexture kInterfaceMenuSlideBarTexture

#define kInterfaceMenuItemMask (~(kInterfaceMenuLeftArrow|kInterfaceMenuRightArrow|kInterfaceMenuEasterEgg|kInterfaceMenuReplayKey|kInterfaceMenuSpaceFlag))
 
typedef struct{
	char label[256];
	char describtion[512];
	char type[256];
	int flags;
	int maxTypeLength;
	float maxTypeXPos;
	float sliderPos;
	float sliderTransparency;
	float sel;
	float size;
	float scroll;
	float lineSpacing;
	float r,g,b;
	float fixedX,fixedY;
} tInterfaceMenuItemDescribtion;

enum{
	kMenuTypeableOff,
	kMenuTypeableOn,
	kMenuTypeableReggie
};

typedef struct{
	char title[256];
	char type[256];
	int initialSelection;
	int numItems;
	int scrollEnable;
	int menuTypeable;
	tFileRef image,background;
	int enterAlwaysOK;
	int returnOnSpace;
	int easterEggEnable;
	int easterEggString;
	int joinDisable;
	float cursorPos,cursorShowPos;
	float easterEggScrollPos;
	float imageXScale,imageYScale;
	float imageXPos,imageYPos;
	float imageAlpha;
	float itemsXPos,itemsYPos;
	float minScroll;
	tVector2 mousePos;
	tVector2 descPos;
	tInterfaceMenuItemDescribtion *items;
	void *userData;
	void (*RenderCallback)(void*,int,void*);
	int (*TimerCallback)(void*);
} tInterfaceMenuDescribtion;

#define kTitlePosX -0.93
#define kTitlePosY 0.98

#define kInterfaceMenuPointerTexture "menupointer.tif"
#define kInterfaceMenuPointerSize 0.02

extern int gJoinFlag;
extern char gJoinHost[];
extern char gLastMenuChar;
extern int gInterfaceType;
extern float gStartIdleTime;

int InterfaceGetUserInputString(char *prompt,char *stringBuffer,int bufferSize,int fullCharSet,int hideType);
int InterfaceGetUserMenuSelection(tInterfaceMenuDescribtion *menu);
void InterfaceDrawStrings(char *stringBuffer,char *secondaryStringBuffer,tFileRef background);
void InterfaceDisplayMessage(tFileRef background,char *stringBuffer,char *secondaryStringBuffer);
void CashString(int cash, char *str);
void MakeNumString(int i,char *str);
void TextScrollFile(tFileRef text);
void InterfaceTextBufferZoomAnimation(tFileRef background,int in);
void InterfaceMenuZoomAnimation(tInterfaceMenuDescribtion *menu,int selection,int in);
void InterfaceInitMenu(tInterfaceMenuDescribtion *menu,int numItems,char *title);
void InterfaceDisposeMenu(tInterfaceMenuDescribtion *menu);
void InterfaceDrawBackground(tFileRef background,tFileRef image,float imageXScale,float imageYScale,float imageXPos,float imageYPos,float alpha);
int InterfaceGetUserConfirmation(char *title,char *text);
void InterfaceFadeInImageFromBlack(float xSize,float ySize,tFileRef image,float maxTime);
void InterfaceFadeInInterfaceFromImage(tFileRef image,float maxTime);
void InterfaceFadeInImageFromImage(float xSize,float ySize,tFileRef image,float xSize2,float ySize2,tFileRef image2,float maxTime);
void InterfaceDrawBackgroundFade(float opacity,int showtop);
void InterfaceDrawStatusBar(char *stringBuffer,char *secondaryStringBuffer,float status);
void TeaserScreen();


void InterfaceRenderReplay(void *userData,int selection,void *menu);

#endif