コード例 #1
0
ファイル: menu_demo.c プロジェクト: AAS/ezquake-source
void CT_Demo_Playlist_Draw(int x, int y, int w, int h, CTab_t *tab, CTabPage_t *page)
{
	int i, y2;

	if(demo_playlist_num == 0)
	{
		UI_Print_Center(x, y + 16, w, "Playlist is empty", false);
		UI_Print_Center(x, y + 32, w, "Use [Insert] or [Ctrl]+[Enter]", true);
		UI_Print_Center(x, y + 40, w, "in the demo browser to add a demo", true);
		// UI_Print_Center(x, y + 40, w, "to add demo to the playlist", true);
	}
	else
	{
		y = y - 48;
		for (i = 0; i <= demo_playlist_num - demo_playlist_base && i < DEMO_MAXLINES; i++)
		{
			y2 = 32 + i * 8 ;

			if (demo_playlist_cursor == i)
				M_Print (24, y + y2, demo_playlist[demo_playlist_base + i].name);
			else
				M_PrintWhite (24, y + y2, demo_playlist[demo_playlist_base + i].name);
		}

		M_DrawCharacter (8, y + 32 + demo_playlist_cursor * 8, FLASHINGARROW());
	}
}
コード例 #2
0
void CT_Opt_System_Draw (int x, int y, int w, int h, CTab_t *tab, CTabPage_t *page)
{
#ifndef GLQUAKE	// SOFT
#ifdef _WIN32
	if(mss_software_change_resolution_mode)
	{
		(*vid_menudrawfn) ();
	}
	else
	{
		Settings_Draw(x,y,w,h, &settsystem);
	}
#else
	Settings_Draw(x,y,w,h, &settsystem);
#endif
#else	// GL
	#define ASKBOXWIDTH 300
	if(mss_askmode)
	{
		UI_DrawBox((w-ASKBOXWIDTH)/2, h/2 - 16, ASKBOXWIDTH, 32);
		UI_Print_Center((w-ASKBOXWIDTH)/2, h/2 - 8, ASKBOXWIDTH, "Do you wish to keep these settings?", false);
		UI_Print_Center((w-ASKBOXWIDTH)/2, h/2, ASKBOXWIDTH, "(y/n)", true);
	}
	else
	{
		Settings_Draw(x,y,w,h, &settsystem);
	}
#endif
}
コード例 #3
0
void CT_Opt_System_Draw (int x, int y, int w, int h, CTab_t *tab, CTabPage_t *page)
{
	#define ASKBOXWIDTH 300
	if(mss_askmode)
	{
		UI_DrawBox((w-ASKBOXWIDTH)/2, h/2 - 16, ASKBOXWIDTH, 32);
		UI_Print_Center((w-ASKBOXWIDTH)/2, h/2 - 8, ASKBOXWIDTH, "Do you wish to keep these settings?", false);
		UI_Print_Center((w-ASKBOXWIDTH)/2, h/2, ASKBOXWIDTH, "(y/n)", true);
	}
	else
	{
		Settings_Draw(x,y,w,h, &settsystem);
	}
}
コード例 #4
0
ファイル: menu_options.c プロジェクト: jogi1/camquake
void CT_Opt_Video_Draw (int x, int y, int w, int h, CTab_t *tab, CTabPage_t *page) {
#ifndef GLQUAKE

	// Software Rendering version menu
#ifdef _WIN32
	(*vid_menudrawfn) ();
#endif
#else

	// (Open)GL version menu

#define ASKBOXWIDTH 300

	if (mvs_askmode) {
		UI_DrawBox((w-ASKBOXWIDTH)/2, h/2 - 16, ASKBOXWIDTH, 32);
		UI_Print_Center((w-ASKBOXWIDTH)/2, h/2 - 8, ASKBOXWIDTH, "Do you wish to keep these settings?", false);
		UI_Print_Center((w-ASKBOXWIDTH)/2, h/2, ASKBOXWIDTH, "(y/n)", true);
	} else
		Settings_Draw(x,y,w,h, &settvideo);

#endif
}
コード例 #5
0
ファイル: menu_options.c プロジェクト: jogi1/camquake
void MOpt_FilenameInputBoxDraw(int x, int y, int w, int h)
{
	UI_DrawBox(x + (w-INPUTBOXWIDTH) / 2, y + (h-INPUTBOXHEIGHT) / 2, INPUTBOXWIDTH, INPUTBOXHEIGHT);
	UI_Print_Center(x, y + h/2 - 8, w, "Enter the config file name", false);
	CEditBox_Draw(&filenameeb, x + (w-INPUTBOXWIDTH)/2 + 16, y + h/2 + 8, true);
}
コード例 #6
0
ファイル: Ctrl_PageViewer.c プロジェクト: AAS/ezquake-source
void CPageViewer_Draw(CPageViewer_t *viewer, int x, int y, int w, int h)
{
    int i;
    document_rendered_link_t *link;
    int line;
    char buf[512];
    int sx, sy, sw, sh;

    // change x, y, w, h
    x = x + (w - 8*(w/8)) /2;
    w = w/8;
    y = y + (h - 8*(h/8)) /2;
    h = h/8;

    if (w < 20  ||  h < 10)
        return;

    if (viewer->page == NULL)
        return;

    sx = x;
    sy = y;
    sw = w;
    sh = h;

    if (viewer->page->width != w)
        viewer->page->should_render = true;

    if (viewer->page->should_render)
        RenderDocument(viewer, w);

    // current link, if in navigation mode
    link = viewer->navigation_mode ? viewer->current_links[viewer->current_link_index] : NULL;

    // draw title bar
    /*
    if (viewer->page->rendered.title  &&  viewer->show_title)
    {
        for (line = 0; line < viewer->page->rendered.title_lines; line++)
        {
            MakeString(buf, viewer->page->rendered.title + line*viewer->page->width, viewer->page->width);
            UI_Print(x, y + line*8, buf, false);
        }

        UI_MakeLine(buf, viewer->page->width/2);
        UI_Print_Center(x, y + line*8, viewer->page->width*8, buf, false);

        sh -= line + 1;
        sy += (line + 1) * 8;
    }
    */

    // calculate scrollable area yet
    if (viewer->show_status)
        sh -= 2;
    if (viewer->page->rendered.text_lines - viewer->page->current_line < sh)
        viewer->page->current_line -= sh - (viewer->page->rendered.text_lines - viewer->page->current_line);
    if (viewer->page->current_line < 0)
        viewer->page->current_line = 0;

    // draw status bar
    if (viewer->show_status)
    {
        if (viewer->navigation_mode)
        {
            if (strlen (link->tag->href) > w)
            {
                strlcpy (buf, link->tag->href, min (sizeof (buf), w-3));
                strlcat (buf, "...", sizeof (buf));
            }
            else
            {
                int offset = (w - strlen(link->tag->href)) / 2;
                memset(buf, ' ', offset);
                strlcpy (buf + offset, link->tag->href, sizeof (buf) - offset);
            }
            UI_Print(x, y + (h-1)*8, buf, false);
        }
        else
        {
            snprintf(buf, sizeof (buf), "%d lines  ", viewer->page->rendered.text_lines);
            if (sh >= viewer->page->rendered.text_lines)
                strlcat(buf, "[full]", sizeof (buf));
            else if (viewer->page->current_line == 0)
                strlcat(buf, "[top]", sizeof (buf));
            else if (viewer->page->current_line + sh == viewer->page->rendered.text_lines)
                strlcat(buf, "[bottom]", sizeof (buf));
            else
            {
                int percent = (100*(viewer->page->current_line + sh)) / viewer->page->rendered.text_lines;
                strlcat(buf, va("[%d%%]", percent), sizeof (buf));
            }

            UI_Print(x+8*(w-strlen(buf)-1), y + (h-1)*8, buf, false);

            if (viewer->page->doc  &&  viewer->page->doc->title)
            {
                int l = w - strlen(buf) - 3;
                if (strlen(viewer->page->doc->title) <= l)
                {
                    UI_Print(x+8, y + (h-1)*8, viewer->page->doc->title, false);
                }
                else
                {
                    strlcpy(buf, viewer->page->doc->title, min (sizeof (buf), l-3));
                    strlcat(buf, "...", sizeof (buf));
                    UI_Print(x+8, y + (h-1)*8, buf, false);
                }
            }
        }
        UI_MakeLine(buf, w);
        UI_Print_Center(x, y + (h-2)*8, w*8, buf, false);
    }

    // process with scrollable area
    for (line = 0;  line < min(sh, viewer->page->rendered.text_lines - viewer->page->current_line); line++)
    {
        int start, end;
	MakeString(buf, (byte *) viewer->page->rendered.text + (line+viewer->page->current_line)*viewer->page->width, viewer->page->width);

        if (link)
        {
            start = max(link->start, (viewer->page->current_line + line) * viewer->page->width);
            end = min(link->end, (viewer->page->current_line + line + 1) * viewer->page->width);
            if (end > start)
            {
                start -= (viewer->page->current_line + line) * viewer->page->width;
                end -= (viewer->page->current_line + line) * viewer->page->width;
                for (i=start; i < end; i++)
                    buf[i] ^= 128;
            }
        }

        UI_Print(sx, sy + line*8, buf, false);
    }
    viewer->page->last_height = sh;
}
コード例 #7
0
ファイル: EX_FileList.c プロジェクト: AAS/ezquake-source
//
// FileList drawing func
//
void FL_Draw(filelist_t *fl, int x, int y, int w, int h)
{
	int i;
	int listsize, pos, interline, inter_up, inter_dn, rowh;
	char line[1024];
	char sname[MAX_PATH] = {0}, ssize[COL_SIZE+1] = {0}, sdate[COL_DATE+1] = {0}, stime[COL_TIME+1] = {0};

	// Check if it's time for us to reset the search.
	// (FL_SEARCH_TIMEOUT seconds after the user entered the last char in the search term)
	if (Sys_DoubleTime() - last_search_enter_time >= FL_SEARCH_TIMEOUT)
	{
		fl->search_valid = false;
		fl->search_string[0] = 0;
	}

	if (fl->mode == FL_MODE_DELETE)
	{
		UI_Print_Center(x, y + 8,  w, "Are you sure you want to delete this file?", true);
		UI_Print_Center(x, y + 24, w, FL_GetCurrentDisplay(fl), false);
		UI_Print_Center(x, y + 40, w, "(Y/N)", true);
		return;
	}
	#ifdef WITH_ZIP
	else if (fl->mode == FL_MODE_COMPRESS)
	{
		UI_Print_Center(x, y + 8,  w, "Are you sure you want to compress this file?", true);
		UI_Print_Center(x, y + 24, w, FL_GetCurrentDisplay(fl), false);
		UI_Print_Center(x, y + 40, w, "(Y/N)", true);
		return;
	}
	else if (fl->mode == FL_MODE_DECOMPRESS)
	{
		UI_Print_Center(x, y + 8,  w, "Are you sure you want to decompress this file?", true);
		UI_Print_Center(x, y + 24, w, FL_GetCurrentDisplay(fl), false);
		UI_Print_Center(x, y + 40, w, "(Y/N)", true);
		return;
	}
	#endif // WITH_ZIP

    fl->last_page_size = 0;

    w -= fl->scrollbar->width;

    // Calculate interline (The space between each row)
    interline = file_browser_interline.value;
    interline = max(interline, 0);
    interline = min(interline, 6);
    inter_up = interline / 2;
    inter_dn = interline - inter_up;
    rowh = 8 + inter_up + inter_dn;
    listsize = h / rowh;

    // Check screen boundaries and mimnimum size
    if (w < 160 || h < 80)
        return;
    if (x < 0 || y < 0 || x + w > vid.width || y + h > vid.height)
        return;

    if (fl->need_refresh)
	{
		#ifdef WITH_ZIP
		if (fl->in_archive)
		{
			FL_ReadArchive (fl);
		}
		else
		#endif // WITH_ZIP
		{
			FL_ReadDir(fl);
		}
	}

    if (fl->need_resort)
	{
        FL_SortDir(fl);
	}

    if (fl->search_dirty)
	{
		FL_Search(fl);
	}

	// Print the current path.
	{
		char *curr_path = NULL;

		#ifdef WITH_ZIP
		if (fl->in_archive)
		{
			curr_path = fl->current_archive;
		}
		else
		#endif // WITH_ZIP
		{
			curr_path = fl->current_dir;
		}

		// Make the path fit on screen "c:\quake\bla\bla\bla" => "c:\quake...la\bla".
		COM_FitPath (line, sizeof(line), curr_path, w/8);
	}

    line[w/8] = 0;
    UI_Print(x, y + inter_up, line, true);
    listsize--;

    // Draw column titles.
    pos = w/8;
    memset(line, ' ', pos);
    line[pos] = 0;

    if (file_browser_show_time.value)
        Add_Column(line, &pos, "time", COL_TIME);
    if (file_browser_show_date.value)
        Add_Column(line, &pos, "date", COL_DATE);
    if (file_browser_show_size.value)
        Add_Column(line, &pos, "  kb", COL_SIZE);

    memcpy(line, "name", min(pos, 4));
    line[w/8] = 0;
    UI_Print_Center(x, y + rowh + inter_dn, w, line, true);
    listsize--;

	// Nothing to show.
    if (fl->num_entries <= 0)
    {
        UI_Print_Center(x, y + 2 * rowh + inter_dn + 4, w, "directory empty", false);
        return;
    }

	// Something went wrong when processing the directory.
    if (fl->error)
    {
        UI_Print_Center(x, y + 2 * rowh + inter_dn + 4, w, "error reading directory", false);
        return;
    }

	// If we're showing the status bar we have less room for the file list.
    if (file_browser_show_status.value)
	{
        listsize -= 3;
	}

    fl->list_width = w;
	fl->list_height = listsize*rowh;
    fl->list_y_offset = 2 * rowh;
    fl->last_page_size = listsize;  // Remember for PGUP/PGDN
    fl->displayed_entries_count = listsize;
    FL_CheckPosition(fl);

    if (fl->displayed_entries_count < fl->num_entries) {
        ScrollBar_Draw(fl->scrollbar, x + fl->list_width, y + fl->list_y_offset, fl->list_height);
    }

    for (i = 0; i < listsize; i++)
    {
        filedesc_t *entry;
        DWORD dwsize;
		char size[COL_SIZE+1], date[COL_DATE+1], time[COL_TIME+1];
		char name[MAX_PATH];
        int filenum = fl->display_entry + i;
		clrinfo_t clr[2]; // here we use _one_ color, at begining of the string
		static char	last_name[sizeof(name)]	= {0}; // this is for scroll, can't put it inside scroll code

		clr[0].c = COLOR_WHITE;
		clr[0].i = 0; // begin of the string

        if (filenum >= fl->num_entries)
            break;

        entry = &fl->entries[filenum];

        // Extract date & time.
        snprintf(date, sizeof(date), "%02d-%02d-%02d", entry->time.wYear % 100, entry->time.wMonth, entry->time.wDay);
        snprintf(time, sizeof(time), "%2d:%02d", entry->time.wHour, entry->time.wMinute);

        // Extract size.
        if (entry->is_directory)
        {
            strlcpy(size, "<-->", sizeof(size));
            if (filenum == fl->current_entry)
                strlcpy(ssize, "dir", sizeof(ssize));
        }
        else
        {
            dwsize = entry->size / 1024;
            if (dwsize > 9999)
            {
                dwsize /= 1024;
                dwsize = min(dwsize, 999);
                snprintf(size, sizeof(size), "%3dm", dwsize);
                if (filenum == fl->current_entry)
                    snprintf(ssize, sizeof(ssize), "%d mb", dwsize);
            }
            else
            {
                snprintf(size, sizeof(size), "%4d", dwsize);
                if (filenum == fl->current_entry)
                    snprintf(ssize, sizeof(ssize), "%d kb", dwsize);
            }
        }

        // Add the columns to the current row (starting from the right).
        pos = w/8;

		// Clear the line.
        memset(line, ' ', pos);
		line[pos] = 0;

		// Add columns.
        if (file_browser_show_time.value)
            Add_Column(line, &pos, time, COL_TIME);
        if (file_browser_show_date.value)
            Add_Column(line, &pos, date, COL_DATE);
        if (file_browser_show_size.value)
            Add_Column(line, &pos, size, COL_SIZE);

		// End of name, switch to white.
		clr[1].c = COLOR_WHITE;
		clr[1].i = pos;

		// Set the name.
		// (Add a space infront so that the cursor for the currently
		// selected file can fit infront)
		snprintf (name, sizeof(name) - 1, " %s", entry->display);

		//
		// Copy the display name of the entry into the space that's left on the row.
		//
		if (filenum == fl->current_entry && file_browser_scrollnames.value && strlen(name) > pos)
		{
			// We need to scroll the text since it doesn't fit.
			#define SCROLL_RIGHT	1
			#define SCROLL_LEFT		0

			double			t					= 0;
			static double	t_last_scroll		= 0;
			static qbool	wait				= false;
			static int		scroll_position		= 0;
			static int		scroll_direction	= SCROLL_RIGHT;
			static int		last_text_length	= 0;
			int				text_length			= strlen(name);
			float			scroll_delay		= 0.1;

			// If the text has changed since last time we scrolled
			// the scroll data will be invalid so reset it.
			if (last_text_length != text_length || !last_name[0] || strncmp(name, last_name, sizeof(last_name)))
			{
				strlcpy(last_name, name, sizeof(last_name));
				scroll_position = 0;
				scroll_direction = SCROLL_RIGHT;
				last_text_length = text_length;

				// Wait a second before start scroll plz.
				wait = true;
				t_last_scroll = Sys_DoubleTime();
			}

			// Get the current time.
			t = Sys_DoubleTime();

			// Time to scroll.
			if (!wait && (t - t_last_scroll) > scroll_delay)
			{
				// Save the current time as the last time we scrolled
				// and change the scroll position depending on what direction we're scrolling.
				t_last_scroll = t;
				scroll_position = (scroll_direction == SCROLL_RIGHT) ? scroll_position + 1 : scroll_position - 1;
			}

			// Set the scroll direction.
			if (text_length - scroll_position == pos)
			{
				// We've reached the end, go back.
				scroll_direction = SCROLL_LEFT;
				wait = true;
			}
			else if (scroll_position == 0)
			{
				// At the beginning, start over.
				scroll_direction = SCROLL_RIGHT;
				wait = true;
			}

			// Wait a second when changing direction.
			if (wait && (t - t_last_scroll) > 1.0)
			{
				wait = false;
			}

			memcpy(line, name + scroll_position, min(pos, text_length + scroll_position));
		}
		else
		{
			//
			// Fits in the name column, no need to scroll (or the user doesn't want us to scroll :~<)
			//

			// Did we just select a new entry? In that case reset the scrolling.
			if (filenum == fl->current_entry)
			{
				last_name[0] = 0;
			}

			// If it's not the selected directory/zip color it so that it stands out.
			if (filenum != fl->current_entry)
			{
				if (entry->is_directory)
				{
					// Set directory color.
					clr[0].c = RGBAVECT_TO_COLOR(file_browser_dir_color.color);
				}
				#ifdef WITH_ZIP
				else if (entry->is_archive)
				{
					// Set zip color.
					clr[0].c = RGBAVECT_TO_COLOR(file_browser_archive_color.color);
				}
				#endif // WITH_ZIP
				else
				{
					clr[0].c = RGBAVECT_TO_COLOR(file_browser_file_color.color);
				}
			}

			memcpy(line, name, min(pos, strlen(name)));
		}

		// Draw a cursor character at the start of the line.
        if (filenum == fl->current_entry)
		{
            line[0] = 141;
			UI_DrawGrayBox(x, y + rowh * (i + 2) + inter_dn, w, rowh);
		}

		// Max amount of characters that fits on a line.
		line[w/8] = 0;

		// Color the selected entry.
		if (filenum == fl->current_entry)
		{
			clr[0].c = RGBAVECT_TO_COLOR(file_browser_selected_color.color);
			clr[0].i = 1; // Don't color the cursor (index 0).
		}

		// Print the line for the directory entry.
        UI_Print_Center3(x, y + rowh * (i + 2) + inter_dn, w, line, clr, 2, 0);

        // Remember the currently selected file for dispalying in the status bar
        if (filenum == fl->current_entry)
        {
			strlcpy (sname, line + 1, min(pos, sizeof(sname)));
            strlcpy (stime, time, sizeof(stime));
            snprintf (sdate, sizeof(sdate), "%02d-%02d-%02d", entry->time.wYear % 100, entry->time.wMonth, entry->time.wDay);
        }
    }

	// Show a statusbar displaying the currently selected entry.
    if (file_browser_show_status.value)
    {
		// Print a line to part the status bar from the file list.
        memset(line, '\x1E', w/8);
        line[0] = '\x1D';
        line[w/8 - 1] = '\x1F';
        line[w/8] = 0;
        UI_Print(x, y + h - 3 * rowh - inter_up, line, false);

		// Print the name.
        UI_Print_Center(x, y + h - 2 * rowh - inter_up, w, sname, false);

        if (fl->search_valid)
        {
			// Some weird but nice-looking string in Quake font perhaps
			strlcpy(line, "search for: ", sizeof(line));   // seach for:
            if (fl->search_error)
            {
                strlcat(line, "not found", sizeof(line));
                UI_Print_Center(x, y + h - rowh - inter_up, w, line, false);
            }
            else
            {
                strlcat(line, fl->search_string, sizeof(line));
                UI_Print_Center(x, y + h - rowh - inter_up, w, line, true);
            }
        }
        else
        {
            snprintf(line, sizeof(line), "%s \x8f modified: %s %s", ssize, sdate, stime);
            UI_Print_Center(x, y + h - rowh - inter_up, w, line, false);
        }
    }
}