#include "raylib.h"
#include <ctime>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include "tinyfiledialogs.h"
#include "raygui.h"

#define NO 0
#define WORDx 1
#define WORDy 2
#define LETTERx 3
#define LETTERy 4

///VAR

class vari{
    public:
        vari();
        ~vari();

        std::vector<Music> musicFiles;

        Vector2 GetWindowSize();

        Vector2 centreScreen();
        Vector2 origin;
        float rotation;

        Rectangle bottomTabs;
        Rectangle sideTabs;
        Rectangle rectPad;

        std::vector<Texture2D> spriteG;
        std::vector<const char*> textureMusic;
        std::vector<const char*> textureAlarm;
        std::vector<const char*> charInsert;

        bool areTexturesLoaded = false;

};

extern vari v;
/*=========================================================================================================================*/

///FUNCT

class func{
    public:
        func();
        ~func();

        std::vector<Music> LoadMusicFiles(const std::vector<const char*>& fileNames);

        bool isAlarmTime(const char* alarmTime);

        void sizeInitWindow(Vector2 XY, const char *title, int set);

        void drawRect(Rectangle rec, float roundness, int segments, float lineThick, Color color, int rectType);

        Vector2 mousePoint();

        bool textRect(const char *text, float x, float y, Font fontt, Color tColor, Color rColor, int fontSize, int rectType);

        void newEntity();

        void addMusic();

        void mainFunctions();

        void LoadGlobalTextures(const std::vector<const char*>& fileNames);

        void UnloadGlobalTextures();

        void parseTime(const char* timeString, int& hour, int& minute);

        void addAlarm(const char* timeString);

        

        std::pair<std::vector<Music>, std::vector<float>> alarmMusicPair;

        class rectTabs{
            

            //Rectangle selecText = { x - centerText.x, y - centerText.y, textSizeX, textSizeY };)
            //DrawRectangleWithTabs(Rectangle rec, float roundness, int segments, float lineThick, Color color, int tabs, Color tabColor, float overlap, int tabsOrientation)
            public:
                
                rectTabs();

                int RowCol(int index);
                rectTabs setRowCol(int row = 1, int col = 1);

                Vector2 RectPos();
                rectTabs setRectPos(float x, float y);

                Vector2 TabSize();
                rectTabs setTabSize(float w, float h);

                float Overlap();
                rectTabs setOverlap(float value = 0.25f);

                float Roundness();
                rectTabs setRoundness(float value = 0.75f);

                int Smoothness();
                rectTabs setSmoothness(int value = 100);

                float LineThick();
                rectTabs setLineThick(float value = 2.25f);

                bool Clicked();
                rectTabs isClicked(bool value = false);

                Color MainColor();
                rectTabs setMainColor(Color value = GRAY);

                Color OutlineColor();
                rectTabs setOLColor(Color value = BLACK);

                //enum showText { NO, WORD, LETTER };

                // Function that takes a showText enum and returns it
                int getTextMode();

                rectTabs setTabText(const char* inputText, int mode, int startIndex = 0);

                Rectangle GetCentre();

                Rectangle PassRect();
                rectTabs setRect(Rectangle passedRec);

                Rectangle DrawTabs(int sel);


            private:
                int i;
                int X;
                int Y;
                
                int R;
                int C;
                Vector2 tabSize;
                float overlap;
                float roundness;

                int smoothness;
                float lineThick;

                Vector2 rectPos;

                bool isSelected;

                Color m_color;
                Color OL_Color;

                int textMode;

                //enum showText { NO, WORD, LETTER };

                //Rectangle P_centreRect;

                Rectangle P_passRect;
        };

        

        
};

extern func F;

enum class NEWENTITY{
    NONEADDED,
    SELECTION,
    ADD_MUSIC,
    ADD_ALARM,
    ADD_CLOCKTZ,
    MAIN,
    MAXENTRE
};

extern NEWENTITY Entity;

enum class MAIN{
    //SCREENMAIN,
    MUSIC,
    ALARM,
    MAXMAIN
};

extern MAIN E_Main;