コード例 #1
0
ファイル: expose.c プロジェクト: calumchisholm/XPilotNG-web
void DrawTools(void)
{
    int i, j, w, sel;

    DrawSmallMap();
    /* draw button icons */
    w = (TOOLSWIDTH - 20) / 5;
    for (i = 0; i < 7; i++)
	for (j = 0; j < 5; j++) {
	    sel = i * 5 + j + 1;
	    if (sel == drawicon)
		DrawMapPic(mapwin, 14 + j * w, 9 + i * w,
			   mapicon_ptr[iconmenu[sel] - 32], w - 7);
	    else
		DrawMapPic(mapwin, 13 + j * w, 8 + i * w,
			   mapicon_ptr[iconmenu[sel] - 32], w - 7);
	}
}
コード例 #2
0
ファイル: expose.c プロジェクト: calumchisholm/XPilotNG-web
void DrawMapSection(int x, int y, int width, int height, int xpos,
		    int ypos)
{
    int i, j, w, h, data;
    char strng[2];

    if (x < 0) {
	DrawMapSection(map.width + x, y, (0 - x), height, xpos, ypos);
	DrawMapSection(0, y, width + x, height, xpos - (x * map.view_zoom),
		       ypos);
	return;
    }
    if (y < 0) {
	DrawMapSection(x, map.height + y, width, (0 - y), xpos, ypos);
	DrawMapSection(x, 0, width, height + y, xpos,
		       ypos - (y * map.view_zoom));
	return;
    }
    if ((x + width) > map.width) {
	DrawMapSection(x, y, map.width - x, height, xpos, ypos);
	DrawMapSection(0, y, x + width - map.width, height,
		       xpos + ((map.width - x) * map.view_zoom), ypos);
	return;
    }
    if ((y + height) > map.height) {
	DrawMapSection(x, y, width, map.height - y, xpos, ypos);
	DrawMapSection(x, 0, width, y + height - map.height, xpos,
		       ypos + ((map.height - y) * map.view_zoom));
	return;
    }

    w = width + x;
    h = height + y;
    for (i = x; i <= w; i++)
	for (j = y; j <= h; j++) {
	    if ((i < map.width) && (j < map.height)) {
		data = map.data[i][j];
		DrawMapPic(mapwin, (i - x) * map.view_zoom + xpos,
			   (j - y) * map.view_zoom + ypos,
			   mapicon_ptr[data - 32], map.view_zoom);
		if (((data > 47) && (data < 58))
		    || ((data > 64) && (data < 91))) {
		    strng[0] = data;
		    strng[1] = '\0';
		    T_DrawString(mapwin, (i - x) * map.view_zoom + xpos,
				 (j - y) * map.view_zoom + 1 + ypos,
				 map.view_zoom, map.view_zoom - 1,
				 White_GC, strng, JUSTIFY_CENTER,
				 CROP_RIGHT, -1);
		}
	    }
	}
}
コード例 #3
0
ファイル: map.c プロジェクト: huangda1982/jinyong
void DrawMapWithoutUpdate()
{
	int mx;
	int my;
	int cx = g_mx;
	int cy = g_my;

	//清屏
	DrawRectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0xff);

	int minMx = ScreenXYToMapScencePos(PIC_POS_MAX_X, PIC_POS_MIN_Y, cx, cy).x;
	if (minMx < 0) minMx = 0;
	int minMy = ScreenXYToMapScencePos(PIC_POS_MIN_X, PIC_POS_MIN_Y, cx, cy).y;
	if (minMy < 0) minMy = 0;
	int maxMx = ScreenXYToMapScencePos(PIC_POS_MIN_X, PIC_POS_MAX_Y, cx, cy).x;
	if (maxMx > MAP_WIDTH) maxMx = MAP_WIDTH;
	int maxMy = ScreenXYToMapScencePos(PIC_POS_MAX_X, PIC_POS_MAX_Y, cx, cy).y;
	if (maxMy > MAP_HEIGHT) maxMy = MAP_HEIGHT;

		for (mx = minMx; mx < maxMx; mx++) {
	for (my = minMy; my < maxMy; my++) {
			T_Position pos = MapScenceXYToScreenPos(mx, my, cx, cy);
			if ((pos.x >= PIC_POS_MIN_X && pos.x < PIC_POS_MAX_X)
				&& (pos.y >= PIC_POS_MIN_Y && pos.y < PIC_POS_MAX_Y)) {
				DrawMapPic(g_map[mx][my] / 2, pos.x, pos.y);

				if (g_ground[mx][my] > 0) {
					DrawMapPic(g_ground[mx][my] / 2, pos.x, pos.y);
				}
			}
		//}
	//}

		//for (mx = minMx; mx < maxMx; mx++) {
	//for (my = minMy; my < maxMy; my++) {
			//s.weyl说游戏中xy是反的,开始没在意,现在终于信了。
			int by = g_buildingX[mx][my];
			int bx = g_buildingY[mx][my];
			T_Position bPos = MapScenceXYToScreenPos(bx, by, cx, cy);
			if ((bPos.x >= PIC_POS_MIN_X && bPos.x < PIC_POS_MAX_X)
				&& (bPos.y >= PIC_POS_MIN_Y && bPos.y < PIC_POS_MAX_Y)) {
				if (g_building[bx][by] > 0 && g_buildingX[mx + 1][my] != bx && g_buildingX[mx][my + 1] != by) {
					DrawMapPic(g_building[bx][by] / 2, bPos.x, bPos.y);
				}
			}

			//pos = MapScenceXYToScreenPos(mx, my, cx, cy);
			if (mx == g_mx && my == g_my) {
				if (g_ship) {
					DrawMapPic(SHIP_PIC_OFFSET + g_mFace * SHIP_PIC_NUM + g_mShip, pos.x, pos.y);
				} else if (g_mStep || !g_mRest) {
					DrawMapPic(WALK_PIC_OFFSET + g_mFace * WALK_PIC_NUM + g_mStep, pos.x, pos.y);
				} else {
					DrawMapPic(REST_PIC_OFFSET + g_mFace * REST_PIC_NUM + (g_mRest - 1), pos.x, pos.y);
				}
			}
		}
	}
}
コード例 #4
0
ファイル: help.c プロジェクト: calumchisholm/XPilotNG-web
void DrawHelpWin(void)
{
    int i, j, w, sel;

    switch (helppage) {

    case 0:
	w = (HELP_WIDTH * .3) / 5;
	for (i = 0; i < 7; i++) {
	    for (j = 0; j < 5; j++) {
		sel = i * 5 + j + 1;
		if (sel == helpsel)
		    DrawMapPic(helpwin, 14 + j * w, 14 + i * w,
			       mapicon_ptr[iconmenu[sel] - 32], w - 7);
		else
		    DrawMapPic(helpwin, 13 + j * w, 13 + i * w,
			       mapicon_ptr[iconmenu[sel] - 32], w - 7);
	    }
	}
	for (i = 0; i < 35; i++) {
	    j = i / 12;
	    DrawMapPic(helpwin, (int) 10 + j * ((HELP_WIDTH - 30) / 3),
		       (int) (30 +
			      (HELP_WIDTH * .17 / 5 + 10) * (i - j * 12)) +
		       (HELP_WIDTH * .5 / 5 * 4),
		       mapicon_ptr[iconhelp[i + 1] - 32], w - 7);
	    T_DrawString(helpwin, 20 + j * ((HELP_WIDTH - 30) / 3) + w,
			 (int) (25 +
				(HELP_WIDTH * .17 / 5 + 10) * (i -
							       j * 12)) +
			 (HELP_WIDTH * .5 / 5 * 4),
			 (int) ((HELP_WIDTH - 20) / 3), w, BKGR,
			 iconlabel[i + 1], JUSTIFY_LEFT, CROP_RIGHT, -1);
	}
	T_DrawText(helpwin, (int) (HELP_WIDTH * .3 + 20),
		   (int) (10 + HELP_WIDTH * .03),
		   (int) (HELP_WIDTH * .7 - 20),
		   (int) (HELP_WIDTH * .3 / 5 * 4), BKGR,
		   "Select a map icon to draw with from the buttons at the top of the tool panel. The selected icon will also be used in the line and fill modes.\n\nThe map icon buttons may be turned off to draw empty spaces or the second mouse button can be used.");
	T_DrawText(helpwin, 10,
		   (int) (150 +
			  (HELP_WIDTH * .3 / 5 * 4 +
			   (HELP_WIDTH * .3 / 5 + 10) * 7)),
		   HELP_WIDTH - 20,
		   (int) (HELP_HEIGHT - (30 + (HELP_WIDTH * .3 / 5 * 11))),
		   BKGR,
		   "You can draw numbered bases and checkpoints by entering 0 through 9 and A through Z on the keyboard while the pointer is in the map region.");
	break;

    case 1:
	T_DrawText(helpwin, (int) (HELP_WIDTH * .3 + 20), 10,
		   (int) (HELP_WIDTH * .7 - 20), HELP_BTN_HEIGHT * 3, BKGR,
		   "The three button set below the map icon buttons determines what mode you are in.\n\nWhile in draw and line mode, the first button draws the selected map icon and the second button draws space.");
	T_DrawButton(helpwin, 10, 80 + 3 * HELP_BTN_HEIGHT,
		     HELP_WIDTH * .3, HELP_WIDTH * .3, LOWERED, 0);
	XFillRectangle(display, helpwin, Black_GC, 15,
		       85 + 3 * HELP_BTN_HEIGHT, HELP_WIDTH * .3 - 10,
		       HELP_WIDTH * .3 - 10);
	T_DrawText(helpwin, (int) (HELP_WIDTH * .3 + 20),
		   100 + 3 * HELP_BTN_HEIGHT, (int) (HELP_WIDTH * .7 - 20),
		   HELP_WIDTH * .3, BKGR,
		   "To move the map view around, press a button and drag the cursor in the small map area.\n\n\nUse the Z and z buttons to zoom in and out. If an area is selected, it will be centered in the view.");
	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH,
		   (int) (120 + 3 * HELP_BTN_HEIGHT + .3 * HELP_WIDTH),
		   HELP_WIDTH - 30 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT + 80,
		   BKGR,
		   "The preferences popup allows you to save parameters that will change the behavior of the game. Only non-empty selections are saved in the map file for the fields and the yes/no buttons.");
	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH,
		   (int) (200 + 4 * HELP_BTN_HEIGHT + .3 * HELP_WIDTH),
		   HELP_WIDTH - 30 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT + 80,
		   BKGR, "The Help button displays the help screens.");
	break;

    case 2:
	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 10,
		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
		   "Load a map or .xbm file.");
	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 40 + HELP_BTN_HEIGHT,
		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
		   "Save the current map.");
	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 70 + 2 * HELP_BTN_HEIGHT,
		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
		   "Create a new, empty map.");
	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 100 + 3 * HELP_BTN_HEIGHT,
		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
		   "Quit the map editor.");
	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 170 + 4 * HELP_BTN_HEIGHT,
		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
		   "While in select mode, the Cut button removes the selected map area and places the non-space icons into the cut buffer.");
	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 200 + 5 * HELP_BTN_HEIGHT,
		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
		   "While in select mode, the Copy button places the non-space icons from the selected map area into the cut buffer.");
	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 230 + 6 * HELP_BTN_HEIGHT,
		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
		   "While in select mode, the Paste button fills the selected area with icons from the cut-buffer. Only the selected area of the map will be affected and spaces from the cut buffer will not be copied.");
	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 260 + 7 * HELP_BTN_HEIGHT,
		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
		   "The Undo button reverts the map to the state it was before the last operation. You may undo successive operations until the beginning of the map editor session.");
	break;

    case 3:
	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 10,
		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
		   "While in select mode, the Round button attempts to round the selected area by adding and deleting corner icons. If no area is selected the entire view area is rounded.");
	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 40 + HELP_BTN_HEIGHT,
		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
		   "While in select mode, the currently selected area is filled with the selected map icon.");
	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 70 + 2 * HELP_BTN_HEIGHT,
		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
		   "Hold down the Grow button to grow from existing blocks. If no blocks are drawn in the selected area, blocks will grow from the center in proportion to the selected width and height.");
	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 100 + 3 * HELP_BTN_HEIGHT,
		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
		   "The Neg. button reverses the filled blocks and spaces.");
	T_DrawText(helpwin, 10, 300 + 3 * HELP_BTN_HEIGHT, HELP_WIDTH - 20,
		   100, BKGR,
		   "XP-Mapedit was originally written by Aaron Averill\nPlease send any bugs, patches, enhancements or comments to the current maintainer at:\n\n" PACKAGE_BUGREPORT);
    }

}