예제 #1
0
int textboxInit(void *handle) {
	MAIN *m = handle;
	int h, i, j, k;

	m->box.visible = 0;
	m->box.str = NULL;
	m->box.ans_str = NULL;
	m->box.strlen = 0;
	m->box.pos = 0;
	m->box.speed = m->system.default_text_speed;
	m->box.npcCallback = 0;
	m->box.time_elapsed_rest = 0;
	m->box.text_width = m->cam.screen_w - (m->system.textbox_pad_h * 3 + m->system.face_w);
	
	if ((m->box.text = darnitTextSurfaceAlloc(m->system.std_font, TEXTBOX_GLYPHS, m->box.text_width, TEXTBOX_TEXT_H_ADJUST, TEXTBOX_TEXT_V_ADJUST)) == NULL) {
		fprintf(stderr, "Unable to allocate test buffer for text box\n");
		return -1;
	}

	m->box.tiles = m->cam.screen_w / m->system.tile_w * m->system.textbox_height;
	if ((m->box.tile = darnitRenderTileAlloc(m->box.tiles)) == NULL) {
		fprintf(stderr, "Unable to allocate tile buffer for text box background\n");
		return -1;
	}

	m->box.menu_tiles = m->system.box_selection_w * m->system.box_selection_h;
	if ((m->box.menu_tile = darnitRenderTileAlloc(m->box.menu_tiles)) == NULL) {
		fprintf(stderr, "Unable to allocate tile buffer for text box selection background\n");
		return -1;
	}

	if ((m->box.face_c = darnitRenderTileAlloc(1)) == NULL) {
		fprintf(stderr, "Unable to allocate face tile for text box\n");
		return -1;
	}

	m->box.face_ts = NULL;
	m->box.menu = NULL;
	m->box.selection = -1;
	m->box.text_w_pos = 0;

	for (j = k = 0; j < m->system.textbox_height; j++) {
		for (i = 0; i < m->cam.screen_w / m->system.tile_w; i++, k++) {
			h = textboxDecideTile(m->cam.screen_w / m->system.tile_w, m->system.textbox_height, i, j, 1);
			darnitRenderTileMove(m->box.tile, k, m->system.ts_ui_elements, i * m->system.tile_w, j * m->system.tile_h + TEXTBOX_TILE_Y);
			darnitRenderTileSet(m->box.tile, k, m->system.ts_ui_elements, h);
		}
	}

	for (j = k = 0; j < m->system.box_selection_h; j++) {
		for (i = 0; i < m->system.box_selection_w; i++, k++) {
			h = textboxDecideTile(m->system.box_selection_w, m->system.box_selection_h, i, j, 0);
			darnitRenderTileMove(m->box.menu_tile, k, m->system.ts_ui_elements, i * m->system.tile_w + TEXTBOX_SELECT_X, j * m->system.tile_h + TEXTBOX_SELECT_Y);
			darnitRenderTileSet(m->box.menu_tile, k, m->system.ts_ui_elements, h);
		}
	}

	return 0;
}
예제 #2
0
int textboxActivate(void *handle, const char *str, int npcCallback, int scroll, int face, void *face_ts, const char *q_str) {
	MAIN *m = handle;

	m->box.visible = 1;
	m->box.str = str;
	m->box.ans_str = q_str;
	m->box.strlen = strlen(str);
	m->box.pos = 0;
	m->box.speed = m->system.default_text_speed;
	m->box.scroll = scroll;
	m->box.npcCallback = npcCallback;
	m->box.time_elapsed_rest = 0;
	m->box.text_w_pos = 0;
	m->box.selection = -1;

	darnitTextSurfaceReset(m->box.text);
	darnitRenderTileSet(m->box.tile, m->box.tiles-1, m->system.ts_ui_elements, (scroll) ? TEXT_BOX_TILE_SCROLL : TEXT_BOX_TILE_CORNER_2);

	m->box.face_ts = face_ts;

	if (q_str != NULL) {
		m->box.menu = darnitMenuVerticalCreate(m->darnit, q_str, TEXTBOX_MENU_X, TEXTBOX_MENU_Y, m->system.std_font, TEXTBOX_MENU_W, m->system.box_selection_text_pad, 3);
		darnitMenuShadeColorSet(m->box.menu, m->system.box_selection_r, m->system.box_selection_g, m->system.box_selection_b, m->system.box_selection_a);
	}

	if (face_ts != NULL) {
		darnitRenderTileMove(m->box.tile, 0, m->system.ts_ui_elements, m->system.textbox_pad_h, TEXTBOX_TILE_Y + m->system.textbox_pad_v);
		darnitRenderTileSet(m->box.face_c, 0, m->box.face_ts, face);
	}

	return 0;
}
예제 #3
0
파일: arne.c 프로젝트: h4xxel/arne
int main(int argc, char **argv) {
	DARNIT_PLATFORM platform;
	DARNIT_TILE *tile;
	DARNIT_TILESHEET *ts;
	unsigned int *pixbuf;
	int w, h, x, y;//, t;
	//int sinc_1, sinc_2, sinc_3, sinc_4;

	sinetable_init();
	if (!darnitInit("Arne", "arne"))
		return -1;
	platform = darnitPlatformGet();

	w = platform.screen_w / SCALE;
	h = platform.screen_h / SCALE;

	ts = darnitRenderTilesheetNew(1, 1, w, h, DARNIT_PFORMAT_RGB5A1);
	tile = darnitRenderTileAlloc(1);

	darnitRenderTileMove(tile, 0, ts, 0, 0);
	darnitRenderTileSetTilesheetCoord(tile, 0, ts, 0, 0, w, h);
	darnitRenderTileSizeSet(tile, 0, platform.screen_w, platform.screen_h);
	pixbuf = malloc(sizeof(unsigned int) * w * h);
	if (!ts || !pixbuf)
		darnitQuit();
	
	memset(pixbuf, 0, w * h * sizeof(unsigned int));
	darnitRenderTilesheetUpdate(ts, 0, 0, w, h, pixbuf);
	
	int mov1, mov2, c1, c2, c3;

	int t = 0;

	for (;;) {
		if(t&1) {
			for (y = 0; y < h; y++)
				for (x = 0; x < w; x++) {
					//int mov0=x+y+cosine((2*sine(t/2))/10)+sine(360*x/100);
					mov1=360*y/h+(t>>1);
					mov2=360*x/w;
					c1=sine(mov1+(t>>1))/2+((mov2>>1)-mov1-mov2+(t>>1));
					//int c2=sine((c1+sine(mov0+t/10)+sine(y/40+t/2)+sine((x+y)/100)));
					c2=sine((c1+sine((y>>2)+(t>>1))+sine((x+y)))/10);
					c3=sine((c2+(cosine(mov1+mov2+c2/10)>>2)+cosine(mov2)+sine(x))/10);
					pixbuf[y * w + x] = (c1+c2+c3)/150+64;///0x10+128;
				}
			darnitRenderTilesheetUpdate(ts, 0, 0, w, h, pixbuf);
		}
		t++;
		
		darnitRenderBegin();
		darnitRenderTileDraw(tile, ts, 1);
		darnitRenderEnd();
		darnitLoop();
	}

	return 0;
}