Exemplo n.º 1
0
Arquivo: path.c Projeto: trezker/allua
static int allua_Path_drop_tail(lua_State * L)
{
   ALLUA_path path = allua_check_path(L, 1);

   al_drop_path_tail(path);

   return 0;
}
Exemplo n.º 2
0
static ALLEGRO_PATH *maybe_parent_dir(const ALLEGRO_PATH *path)
{
    ALLEGRO_PATH *path2;

    if (!path)
        return NULL;

    if (!is_build_config_name(al_get_path_tail(path)))
        return NULL;

    path2 = al_clone_path(path);
    if (path2) {
        al_drop_path_tail(path2);
        al_set_path_filename(path2, NULL);
        ALLEGRO_DEBUG("Also searching %s\n", al_path_cstr(path2, '\\'));
    }

    return path2;
}
Exemplo n.º 3
0
/* drop build configuration directory tail */
static ALLEGRO_PATH *get_resources_path(void)
{
   ALLEGRO_PATH *path;
   const char *last;

   path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
   if (!path)
      return al_create_path("");

   /* If the last directory component is the name of an MSVC build
    * configuration, then drop it.
    */
   last = al_get_path_tail(path);
   if (last &&
         (0 == strcmp(last, "Debug") ||
          0 == strcmp(last, "Release") ||
          0 == strcmp(last, "RelWithDebInfo") ||
          0 == strcmp(last, "Profile"))) {
      al_drop_path_tail(path);
   }

   return path;
}
Exemplo n.º 4
0
////////////////////////////////////////////////////////////////////////////////
// Loads and processes the skin description file which is in fact a regular
// Allegro configuration file
MAS::Error MAS::Skin::Load(const char *file) {
   int i = 0;
   lastError = MAS::Error(MAS::Error::NONE);
   ALLEGRO_CONFIG *config;
   const char *str;
   ALLEGRO_PATH *sdp;

   if (!file) {
      lastError =  MAS::Error(MAS::Error::SKIN_INI);
      return lastError;
   }

   // Try to open the skin description file
   sdp = al_create_path(file);
   if (!al_is_path_present(sdp)) {
      al_destroy_path(sdp);
      lastError = MAS::Error(MAS::Error::SKIN_INI);
      return lastError;
   }

   config = al_load_config_file(file);

   if (skinFilePath != file) {
      delete [] skinFilePath;
      skinFilePath = new char[1+strlen(file)];
      strcpy(skinFilePath, file);
   }

   Reset();

   // Get the path to the skin configuration file (drop the filename)
   al_set_path_filename(sdp, "");

   ////////////////////////////////////////////////////////////////////////////////
   // Read the name of the dir and load the bitmap data
   bool default_bitmaps = false;

   str = al_get_config_value(config, "Skin", "main_data");
   if (str) {
      al_append_path_component(sdp, str);
      lastError = LoadData(sdp, config);
      al_drop_path_tail(sdp);
      if (lastError) {
         al_destroy_config(config);
         al_destroy_path(sdp);
         delete [] skinFilePath;
         skinFilePath = NULL;
         return lastError;
      }
   }
   else {
      default_bitmaps = true;
   }

   ////////////////////////////////////////////////////////////////////////////////
   // Read the default colors
#define GET_COLOR_STR(val, def) ((str = al_get_config_value(config, "COLORS", val)) ? str : def)
   c_face     = MAS::Color(GET_COLOR_STR("face",     "210,210,210"));
   c_font     = MAS::Color(GET_COLOR_STR("fontface", " 16, 16, 16"));
   c_shad1    = MAS::Color(GET_COLOR_STR("shad1",    "255,255,255"));
   c_shad2    = MAS::Color(GET_COLOR_STR("shad2",    " 80, 80, 80"));
   c_disable  = MAS::Color(GET_COLOR_STR("disable",  "128,128,128"));
   c_select   = MAS::Color(GET_COLOR_STR("select",   "128,192,128"));
   c_deselect = MAS::Color(GET_COLOR_STR("deselect", "224,224,224"));
   c_focus    = MAS::Color(GET_COLOR_STR("focus",    "128,192,128"));
   c_sunken   = MAS::Color(GET_COLOR_STR("sunken",   "232,232,232"));
   c_back     = MAS::Color(GET_COLOR_STR("back",     "180,180,180"));
#undef GET_COLOR_STR

   if (default_bitmaps) {
      GenerateDefaultBitmaps();
   }

   ////////////////////////////////////////////////////////////////////////////////
   // Read the cursors from another datafile
   str = al_get_config_value(config, "Skin", "cursors");
   if (str) {
      al_append_path_component(sdp, str);
      lastError = LoadCursors(sdp, config);
      al_drop_path_tail(sdp);
      if (lastError) {
         al_destroy_config(config);
         al_destroy_path(sdp);
         delete [] skinFilePath;
         skinFilePath = NULL;
         return lastError;
      }
   }

   ////////////////////////////////////////////////////////////////////////////////
   // Read the samples from another datafile
   str = al_get_config_value(config, "Skin", "sounds");
   if (str) {
      al_append_path_component(sdp, str);
      lastError = LoadSamples(sdp);
      al_drop_path_tail(sdp);
      if (lastError) {
         al_destroy_config(config);
         al_destroy_path(sdp);
         delete [] skinFilePath;
         skinFilePath = NULL;
         return lastError;
      }
   }

#define GET_CONFIG_STR(section, key, def) \
   (str = al_get_config_value(config, section, key)) ? strtol(str, NULL, 10) : def

   ////////////////////////////////////////////////////////////////////////////////
   // Now load the fonts
   const char *fonts[] = { "FONT0", "FONT1", "FONT2", "FONT3",
                           "FONT4", "FONT5", "FONT6", "FONT7" };
   const char *ttfont;
   int size;
   for (i=0; i<nFonts; i++)   {
      size = GET_CONFIG_STR(fonts[i], "size", 10);
      ttfont = al_get_config_value(config, fonts[i], "file");   // the filename of the font
      al_set_path_filename(sdp, ttfont);
	  const char *filename = al_path_cstr(sdp, ALLEGRO_NATIVE_PATH_SEP);
      fntList[i]->Load(filename, size, false);
   }

   ////////////////////////////////////////////////////////////////////////////////
   // Read the object specific data:
   //----------------------------------------------
   const char *fnames[] = { "font1", "font2", "font3", "font4" };
   const char *cnames[] = { "f_col1", "f_col2", "f_col3", "f_col4" };
   const char *snames[] = { "s_col1", "s_col2", "s_col3", "s_col4" };
   const char *def_col[] = { "0,0,0", "0,0,0", "128,128,128", "0,0,0" };
   const char *def_shd[] = { "-1", "-1", "-1", "-1" };

   // button, checkbox, radio button, etc.
   const char *info_name[] = {
      "BOX",
      "BUTTON",
      "CHECKBOX",
      "RADIO",
      "LIST",
      "WINDOW",
      "MENU",
      "TEXT",
      "EDITBOX",
      "PROGRESS",
      "HYPER",
      "TAB",
      "TOOLTIP"
   };

   for (int j=0; j<nInfoItems; j++)   {
      for (i=0; i<4; i++)   {
         fnt[j][i] = GET_CONFIG_STR(info_name[i], fnames[i], 10);
         fcol[j][i] = Color((str = al_get_config_value(config, info_name[j], cnames[i])) ? str : def_col[i]);
         scol[j][i] = Color((str = al_get_config_value(config, info_name[j], snames[i])) ? str : def_shd[i]);
      }
   }

   // wallpaper style
   wallpaperStyle = GET_CONFIG_STR("WALLPAPER", "style", 3);

   // buttons animation
   buttonDisplacement    = GET_CONFIG_STR("BUTTON", "displacement", 1);
   buttonAnimationType   = GET_CONFIG_STR("BUTTON", "animationType", 0);
   buttonAnimationLength = GET_CONFIG_STR("BUTTON", "animationLength", 0);

   // group box info
   boxX =      GET_CONFIG_STR("BOX", "offX", 6);
   boxY =      GET_CONFIG_STR("BOX", "offY", 1);
   boxAlign =  GET_CONFIG_STR("BOX", "alignment", 0);
   boxBack =   (str = al_get_config_value(config, "BOX", "backColor")) ? str : "222,222,222";

   // window
   winTextPos.x(  GET_CONFIG_STR("WINDOW", "textX", 10));
   winTextPos.y(  GET_CONFIG_STR("WINDOW", "textY", 18));
   winTextAlign = GET_CONFIG_STR("WINDOW", "alignment", 0);
   winTextBack  = GET_CONFIG_STR("WINDOW", "textBack", 0);
   winExitPos.x(  GET_CONFIG_STR("WINDOW", "exitX", -22));
   winExitPos.y(  GET_CONFIG_STR("WINDOW", "exitY", 6));
   winMaxPos.x(   GET_CONFIG_STR("WINDOW", "manX", -40));
   winMaxPos.y(   GET_CONFIG_STR("WINDOW", "manY", 6));
   winMinPos.x(   GET_CONFIG_STR("WINDOW", "minX", -56));
   winMinPos.y(   GET_CONFIG_STR("WINDOW", "minY", 6));
   winAnimationType = GET_CONFIG_STR("WINDOW", "animationType", 0);
   winAnimationLength = GET_CONFIG_STR("WINDOW", "animationLength", 0);

   // combo box
   comboAnimationType = GET_CONFIG_STR("COMBOBOX", "animationType", 0);
   comboAnimationLength = GET_CONFIG_STR("COMBOBOX", "animationLength", 0);

   // menu
   menuHeight = GET_CONFIG_STR("MENU", "height", 16);
   menuDelay =  GET_CONFIG_STR("MENU", "delay", 300);
   menuAnimationType = GET_CONFIG_STR("MENU", "animationType", 0);
   menuAnimationLength = GET_CONFIG_STR("MENU", "animationLength", 0);

   // tooltip info
   tooltipAnimationType =   GET_CONFIG_STR("TOOLTIP", "animationType", 0);
   tooltipAnimationLength = GET_CONFIG_STR("TOOLTIP", "animationLength", 0);
   tooltipBack = Color((str = al_get_config_value(config, "TOOLTIP", "backColor")) ? str : "255,255,192");
   tooltipBorder = Color((str = al_get_config_value(config, "TOOLTIP", "backColor")) ? str : "0,0,0");

   // dialog popup animation
   // ...

   // should the GUI draw dotted rectangles?
   drawDots = (str = al_get_config_value(config, "Skin", "dottedRect")) ? *str != '0' : false;

   // how the focus follows the mouse
   focus = GET_CONFIG_STR("Skin", "focus", 1);

#undef GET_CONFIG_STR

   al_destroy_path(sdp);

   return MAS::Error(MAS::Error::NONE);
}