Esempio n. 1
0
gmp_ZZpairOrNull rawWeightRange(M2_arrayint wts, const RingElement *a)
/* The first component of the degree is used, unless the degree monoid is
   trivial,
   in which case the degree of each variable is taken to be 1.
   Returns lo,hi degree.  If the ring is not a graded ring or a polynomial ring
   then (0,0) is returned.
*/
{
  try
    {
      int lo, hi;
      a->degree_weights(wts, lo, hi);
      if (error()) return 0;
      gmp_ZZpair p = new gmp_ZZpair_struct;
      p->a = newitem(__mpz_struct);
      p->b = newitem(__mpz_struct);
      mpz_init_set_si(p->a, static_cast<long>(lo));
      mpz_init_set_si(p->b, static_cast<long>(hi));
      return p;
  } catch (exc::engine_error e)
    {
      ERROR(e.what());
      return NULL;
  }
}
Esempio n. 2
0
T st_init(size_t capacity)
{
    (void)capacity;
    T t         = alloc(sizeof *t);
    t->size     = 0;
    t->head = newlink(newitem(INT_MIN, "head"), NULL);
    t->tail = newlink(newitem(INT_MIN, "head"), NULL);
    t->head->next = t->tail;
    return t;
}
Esempio n. 3
0
void test_insert()
{
    Nameval *treep;
    treep = NULL;

    treep = insert(treep, newitem("dsjung", 29));
    treep = insert(treep, newitem("wwlee", 30));
    treep = insert(treep, newitem("arkim", 24));
    treep = insert(treep, newitem("shjo", 31));
    treep = insert(treep, newitem("dhkim", 33));

    applyinorder(treep, printnv, "%s: %d\n");
    freeall(treep);
}
Esempio n. 4
0
int main(void)
{
    size_t max = 100;
    size_t n = 20;
    char buf[strsiz];
    size_t i;
    st_t st = st_init(max);

    for (i = 0; i < n; i++) {
        item_t t = newitem(randkey(), randstr(buf, strsiz));
        st_insert(st, t);
    }

    st_sort(st, print);
    printf("\nThe item with key 11 is: ");
    print(st_search(st, 11));
    printf("\nThe 4th smallest key is: ");
    print(st_select(st, 4));
    st_delete(st, st_search(st, 11));
    printf("\n delete the item with key 11.\n");
    st_sort(st, print);

    /* delete all item */
    while (!st_empty(st)) {
        item_t x = st_select(st, 0);
        printf("delete item: ");
        print(x);
        st_delete(st, st_select(st, 0));
    }

    st_finalize(&st);
    return 0;
}
Esempio n. 5
0
t_dlgitem *CreateEditText(t_x11 *x11,
			  const char *title,
			  int screenbuf,char *buf, t_id id,t_id groupid,
			  int x0,int y0,int w,int h,int bw)
{
  t_dlgitem *dlgitem;
  t_edittext *et;
  
  dlgitem=newitem(x11);
  if (h==0) h=XTextHeight(x11->font)+OFFS_Y;
  if (w==0) {
    char *test;

    snew(test,screenbuf);
    memset(test,'w',screenbuf);
    w=XTextWidth(x11->font,test,screenbuf)+
      XTextWidth(x11->font,title,strlen(title))+
      2*XCARET+2*OFFS_X;
    sfree(test);
  }
  InitWin(&(dlgitem->win),x0,y0,w,h,bw,title);
  dlgitem->ID=id;
  dlgitem->GroupID=groupid;
  dlgitem->type=edlgET;
  et=&(dlgitem->u.edittext);
  snew(et->buf,STRLEN);
  strcpy(et->buf,buf);
  et->buflen=screenbuf;
  et->strbegin=0;
  et->bChanged=FALSE;
  dlgitem->WndProc=WndProcET;

  return dlgitem;
}
Esempio n. 6
0
t_dlgitem *CreateStaticText(t_x11 *x11,
                            int nlines, char * const * lines, t_id id,
                            t_id groupid,
                            int x0, int y0, int w, int h, int bw)
{
    t_dlgitem *dlgitem;
    int        i;

    dlgitem = newitem(x11);
    if (h == 0)
    {
        h = (XTextHeight(x11->font)+OFFS_Y)*nlines+OFFS_Y;
    }
    if (w == 0)
    {
        for (i = 0; (i < nlines); i++)
        {
            w = max(w, XTextWidth(x11->font, lines[i], strlen(lines[i])));
        }
        w += 2*OFFS_X;
    }
    InitWin(&(dlgitem->win), x0, y0, w, h, bw, NULL);
    dlgitem->ID                  = id;
    dlgitem->GroupID             = groupid;
    dlgitem->type                = edlgST;
    dlgitem->u.statictext.nlines = nlines;
    snew(dlgitem->u.statictext.lines, nlines);
    for (i = 0; (i < nlines); i++)
    {
        dlgitem->u.statictext.lines[i] = strdup(lines[i]);
    }
    dlgitem->WndProc = WndProcST;

    return dlgitem;
}
Esempio n. 7
0
t_dlgitem *CreateGroupBox(t_x11 *x11,
                          const char *szLab, t_id id,
                          int nitems, t_id items[],
                          int x0, int y0, int w, int h, int bw)
{
    t_dlgitem *dlgitem;

    dlgitem = newitem(x11);
    if (h == 0)
    {
        h = XTextHeight(x11->font)+OFFS_Y;
    }
    if (w == 0)
    {
        w = XTextWidth(x11->font, szLab, strlen(szLab))+2*OFFS_X;
    }
    InitWin(&(dlgitem->win), x0, y0, w, h, bw, szLab);
    dlgitem->GroupID           = id;
    dlgitem->ID                = id;
    dlgitem->type              = edlgGB;
    dlgitem->u.groupbox.nitems = nitems;
    snew(dlgitem->u.groupbox.item, nitems);
    memcpy((char *)dlgitem->u.groupbox.item, (char *)items,
           nitems*sizeof(items[0]));
    dlgitem->WndProc = WndProcGB;

    return dlgitem;
}
Esempio n. 8
0
t_dlgitem *CreateCheckBox(t_x11 *x11,
                          const char *szLab, gmx_bool bCheckedInitial, t_id id,
                          t_id groupid,
                          int x0, int y0, int w, int h, int bw)
{
    t_dlgitem *dlgitem;

    dlgitem = newitem(x11);
    if (h == 0)
    {
        h = XTextHeight(x11->font)+OFFS_Y;
    }
    if (w == 0)
    {
        w = XTextWidth(x11->font, szLab, strlen(szLab))+OFFS_X+h;
    }
    InitWin(&(dlgitem->win), x0, y0, w, h, bw, szLab);
    dlgitem->ID                  = id;
    dlgitem->GroupID             = groupid;
    dlgitem->type                = edlgCB;
    dlgitem->u.checkbox.bChecked = bCheckedInitial;
    dlgitem->WndProc             = WndProcCB;

    return dlgitem;
}
Esempio n. 9
0
/*****************************
 *
 * Routines to create dialog items, all items have an id
 * which you can use to extract info. It is possible to have
 * multiple items with the same id but it may then not be possible
 * to extract information.
 * All routines take the position relative to the parent dlg
 * and the size and border width.
 * If the width and height are set to zero initially, they will
 * be calculated and set by the routine. With the dlgitem manipulation
 * routines listed below, the application can then move the items around
 * on the dlg box, and if wished resize them.
 *
 ****************************/
t_dlgitem *CreateButton(t_x11 *x11,
                        const char *szLab, gmx_bool bDef, t_id id, t_id groupid,
                        int x0, int y0, int w, int h, int bw)
{
    t_dlgitem *dlgitem;
    char      *lab;

    dlgitem = newitem(x11);
    if (h == 0)
    {
        h = XTextHeight(x11->font)+2*OFFS_Y;
    }
    if (w == 0)
    {
        w = XTextWidth(x11->font, szLab, strlen(szLab))+2*OFFS_X;
    }
    if (bDef)
    {
        snew(lab, strlen(szLab)+7); /* 6 for >> << and 1 for \0 */
        sprintf(lab, ">> %s <<", szLab);
    }
    else
    {
        lab = strdup(szLab);
    }
    InitWin(&(dlgitem->win), x0, y0, w, h, bw, szLab);
    sfree(lab);
    dlgitem->ID                = id;
    dlgitem->GroupID           = groupid;
    dlgitem->type              = edlgBN;
    dlgitem->u.button.bDefault = bDef;
    dlgitem->WndProc           = WndProcBN;

    return dlgitem;
}
Esempio n. 10
0
t_dlgitem *CreateRadioButton(t_x11 *x11,
                             const char *szLab, gmx_bool bSet, t_id id,
                             t_id groupid,
                             int x0, int y0, int w, int h, int bw)
{
    t_dlgitem *dlgitem;

    dlgitem = newitem(x11);
    if (h == 0)
    {
        h = XTextHeight(x11->font)+OFFS_Y;
    }
    if (w == 0)
    {
        w = XTextWidth(x11->font, szLab, strlen(szLab))+OFFS_X+h;
    }
    InitWin(&(dlgitem->win), x0, y0, w, h, bw, szLab);
    dlgitem->ID                    = id;
    dlgitem->GroupID               = groupid;
    dlgitem->type                  = edlgRB;
    dlgitem->u.radiobutton.bSelect = bSet;
    dlgitem->WndProc               = WndProcRB;

    return dlgitem;
}
Esempio n. 11
0
list *
append(list *l, void *v) {
  list *ni = newitem(v);
  if (l == NULL) {
    return ni;
  }
  list *curr;
  for (curr = l; curr->next != NULL; curr = curr->next)
    ;
  curr->next = ni;
  return l;
}
Esempio n. 12
0
TreeView::TreeView( bool controlCenter, KActionCollection *ac, QWidget *parent, const char *name )
    : K3ListView(parent), m_ac(ac), m_rmb(0), m_clipboard(0),
      m_clipboardFolderInfo(0), m_clipboardEntryInfo(0),
      m_controlCenter(controlCenter), m_layoutDirty(false)
{
    setObjectName(name);
	setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
    setAllColumnsShowFocus(true);
    setRootIsDecorated(true);
    setSorting(-1);
    setAcceptDrops(true);
    setDropVisualizer(true);
    setDragEnabled(true);
    setMinimumWidth(240);

    addColumn("");
    header()->hide();

    connect(this, SIGNAL(dropped(QDropEvent*, Q3ListViewItem*, Q3ListViewItem*)),
	    SLOT(slotDropped(QDropEvent*, Q3ListViewItem*, Q3ListViewItem*)));

    connect(this, SIGNAL(clicked( Q3ListViewItem* )),
	    SLOT(itemSelected( Q3ListViewItem* )));

    connect(this,SIGNAL(selectionChanged ( Q3ListViewItem * )),
            SLOT(itemSelected( Q3ListViewItem* )));

    connect(this, SIGNAL(rightButtonPressed(Q3ListViewItem*, const QPoint&, int)),
	    SLOT(slotRMBPressed(Q3ListViewItem*, const QPoint&)));

    // connect actions
    connect(m_ac->action("newitem"), SIGNAL(activated()), SLOT(newitem()));
    connect(m_ac->action("newsubmenu"), SIGNAL(activated()), SLOT(newsubmenu()));
    if (m_ac->action("newsep"))
        connect(m_ac->action("newsep"), SIGNAL(activated()), SLOT(newsep()));

    m_menuFile = new MenuFile( KStandardDirs::locateLocal("xdgconf-menu", "applications-kmenuedit.menu"));
    m_rootFolder = new MenuFolderInfo;
    m_separator = new MenuSeparatorInfo;
    m_drag = 0;

    //	Read menu format configuration information
    KSharedConfig::Ptr pConfig = KSharedConfig::openConfig("kickerrc");
    KConfigGroup cg(pConfig, "menus");
    m_detailedMenuEntries = cg.readEntry("DetailedMenuEntries", true);
    if (m_detailedMenuEntries)
    {
        m_detailedEntriesNamesFirst = cg.readEntry("DetailedEntriesNamesFirst", false);
    }
}
Esempio n. 13
0
t_dlgitem *CreatePixmap(Pixmap pm, t_id id,
                        t_id /*groupid*/, int x0, int y0, int w, int h, int bw)
{
    t_dlgitem *dlgitem;

    dlgitem = newitem();
    InitWin(&(dlgitem->win), x0, y0, w, h, bw, NULL);
    dlgitem->ID          = id;
    dlgitem->type        = edlgPM;
    dlgitem->u.pixmap.pm = pm;
    dlgitem->WndProc     = DefWndProc;

    return dlgitem;
}
Esempio n. 14
0
void deleteenemy(Game *game, int i)
{
    while(i+1<game->room->enemycnt)
    {
        game->room->enemies[i] = game->room->enemies[i+1];
        i++;
    }
    game->room->enemycnt--;
    //otwieranie bram
    if (game->room->enemycnt == 0)
    {
        if (game->room->up!= NULL && game->room->up->type!=5)
        {
            game->room->doorsopen[0] = 1;
            newbomb(game, game->room, 382, 95, 0, 1, 0.3);
        }
        if (game->room->right!= NULL && game->room->right->type!=5)
        {
            game->room->doorsopen[1] = 1;
            newbomb(game, game->room, 755, 342, 0, 1, 0.3);
        }
        if (game->room->down!= NULL && game->room->down->type!=5)
        {
            game->room->doorsopen[2] = 1;
            newbomb(game, game->room, 382, 590, 0, 1, 0.3);
        }
        if (game->room->left!= NULL && game->room->left->type!=5)
        {
            game->room->doorsopen[3] = 1;
            newbomb(game, game->room, 10, 342, 0, 1, 0.3);
            }
        //item lub pickup
        if (game->room->type == 3)
        {
            int random = rand()%(game->level.itemlast-game->level.itemfirst+1) + game->level.itemfirst;
            while(game->useditems[random]==1)
            {
                random = rand()%(game->level.itemlast-game->level.itemfirst+1) + game->level.itemfirst;
            }
            newitem(game, game->room, 0, random, 378, 428);
        }
        else
        {
            newpickup(game, game->room, rand()%3+1, 383, 323, 0);
        }
        //spacja
        game->spaceleft--;
    }
}
Esempio n. 15
0
void test_treesort()
{
    Nameval *treep;
    int i = 0;
    int p = 0;
    char *names[10] = {NULL};
    
    treep = NULL;
    treep = insert(treep, newitem("dsjung", 29));
    treep = insert(treep, newitem("wwlee", 30));
    treep = insert(treep, newitem("arkim", 24));
    treep = insert(treep, newitem("shjo", 31));
    treep = insert(treep, newitem("dhkim", 33));
    
    treesort(treep, &p, names);
    
    for (i = 0; i < 5; ++i) {
        if (NULL == names[i])
            break;
        printf("%s\n", names[i]);
    }
    
    freeall(treep);
}
Esempio n. 16
0
/*
 * Returns 1 if engineering was jettisoned
 */
int
e_jettison(struct ship *sp, struct ship *fed)
{
	struct list *lp;
	struct torpedo *tp;

	if (is_dead(sp, S_ENG))
		return 0;
	(void) e_cloak_off(sp, fed);
	if (syswork(shiplist[0], S_SENSOR)) {
		printf("%s: Sensors indicate debris being left by\n", science);
		printf("   the %s.  Insufficient mass . . .\n", sp->name);
	}
	lp = newitem(I_ENG);
	tp = lp->data.tp = MKNODE(struct torpedo, *, 1);
	if (tp == (struct torpedo *)NULL) {
		fprintf(stderr, "e_jettison: malloc failed\n");
		exit(2);
	}
	tp->id = new_slot();
	/*
	 * ship slows to warp 1.0 when jettisonning engineering
	 */
	tp->newspeed = 0.0;
	tp->speed = sp->warp;
	tp->target = NULL;
	tp->course = sp->course;
	tp->x = sp->x;
	tp->y = sp->y;
	tp->prox = 0;
	tp->timedelay = 10.;
	tp->fuel = sp->energy;
	tp->type = TP_ENGINEERING;
	sp->energy = sp->pods = 0;
	sp->regen = 0.0;
	tp->from = sp;
	if (sp->newwarp < -1.0)
		sp->newwarp = -0.99;
	if (sp->newwarp > 1.0)
		sp->newwarp = 0.99;
	sp->max_speed = 1.0;
	sp->status[S_ENG] = 100;	/* List as destroyed */
	sp->status[S_WARP] = 100;
	sp->cloaking = C_NONE;
	sp->t_blind_left = sp->t_blind_right = sp->p_blind_left =
	    sp->p_blind_right = 180;
	return 1;
}
Esempio n. 17
0
int main() {
	int starts[] = { 7, 8, 2, 3, 6, 9};
	int ends[] = {9, 10, 3, 4, 8, 12};
	int i, n = 6;
	NV *itree = NULL, *p;
	
	for (i = 0; i < n; i++) {
		itree = insert(itree, newitem(starts[i], ends[i], NULL));
	}
	
	puts("\nlookupany");
	p = lookupany(itree, 5, 9);
	print_interval(p);
	
	puts("\nlookupall");
	lookupall(itree, 5, 9);
	
	return 0;
}
Esempio n. 18
0
gmp_ZZorNull IM2_RingElement_to_Integer(const RingElement *a)
  /* If the ring of a is ZZ, or ZZ/p, this returns the underlying representation.
     Otherwise, NULL is returned, and an error is given */
{
  const Ring *R = a->get_ring();
  if (R->is_ZZ())
    {
      void *f = a->get_value().poly_val;
      return static_cast<gmp_ZZ>(f);
    }
  if (R->cast_to_Z_mod() != 0)
    {
      gmp_ZZ result = newitem(__mpz_struct);
      mpz_init_set_si(result, R->coerce_to_int(a->get_value()));
      return result;
    }
  ERROR("Expected ZZ or ZZ/p as base ring");
  return 0;
}
Esempio n. 19
0
/*
 * Returns 1 if a probe was launched
 */
int
e_launchprobe(struct ship *sp, struct ship *fed)
{
	int i;
	struct list *lp;
	struct torpedo *tp;

	if (!syswork(sp, S_PROBE) || sp->energy <= 10 || cantsee(sp))
		return 0;
	/*
	 * fed ship has to be going slow before we'll launch
	 * a probe at it.
	 */
	if (fabs(fed->warp) > 1.0)
		return 0;
	lp = newitem(I_PROBE);
	tp = lp->data.tp = MKNODE(struct torpedo, *, 1);
	if (tp == (struct torpedo *)NULL) {
		fprintf(stderr, "e_launchprobe: malloc failed\n");
		exit(2);
	}
	tp->from = sp;
	tp->speed = sp->warp;
	tp->newspeed = 3.0;
	tp->target = fed;
	tp->course = bearing(sp->x, fed->x, sp->y, fed->y);
	tp->x = sp->x;
	tp->y = sp->y;
	tp->prox = 200 + randm(200);
	tp->timedelay = 15.;
	tp->id = new_slot();
	if ((i = randm(15) + 10) > sp->energy)
		i = sp->energy;
	tp->fuel = i;
	tp->type = TP_PROBE;
	sp->energy -= i;
	sp->pods -= i;
	printf("%s launching probe #%d\n", sp->name, tp->id);
	return 1;
}
Esempio n. 20
0
gmp_ZZorNull IM2_RingElement_to_Integer(const RingElement *a)
/* If the ring of a is ZZ, or ZZ/p, this returns the underlying representation.
   Otherwise, NULL is returned, and an error is given */
{
  const Ring *R = a->get_ring();
  if (R->is_ZZ())
    {
      void *f = a->get_value().poly_val;
      return static_cast<gmp_ZZ>(f);
    }
  if (R->isFinitePrimeField())
    {
      gmp_ZZ result = newitem(__mpz_struct);

      std::pair<bool, long> res = R->coerceToLongInteger(a->get_value());
      assert(res.first);

      mpz_init_set_si(result, static_cast<int>(res.second));
      return result;
    }
  ERROR("Expected ZZ or ZZ/p as base ring");
  return 0;
}
Esempio n. 21
0
File: randr.c Progetto: pzanoni/tray
int main(int argc, char **argv)
{
    bindtextdomain("tray_randr", LOCALE_DIR);
    textdomain("tray_randr");

    gtk_init(&argc, &argv);

    icon = (GtkStatusIcon *)
           gtk_status_icon_new_from_file(ICON_PATH "randr.png");

    menu = gtk_menu_new();

    newitem(&item_swext,   _("Switch to external display"), CMD_SWEXT);
    newitem(&item_swint,   _("Switch to built-in display"), CMD_SWINT);
    newitem(&item_clone,   _("Use both displays"), CMD_CLONE);

    sep = gtk_separator_menu_item_new();
    gtk_widget_show(sep);
    gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep);

    newitem(&item_ext1024, _("Set ext. resolution to 1024x768"), CMD_1024);
    newitem(&item_ext800,  _("Set ext. resolution to 800x600"), CMD_800);
    newitem(&item_ext640,  _("Set ext. resolution to 640x480"), CMD_640);

    g_signal_connect(G_OBJECT(icon), "popup-menu",
                     G_CALLBACK(popup), NULL);

    sep = gtk_separator_menu_item_new();
    gtk_widget_show(sep);
    gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep);

    item_quit = gtk_menu_item_new_with_label(_("Quit"));
    gtk_widget_show(item_quit);
    gtk_menu_shell_append(GTK_MENU_SHELL(menu), item_quit);
    g_signal_connect(G_OBJECT(item_quit), "activate", G_CALLBACK(quit), NULL);

    gtk_main();

    return 0;
}
void InnerNode::add( int at, Sortable* k, Node* t)
{
    Item newitem( k, t );
    add( newitem, at );
}
Esempio n. 23
0
std::string HiresTexture::GenBaseName(
	const u8* texture, size_t texture_size,
	const u8* tlut, size_t tlut_size,
	u32 width, u32 height,
	int format,
	bool has_mipmaps,
	bool dump)
{
	std::string name = "";
	bool convert = false;
	HiresTextureCache::iterator convert_iter;
	if ((!dump || convert) && s_check_native_format)
	{
		// try to load the old format first
		u64 tex_hash = GetHashHiresTexture(texture, (int)texture_size, g_ActiveConfig.iSafeTextureCache_ColorSamples);
		u64 tlut_hash = 0;
		if(tlut_size)
			tlut_hash = GetHashHiresTexture(tlut, (int)tlut_size, g_ActiveConfig.iSafeTextureCache_ColorSamples);
		name = StringFromFormat("%s_%08x_%i", SConfig::GetInstance().m_strUniqueID.c_str(), (u32)(tex_hash ^ tlut_hash), (u16)format);
		convert_iter = s_textureMap.find(name);
		if (convert_iter != s_textureMap.end())
		{
			if (g_ActiveConfig.bConvertHiresTextures)
				convert = true;
			else
				return name;
		}
	}
	if (dump || s_check_new_format || convert)
	{
		// checking for min/max on paletted textures
		u32 min = 0xffff;
		u32 max = 0;
		switch (tlut_size)
		{
		case 0: break;
		case 16 * 2:
			for (size_t i = 0; i < texture_size; i++)
			{
				min = std::min<u32>(min, texture[i] & 0xf);
				min = std::min<u32>(min, texture[i] >> 4);
				max = std::max<u32>(max, texture[i] & 0xf);
				max = std::max<u32>(max, texture[i] >> 4);
			}
			break;
		case 256 * 2:
			for (size_t i = 0; i < texture_size; i++)
			{
				min = std::min<u32>(min, texture[i]);
				max = std::max<u32>(max, texture[i]);
			}
			break;
		case 16384 * 2:
			for (size_t i = 0; i < texture_size / 2; i++)
			{
				min = std::min<u32>(min, Common::swap16(((u16*)texture)[i]) & 0x3fff);
				max = std::max<u32>(max, Common::swap16(((u16*)texture)[i]) & 0x3fff);
			}
			break;
		}
		if (tlut_size > 0)
		{
			tlut_size = 2 * (max + 1 - min);
			tlut += 2 * min;
		}
		u64 tex_hash = XXH64(texture, texture_size);
		u64 tlut_hash = 0;
		if(tlut_size)
			tlut_hash = XXH64(tlut, tlut_size);
		std::string basename = s_format_prefix + StringFromFormat("%dx%d%s_%0016" PRIx64, width, height, has_mipmaps ? "_m" : "", tex_hash);
		std::string tlutname = tlut_size ? StringFromFormat("_%0016" PRIx64, tlut_hash) : "";
		std::string formatname = StringFromFormat("_%d", format);
		std::string fullname = basename + tlutname + formatname;
		if (convert)
		{
			// new texture
			if (s_textureMap.find(fullname) == s_textureMap.end())
			{
				HiresTextureCacheItem newitem(convert_iter->second.color_map.size());
				for (size_t level = 0; level < convert_iter->second.color_map.size(); level++)
				{
					std::string newname = fullname;
					if (level)
						newname += StringFromFormat("_mip%d", level);
					newname += convert_iter->second.color_map[level].extension;
					std::string &src = convert_iter->second.color_map[level].path;
					size_t postfix = src.find(name);
					std::string dst = src.substr(0, postfix) + newname;
					if (File::Rename(src, dst))
					{
						s_check_new_format = true;
						OSD::AddMessage(StringFromFormat("Rename custom texture %s to %s", src.c_str(), dst.c_str()), 5000);
					}
					else
					{
						ERROR_LOG(VIDEO, "rename failed");
					}
					newitem.color_map[level] = hires_mip_level(dst, convert_iter->second.color_map[level].extension, convert_iter->second.color_map[level].is_compressed);
				}
				s_textureMap.emplace(fullname, newitem);
			}
			else
			{
				for (size_t level = 0; level < convert_iter->second.color_map.size(); level++)
				{
					if (File::Delete(convert_iter->second.color_map[level].path))
					{
						OSD::AddMessage(StringFromFormat("Delete double old custom texture %s", convert_iter->second.color_map[level].path.c_str()), 5000);
					}
					else
					{
						ERROR_LOG(VIDEO, "delete failed");
					}
				}				
			}
			s_textureMap.erase(name);
		}
		return fullname;
	}
Esempio n. 24
0
void C_ECBLoader::LoadTexts(C_ItemPtr &item)
{
    try {

        C_ArchivePtr arc;

        arc.Create();

        if (arc) {

            T_DecoratorPtr<I_TextBlock, &IID_I_TextBlock> text(item);

            C_PersistentPtr persist(text);

            if (persist) {

                BSTR bs = NULL;

                text->get_Caption(&bs);

                unsigned int len = captions.GetLength();

                captions.ReDim(len + 1, TRUE);
                styles.ReDim(len + 1, TRUE);

                *captions[len] = bs;

                String::FreeBSTR(&bs);

                arc->put_IsStoring(TRUE);
                arc->put_IsFinal(FALSE);
                arc->put_IsDeep(FALSE);

                arc->Open(L"");

                C_DrawingStrategyPtr strategy(persist);
                C_DrawingStrategyPtr decoratee;

                if (strategy) {

                    I_DrawingStrategy *p = NULL;

                    strategy->get_Decoratee(&p);
                    strategy->putref_Decoratee(NULL);

                    decoratee = p;

                    if (p) {
                        p->Release();
                    }
                }

                persist->Serialise(arc);

                if (decoratee) {
                    strategy->putref_Decoratee(decoratee);
                }

                arc->Close();

                arc->get_Buffer(&bs);
                *styles[len] = bs;
                String::FreeBSTR(&bs);
            }

            I_Collection *collection = NULL;

            item->get_Children(&collection);

            if (collection) {

                C_ItemsPtr items(collection);

                long cnt = 0;
                collection->get_Count(&cnt);

                collection->Release();

                if (items && cnt > 0) {

                    VARIANT v;
                    VariantInit(&v);

                    v.vt = VT_I2;

                    for (long n = 0; n < cnt; n++) {

                        //Index is 0-based
                        v.iVal = n;

                        I_MapItem *unk = NULL;

                        items->get_Item(v, &unk);

                        C_ItemPtr newitem(unk);

                        if (unk) {
                            unk->Release();
                        }

                        if (newitem) {
                            LoadTexts(newitem);
                        }
                    }
                }
            }
        }
    }
    catch (C_STLNonStackException const &exception) {
        exception.Log(_T("Exception in C_ECBLoader::LoadTexts"));
    }
}
Esempio n. 25
0
frac_elem *FractionField::new_frac_elem() const
{
  return newitem(frac_elem);
}
Esempio n. 26
0
File: list.c Progetto: PKRoma/uTox
void list_addfriend(FRIEND *f)
{
    ITEM *i = newitem();
    i->item = ITEM_FRIEND;
    i->data = f;
}