示例#1
0
eolKeychain *eol_level_build_backgrounds_keychain(GList *backgrounds)
{
  eolKeychain *bgList = NULL;
  eolKeychain *bgItem;
  GList *l;
  eolBackground *bg;
  if (!backgrounds)return NULL;
  bgList = eol_keychain_new_list();
  if (!bgList)return NULL;
  for (l = backgrounds;l != NULL;l = l->next)
  {
    if (l->data)
    {
      bg = (eolBackground*)l->data;
      bgItem = eol_keychain_new_hash();
      if (!bgItem)continue;
      eol_keychain_hash_insert(bgItem,"ori",eol_keychain_new_orientation(bg->ori));
      eol_keychain_hash_insert(bgItem,"hidden",eol_keychain_new_bool(bg->hidden));
      eol_keychain_hash_insert(bgItem,"useAsClip",eol_keychain_new_bool(bg->useAsClip));
      eol_keychain_hash_insert(bgItem,"modelFile",eol_keychain_new_string(bg->modelFile));
      eol_keychain_hash_insert(bgItem,"followCam",eol_keychain_new_float(bg->followCam));
      eol_keychain_list_append(bgList,bgItem);
    }
  }
  return bgList;
}
示例#2
0
eolBool eol_level_build_save_keychain(eolLevel *level,eolKeychain *keys)
{
  GList *l;
  eolKeychain *layers;
  eolKeychain *key;
  if ((!level)||(!keys))return eolFalse;
  eol_keychain_hash_insert(keys,"idName",eol_keychain_new_string(level->idName));
  eol_keychain_hash_insert(keys,"layerCount",eol_keychain_new_uint(level->layerCount));
  eol_keychain_hash_insert(keys,"spawnPool",eol_keychain_new_uint(level->spawnPool));
  eol_keychain_hash_insert(keys,"active",eol_keychain_new_uint(level->active));
  eol_keychain_hash_insert(keys,"cameraDist",eol_keychain_new_float(level->cameraDist));
  key = eol_keychain_clone(level->keys);
  if (key != NULL)
  {
    eol_keychain_hash_insert(keys,"keys",key);
  }
  key = eol_tile_set_build_keychain(level->tileSet);
  if (key != NULL)
  {
    eol_keychain_hash_insert(keys,"tileSet",key);
  }
  
  layers = eol_keychain_new_list();
  for (l = level->layers;l != NULL;l = l->next)
  {
    eol_keychain_list_append(layers,eol_level_build_layer_keychain(l->data));
  }
  eol_keychain_hash_insert(keys,"layers",layers);
  return eolTrue;
}
示例#3
0
void eol_config_parse_tier(yaml_parser_t *parser, eolKeychain *chain)
{
  int done = 0;
  eolLine last_key;
  eolKeychain *next = NULL;
  yaml_event_t event;
  /* First element must be a variable, or we'll change states to SEQ */
  int state = KEY;
  eol_line_cpy(last_key,"");
  do
  {
    yaml_parser_parse(parser, &event);
    switch(event.type)
    {
      case YAML_SCALAR_EVENT:
        if (state == KEY)
        {
          /* new key, hold on to it until we get a value as well */
          eol_line_cpy(last_key,(char *)event.data.scalar.value);
        }
        else
        {
          /* state is VAL or SEQ */
          /* TODO data type logic should go here */
          next = eol_keychain_new_string((char *)event.data.scalar.value);
          eol_keychain_hash_insert(chain,last_key,next);
        }
        state ^= VAL; /* Toggles KEY/VAL, avoids touching SEQ */
        break;
      case YAML_SEQUENCE_START_EVENT:
        next = eol_keychain_new_list();
        eol_keychain_hash_insert(chain,last_key,
                                 next);
        eol_config_parse_sequence(parser, next);
        break;
      case YAML_MAPPING_START_EVENT:
        if (strlen(last_key) == 0)break;/*first level is implied hash.*/
        next = eol_keychain_new_hash();
        eol_keychain_hash_insert(chain,last_key,next);
        state ^= VAL;
        eol_config_parse_tier(parser, next);
        break;
      case YAML_MAPPING_END_EVENT:
      case YAML_STREAM_END_EVENT:
      case YAML_SEQUENCE_END_EVENT:
        done = 1;
        /* terminate the while loop, see below */
        break;
      default:
        fprintf(stderr,"eol_config_parse_tier: unhandled event\n");
    }
    if(parser->error != YAML_NO_ERROR)
    {
      fprintf(stderr,"eol_config_parse_tier: error\n");
      return;
    }
    yaml_event_delete(&event);
  }
  while (!done);
}
示例#4
0
void eol_spawn_add_key_list(eolSpawn *spawn,eolWord key,eolLine value)
{
  eolKeychain *valuePointer;
  eolKeychain *list;
  if (!spawn)return;
  if (spawn->keys == NULL)return;
  valuePointer = eol_keychain_new_string(value);
  list = eol_keychain_get_hash_value(spawn->keys,key);
  if (!list)
  {
    list = eol_keychain_new_list();
    eol_keychain_hash_insert(spawn->keys,key,list);
  }
  eol_keychain_list_append(list,valuePointer);
}
eolKeychain *eol_keychain_clone_list(eolKeychain *src)
{
  eolUint count,i;
  eolKeychain *item, *list = NULL;
  if (!src)return NULL;
  list = eol_keychain_new_list();
  if (!list)return NULL;
  count = eol_keychain_get_list_count(src);
  for (i = 0;i < count;i++)
  {
    item = eol_keychain_get_list_nth(src, i);
    if (!item)continue;
    eol_keychain_list_append(list,eol_keychain_clone(item));
  }
  return list;
}
示例#6
0
eolKeychain *eol_level_build_spawn_list(GList *spawnList)
{
  GList *l;
  eolKeychain *spawnKeys;
  eolKeychain *key;
  if (!spawnList)return NULL;
  spawnKeys = eol_keychain_new_list();
  if (!spawnKeys)return NULL;
  for (l = spawnList;l != NULL;l = l->next)
  {
    if (!l->data)continue;
    key = eol_spawn_build_keychain(l->data);
    if (key != NULL)
    {
      eol_keychain_list_append(spawnKeys,key);
    }
  }
  return spawnKeys;
}
示例#7
0
eolLevel *eol_level_new()
{
  eolLevel *level = NULL;
  if (!eol_level_initialized())
  {
    eol_logger_message(
      EOL_LOG_INFO,
      "eol_entdow:used uninitialized\n");
    return NULL;
  }
  level = (eolLevel *)eol_resource_new_element(_eol_level_manager);
  if (level == NULL)
  {
    eol_logger_message(
      EOL_LOG_INFO,
      "eol_level:failed to get new resource\n");
    return NULL;
  }
  eol_word_cpy(level->idName,"Untitled");
  level->tileSet = eol_tile_set_new();
  level->keys = eol_keychain_new_list();
  return level;
}