Пример #1
0
void block_url_query(struct session *ses, unsigned char *u)
{
	if (test_list_window_in_use(&blocks_ld, ses->term))
		return;

	input_field(ses->term, NULL, TEXT_(T_BLOCK_URL) , TEXT_(T_BLOCK_ADD), ses, 0, MAX_INPUT_URL_LEN, u, 0, 0, NULL, TEXT_(T_OK), (void (*)(void *, unsigned char *)) block_url_add, TEXT_(T_CANCEL), NULL, NULL);

}
Пример #2
0
static void block_edit_item_fn(struct dialog_data *dlg)
{
	/*Copied from input_field. I don't know how most of it works.*/
#define LL gf_val(1, G_BFU_FONT_SIZE)
	struct terminal *term = dlg->win->term;
	int max = 0, min = 0;
	int w, rw;
	int y = gf_val(-1, -G_BFU_FONT_SIZE);
	unsigned char *text = TEXT_(T_ENTER_URL);


	if (dlg->win->term->spec->braille) y += gf_val(1, G_BFU_FONT_SIZE);
	max_text_width(term, text, &max, AL_LEFT);
	min_text_width(term, text, &min, AL_LEFT);
	max_buttons_width(term, dlg->items + 1, 2, &max);
	min_buttons_width(term, dlg->items + 1, 2, &min);
	if (max < dlg->dlg->items->dlen) max = dlg->dlg->items->dlen;
	w = term->x * 9 / 10 - 2 * DIALOG_LB;
	if (w > max) w = max;
	if (w < min) w = min;
	rw = w;
	dlg_format_text_and_field(dlg, NULL, text, dlg->items, 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT);
	y += LL;
	dlg_format_buttons(dlg, NULL, dlg->items + 1, 2, 0, &y, w, &rw, AL_CENTER);
	w = rw;
	dlg->xw = rw + 2 * DIALOG_LB;
	dlg->yw = y + 2 * DIALOG_TB;
	center_dlg(dlg);
	draw_dlg(dlg);
	y = dlg->y + DIALOG_TB;
	if (dlg->win->term->spec->braille) y += gf_val(1, G_BFU_FONT_SIZE);
	dlg_format_text_and_field(dlg, term, text, dlg->items, dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT);
	y += LL;
	dlg_format_buttons(dlg, term, dlg->items + 1, 2, dlg->x + DIALOG_LB, &y, w, NULL, AL_CENTER);
}
Пример #3
0
/** NOTE: both IP address and port are in host byte order */
STATIC File * SocketOpen2(IPaddr addr, Port port)
{
    Socket sock = INVALID_SOCKET;
    if (SOCKET_GetTcp(0,&sock)) {
        if (SOCKET_Connect(sock, addr, port)) {
            SocketFile * s = MEM_New(SocketFile);
            if (s) {
                Bool ok;
                StrBuf32 nameBuf;
                STRBUF_InitBufXXX(&nameBuf);
                STRBUF_Format(&nameBuf.sb, TEXT(IPADDR_FORMAT)TEXT_(":%hu"),
                    HOST_IPADDR_FORMAT_ARG(addr),port);

                memset(s, 0, sizeof(*s));
                ok = FILE_Init(&s->file, nameBuf.sb.s, False, &SocketIO);
                STRBUF_Destroy(&nameBuf.sb);

                if (ok) {
                    s->sock = sock;
                    s->eof = False;
                    return &s->file;
                }
            }            
            shutdown(sock, SHUT_RDWR);
        }
        closesocket(sock);
    }
    return NULL;
}
Пример #4
0
/*This is used to display the items in the menu*/
static unsigned char *block_type_item(struct terminal *term, void *data, int x)
{
	unsigned char *txt, *txt1;
	struct block* item=(struct block*)data;

	if ((struct list*)item==(&blocks)) return stracpy(_(TEXT_(T_BLOCK_LIST),term));
	txt=stracpy(item->url);

	/*I have no idea what this does, but it os copied from working code in types.c*/
	txt1=convert(blocks_ld.codepage,term_charset(term),txt,NULL);
	mem_free(txt);

	return txt1;
}
Пример #5
0
/*This is used to display the items in the menu*/
static unsigned char *block_type_item(struct terminal *term, void *data, int x)
{
	unsigned char *txt, *txt1;
	struct conv_table *table;
	struct block* item=(struct block*)data;

	if ((struct list*)item==(&blocks)) return stracpy(_(TEXT_(T_BLOCK_LIST),term));
	txt=stracpy(item->url);
	

	/*I have no idea what this does, but it os copied from working code in types.c*/
	table=get_translation_table(blocks_ld.codepage,term->spec->charset);
	txt1=convert_string(table,txt,(int)strlen(cast_const_char txt),NULL);
	mem_free(txt);
			
	return txt1;
}
Пример #6
0
void InitApplication(u32 windowWidth, u32 windowHeight, ApplicationFlagsEnum flags, ApplicationPresentProfileEnum profile, i32 adapterIndex) {
	GDisplaySettings.resolution.x = windowWidth;
	GDisplaySettings.resolution.y = windowHeight;

	switch (profile) {
	case APP_PRESENT_THROUGHPUT:
		{
			GDisplaySettings.vsync = 1;
			GDisplaySettings.backbuffers_num = 3;
			GDisplaySettings.max_gpu_buffered_frames = 3;
			GDisplaySettings.wait_to_vblank = false;
		}
		break;
	case APP_PRESENT_UNTHROTTLED:
		{
			GDisplaySettings.vsync = 0;
			GDisplaySettings.backbuffers_num = 3;
			GDisplaySettings.max_gpu_buffered_frames = 3;
			GDisplaySettings.wait_to_vblank = false;
		}
		break;
	case APP_PRESENT_LOWLATENCY:
		{
			GDisplaySettings.vsync = 1;
			GDisplaySettings.backbuffers_num = 3;
			GDisplaySettings.max_gpu_buffered_frames = 2;
			GDisplaySettings.wait_to_vblank = true;
		}
		break;
	case APP_PRESENT_VERYLOWLATENCY:
		{
			GDisplaySettings.vsync = 1;
			GDisplaySettings.backbuffers_num = 2;
			GDisplaySettings.max_gpu_buffered_frames = 1;
			GDisplaySettings.wait_to_vblank = true;
		}
		break;
	default:
		Check(0);

	}

	InitMainThread();
	InitProfiler();
	PROFILE_NAME_THREAD("Main");
	InitScheduler();

	InitSDL(&SDLWindow);

	InitDevice(GDisplaySettings.hwnd, false, flags & APP_FLAG_D3D12_DEBUG, adapterIndex);
	InitRenderingEngines();
	InitResources();

	GGPUMainQueue = CreateQueue(TEXT_("3d_engine"), GPUQueueEnum::Direct);
	GGPUCopyQueue = CreateQueue(TEXT_("copy_engine"), GPUQueueEnum::Copy);

	CreateSwapChain(GetD12Queue(GGPUMainQueue));

	ImGuiIO& io = ImGui::GetIO();
	io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB;
	io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
	io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT;
	io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP;
	io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN;
	io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME;
	io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END;
	io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE;
	io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE;
	io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
	io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
	io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
	io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
	io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V;
	io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X;
	io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y;
	io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z;

	io.RenderDrawListsFn = Essence::RenderImDrawLists;
	io.ImeWindowHandle = GDisplaySettings.hwnd;

	io.Fonts->AddFontDefault();
	unsigned char* pixels;
	int width, height;
	io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
	io.Fonts->TexID = nullptr;

	D3D12_SUBRESOURCE_DATA imageData;
	imageData.pData = pixels;
	imageData.RowPitch = sizeof(u32) * width;
	imageData.SlicePitch = sizeof(u32) * width * height;

	auto fontsTexture = CreateTexture2D(width, height, DXGI_FORMAT_R8G8B8A8_UNORM, NO_TEXTURE_FLAGS, "font_texture");
	CopyFromCpuToSubresources(GGPUCopyQueue, Slice(fontsTexture), 1, &imageData);
	io.Fonts->TexID = HandleToImGuiTexID(fontsTexture);

	GApplicationInitializeFunction();

	// after issuing init copies waiting for completion
	QueueWait(GGPUMainQueue, GetLastSignaledFence(GGPUCopyQueue));
}
Пример #7
0
static void block_edit_item(struct dialog_data *dlg, void *data, void (*ok_fn)(struct dialog_data *, void *, void *, struct list_description *), void *ok_arg, unsigned char dlg_title)
{
	/*Copied from types.c */
	/*Data is a new item generated by the "default" function*/
	struct block *neww=(struct block*)data;

	struct terminal *term=dlg->win->term;
	struct dialog *d;
	struct assoc_ok_struct *s;
	unsigned char *url;


	/*Allocate space for dialog, 4 items followed by 1 string*/
	d = mem_alloc(sizeof(struct dialog) + 4 * sizeof(struct dialog_item) + 1 * MAX_STR_LEN);
	memset(d, 0, sizeof(struct dialog) + 4 * sizeof(struct dialog_item) + 1 * MAX_STR_LEN);

	/*Set up this string */
	url=(unsigned char *)&d->items[4];
	if (neww->url)safe_strncpy(url,neww->url,MAX_STR_LEN);

	/* Create the dialog */
	s = mem_alloc(sizeof(struct assoc_ok_struct));

	s->fn=ok_fn;
	s->data=ok_arg;
	s->dlg=dlg;

	switch (dlg_title)
	{
		case TITLE_EDIT:
		d->title=TEXT_(T_BLOCK_EDIT);
		break;

		case TITLE_ADD:
		d->title=TEXT_(T_BLOCK_ADD);
		break;

		default:
		internal("Unsupported dialog title.\n");
	}

	d->udata=data;
	d->udata2=s;
	d->fn = block_edit_item_fn;
	d->abort=block_edit_abort;
	d->refresh=block_edit_done;
	d->refresh_data = d;
	d->items[0].type = D_FIELD;
	d->items[0].dlen = MAX_STR_LEN;
	d->items[0].data = url;
	d->items[0].fn = check_nonempty;
	d->items[1].type = D_BUTTON;
	d->items[1].gid = B_ENTER;
	d->items[1].fn = ok_dialog;
	d->items[1].text = TEXT_(T_OK);
	d->items[2].type = D_BUTTON;
	d->items[2].gid = B_ESC;
	d->items[2].text = TEXT_(T_CANCEL);
	d->items[2].fn = cancel_dialog;
	d->items[3].type = D_END;
	do_dialog(term, d, getml(d, NULL));
}