#include <allegro5/allegro.h>
#include <allegro5/allegro_native_dialog.h>
#include <allegro5/allegro_ttf.h>
#include <allegro5/allegro_font.h>

#define ScreenWidth 800
#define ScreenHeight 600

int main(int argc, char **argv)
{
   ALLEGRO_DISPLAY *display = NULL;
   ALLEGRO_FONT    *font    = NULL;
   ALLEGRO_USTR    *ustr    = NULL;
   ALLEGRO_CONFIG  *conf    = NULL;

   
   al_init();
   al_init_font_addon();
   al_init_ttf_addon();
   
   al_set_new_display_flags(ALLEGRO_WINDOWED);
   display = al_create_display(ScreenWidth,ScreenHeight);
   al_set_window_position(display,200,100);
   al_set_window_title(display,"CodingMadeEasy");
   al_clear_to_color(al_map_rgb(0,0,0));
   
   font = al_load_font("NanumGothic.ttf", 36, 0);
   // l_10646.ttf does NOR suport korean characters.
   // font = al_load_font("l_10646.ttf", 36, 0);
   conf = al_load_config_file("korean.ini"); 

  
   if (font && conf)  { 
   
    // Success Output
    al_draw_text(font,al_map_rgb(44,117,255),ScreenWidth/2,ScreenHeight/2,ALLEGRO_ALIGN_CENTER, al_get_config_value(conf, "english", "Coding Made Easy"));
    // Fail No Output why???
    al_draw_text(font,al_map_rgb(44,117,255),ScreenWidth/2,ScreenHeight/2+36,ALLEGRO_ALIGN_CENTER, al_get_config_value(conf, "korean", "Coding Made Easy"));

    // Success Output
    ustr = al_ustr_new(al_get_config_value(conf, "english", "Hello"));
    al_draw_ustr(font,al_map_rgb(44,117,255),0,0,0,ustr);
    al_ustr_free(ustr);
    // Fail No Output why???
    ustr = al_ustr_new(al_get_config_value(conf, "korean", "Hello"));
    al_draw_ustr(font,al_map_rgb(44,117,255),0,36,0,ustr);
    al_ustr_free(ustr);
   } else { 
     al_clear_to_color(al_map_rgb(255,0,0));
   }
   
   al_flip_display();
   al_rest(10.0);
   al_destroy_config(conf);
   al_destroy_font(font);
   al_destroy_display(display);
 
   return 0;
}

