示例#1
0
void _bta_sys_prompt(struct _bta_prompt_info *p) {
	RECT b;
	HINSTANCE hinstance = (HINSTANCE)GetWindowLong(p->parent, GWL_HINSTANCE);
	GetWindowRect(GetParent(GetParent(p->parent)), &b);

	int sh = b.bottom-b.top;
	int sw = b.right-b.left;
	int borderwidth = GetSystemMetrics(SM_CXBORDER);
	int captionheight = GetSystemMetrics(SM_CYCAPTION);
	int w=DIALOG_WIDTH+borderwidth*2;
	int h=DIALOG_HEIGHT+borderwidth+captionheight;
	int x=b.left+((sw/2)-(w/2));
	int y=b.top+((sh/2)-(h/2));

	p->win = CreateWindow(L"BetterThanAdsPrompt", L"BetterThanAds - Confirm payment",
			WS_OVERLAPPED|WS_CAPTION, x,y, w,h,
			p->parent, (HMENU)NULL, hinstance, NULL);

	if( !p->win ) {
		logmsg("error creating window\n");
		return;
	}

	ShowWindow(p->win, SW_SHOW);
	UpdateWindow(p->win);

	MSG msg;
	while( GetMessage( &msg, NULL, 0, 0 ) > 0)
	{ 
		TranslateMessage(&msg);
		DispatchMessage(&msg); 
	}
	bta_free(p);
}
示例#2
0
static int l_anim_free(lua_State *L)
{
	l_anim		*a;

	a = l_checkAnim(L, 1);

	if (a != NULL) {
		/* 
		 * Call l_anim_stop() to eliminate a race condition
		 * between the free'ing of the bta and the events.
		 */
		l_anim_stop(L);
		SDL_FreeSurface(a->s);
		bta_free(a->bta);
	}

	return 0;
}
示例#3
0
文件: gfx.c 项目: ChrisAubuchon/bard
/*
 * icon_write_bta()
 */
static void icon_write_bta(huffile_t *huf, int index)
{
	bta_t		*bta;
	bta_loop_t	*l;
	bta_cell_t	*img;
	uint32_t	offset, size, ncells;
	iconGfx_t	*ip;
	btstring_t	*data;
	int		i, j;

	bta = bta_new(1);

	ip	= &icons[index];
	offset	= 0;
	size	= icons[index].height * icons[index].width;
	data	= dehuf(huf, icons[index].size);
	ncells	= (icons[index].size / size) - 1;
	l	= bta_loop_new(bta, 0, ncells);

	for (i = 0; i < ncells; i++) {
		img	= bta_cell_new(0, 0, 
				icons[index].width, icons[index].height, 
				icons[index].delay, NULL
				);
		img->gfx = bts_ncopy(data, size, offset);
		bta_cell_convert(img);
		bta_cell_set(bta, 0, i, img);

		offset += size;
	}

	bta_write_bta(mkImagePath("%s.bta", icons[index].name), bta);

	__icon_write_png(
		bts_ncopy(data, size, offset),
		mkImagePath("%s_clear.png", ip->name),
		ip
		);


	bta_free(bta);
	bts_free(data);

}
示例#4
0
文件: gfx.c 项目: ChrisAubuchon/bard
/*
 * icon_write_detect()
 */
static void icon_write_detect(huffile_t *huf, int index)
{
	bta_t		*bta;
	bta_loop_t	*l;
	bta_cell_t	*img;
	uint32_t	offset, size;
	btstring_t	*data;
	iconGfx_t	*ip;
	int		i, j;

	bta = bta_new(1);
	l = bta_loop_new(bta, 0, 6);

	ip	= &icons[index];
	offset	= 0;
	size	= ip->height * ip->width;
	data	= dehuf(huf, ip->size);

	for (i = 0; i < 6; i++) {
		if (i == 0) {
			img = bta_cell_new(0, 0, ip->width, ip->height, 
						35, NULL);
		} else {
			img = bta_cell_new(0, 0, ip->width, ip->height,
						ip->delay, NULL);
		}

		img->gfx = bts_ncopy(data, size, size * ((i > 3)? 6 - i : i));
		bta_cell_convert(img);
		bta_cell_set(bta, 0, i, img);
	}

	bta_write_bta(mkImagePath("%s.bta", ip->name), bta);

	__icon_write_png(
		bts_ncopy(data, size, size * 4), 
		mkImagePath("%s_clear.png", ip->name),
		ip
		);
	bta_free(bta);
	bts_free(data);
}
示例#5
0
void outputBigpic(uint8_t indent)
{
	int i;
	huffile_t *huf;
	btstring_t *data;
	btstring_t *big;
	btstring_t *anim;
	uint16_t npics;
	cnvList_t	*bpl;
	bt_bigpic_t	*bp;

	bta_t *img;
	bta_cell_t *c;
	uint8_t nloops;

	FILE		*fp;
	anim_t		*ba;

	fp = xfopen(mkBardOnePath("bigpic"), "rb");
	npics = fp_read32le(fp) / sizeof(uint32_t);

	bpl = bigpicList_new();

	for (i = 0; i < npics; i++) {
/*	i = 0; {*/
		debug("Picture %d:\n", i);
		fp_moveToIndex32(fp, i, 0);

		huf = dehuf_init(fp);
		data = dehuf(huf, 0x4074);

		bigpic_flate(data, &big, &anim, huf->maxSize);

		if (anim == NULL) {
			nloops = 0;
		} else {
			ba = anim_parse(anim);
			nloops = ba->nloops;
		}

		bp = bigpic_new();
		bp->name = getPicMacro(i);
		bp->isTimeAware = isTimeAware[i];

		if (nloops) {
			img = bta_new(nloops);

			c = bta_cell_new(0, 0, 56, 88, 0, big);
			bta_cell_4bitTo8bit(c);
			bta_cell_scale(c);
			img->base = c;
 
			getAnimLoops(img, anim, ba);

			bta_cell_toRGBA(img->base, egapal);
			
			bts_free(anim);

			bta_write_bta(mkImagePath("bigpic_%d.bta", i), img);

			bp->type = IMAGE_BTA;
			bp->path = mkImagePathRel("bigpic_%d.bta", i);

			bta_free(img);
			free(ba);
		} else {
			c = bta_cell_new(0, 0, 56, 88, 0, big);
			if (isTimeAware[i]) {
				bta_cell_4bitTo8bit(c);
				bta_cell_scale(c);
				bta_cell_toRGBA(c, cityPalette);
			} else {
				bta_cell_convert(c);
			}
			bta_toPNG(c, mkImagePath("bigpic_%d.png", i));

			bp->type = IMAGE_PNG;
			bp->path = mkImagePathRel("bigpic_%d.png", i);
			bta_cell_free(c);
		}

		cnvList_add(bpl, bp);
		anim = NULL;
		dehuf_free(huf);
	}

	bigpicList_toJson(bpl, mkJsonPath("bigpic.json"));
	cnvList_free(bpl);

	fclose(fp);
}