#ifndef __SCREEN_H
#define __SCREEN_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include <wiisprite.h>

#include "theme.h"
#include "settings.h"
#include "input.h"
#include "sound.h"
#include "common.h"
#include "color.h"
#include "drawable.h"
#include "text.h"
#include "filelist.h"
#include "widget.h"
#include "currentplaying.h"
#include "currentlength.h"
#include "playcontrol.h"
#include "eq.h"
#include "seekbar.h"
#include "image.h"
#include "notice.h"
#include "button.h"
#include "diriter.h"

#define NOTICE_FADE 30
#define NOTICE_TOTAL (30 * 7)

#define NOTICE_POS 100

enum _widget_uids
{
	WIDGET_NOUID = 0,
	WIDGET_MASTER,
	WIDGET_FILELIST,
	WIDGET_MENU,
	WIDGET_MENU_CHILD,
	WIDGET_NOTICE,
	WIDGET_NOTICE_CAPTION
};

typedef struct _DrawList
{
	Widget *widget;
	int uid;
	int uuid;
	
	struct _DrawList *next;	
} DrawList;

using namespace wsp;

class Screen
{
	public:
		Screen();
		~Screen();
		
		bool update();
		
		void setCursor(int x, int y, f32 rot, u32 buttonsDown, u32 buttonsUp);
		void drawFrame();
		
		void addWidget(Widget *widget, int uid);
		Widget *findWidget(int uid);
		bool removeWidget(int uid);
		
		void exitNow();
		void closeMenu();
		void toggleFlashing();

		void setNextTheme();
		void setPrevTheme();	
	private:
		void initConsole();
		void initSkin();
		
		void initParentControl();
		void initFiles();
		void initNowPlaying();
		void initCurrentTime();
		void initLength();
		void initPlayControls();
		void initEQ();
		void initSeekBar();
		void initNotice();
		void initMenu();
		
		void setThemeCaptions();
		
		char menuThemeName[128];
		
		Directory *themes;
		Directory *languages;
		Label *themeLabel;
		Button *next;
		Button *prev;
		
		Settings settingsManager;
		Theme windowManager;
		Input cursor;
		Sound sound;
		Rect offset;
		
		GameWindow mainWindow;
		FileList fileList;
		
		Image cursorImage;
		Sprite cursorSprite;
		
		DrawList *drawList;
		int uidUnique;
		int lastUid;
		int focusUid;
		
		bool shouldExit;
		bool menuOpen;
		
		int menuFinal;
		int direction;
		Button *wiilight;
		
		Notice notice;
		int noticeFrame;
		bool noticeOpen;
};

#ifdef __cplusplus
}
#endif

#endif
