Пример #1
0
void veh_interact::move_cursor (int dx, int dy)
{
    mvwputch (w_disp, cy+6, cx+6, cpart >= 0? veh->part_color (cpart) : c_black, special_symbol(cpart >= 0? veh->part_sym (cpart) : ' '));
    cx += dx;
    cy += dy;
    cpart = part_at (cx, cy);
    int vdx = -ddx - cy;
    int vdy = cx - ddy;
    int vx, vy;
    veh->coord_translate (vdx, vdy, vx, vy);
    int vehx = veh->global_x() + vx;
    int vehy = veh->global_y() + vy;
    bool obstruct = g->m.move_cost_ter_only (vehx, vehy) == 0;
    vehicle *oveh = g->m.veh_at (vehx, vehy);
    if (oveh && oveh != veh)
        obstruct = true;
    nc_color col = cpart >= 0? veh->part_color (cpart) : c_black;
    mvwputch (w_disp, cy+6, cx+6, obstruct? red_background(col) : hilite(col),
                      special_symbol(cpart >= 0? veh->part_sym (cpart) : ' '));
    wrefresh (w_disp);
    werase (w_parts);
    veh->print_part_desc (w_parts, 0, winw2, cpart, -1);
    wrefresh (w_parts);

    can_mount.clear();
    has_mats.clear();
    if (!obstruct)
        for (int i = 1; i < num_vparts; i++)
        {
            if (veh->can_mount (vdx, vdy, (vpart_id) i))
                can_mount.push_back (i);
        }
    need_repair.clear();
    parts_here.clear();
    ptank = -1;
    if (cpart >= 0)
    {
        parts_here = veh->internal_parts(cpart);
        parts_here.insert (parts_here.begin(), cpart);
        for (int i = 0; i < parts_here.size(); i++)
        {
            int p = parts_here[i];
            if (veh->parts[p].hp < veh->part_info(p).durability)
                need_repair.push_back (i);
            if (veh->part_flag(p, vpf_fuel_tank) && veh->parts[p].amount < veh->part_info(p).size)
                ptank = p;
        }
    }
    has_fuel = ptank >= 0? g->pl_refill_vehicle(*veh, ptank, true) : false;
    werase (w_msg);
    wrefresh (w_msg);
    display_mode (' ');
}
Пример #2
0
status_t
Rage128_SetDisplayMode(const DisplayModeEx& mode)
{
	// The code to actually configure the display.
	// All the error checking must be done in ProposeDisplayMode(),
	// and assume that the mode values we get here are acceptable.

	DisplayParams params;		// where computed parameters are saved

	if (gInfo.sharedInfo->displayType == MT_VGA) {
		// Chip is connected to a monitor via a VGA connector.

		if ( ! CalculateCrtcRegisters(mode, params))
			return B_BAD_VALUE;

		if ( ! CalculatePLLRegisters(mode, params))
			return B_BAD_VALUE;

		if ( ! CalculateDDARegisters(mode, params))
			return B_BAD_VALUE;

		SetRegisters(params);

	} else {
		// Chip is connected to a laptop LCD monitor; or via a DVI interface.

		uint16 vesaMode = GetVesaModeNumber(display_mode(mode), mode.bitsPerPixel);
		if (vesaMode == 0)
			return B_BAD_VALUE;

		if (ioctl(gInfo.deviceFileDesc, ATI_SET_VESA_DISPLAY_MODE,
				&vesaMode, sizeof(vesaMode)) != B_OK)
			return B_ERROR;
	}

	Rage128_AdjustFrame(mode);

	// Initialize the palette so that color depths > 8 bits/pixel will display
	// the correct colors.

	// Select primary monitor and enable 8-bit color.
	OUTREGM(R128_DAC_CNTL, R128_DAC_8BIT_EN,
		R128_DAC_PALETTE_ACC_CTL | R128_DAC_8BIT_EN);
	OUTREG8(R128_PALETTE_INDEX, 0);		// set first color index

	for (int i = 0; i < 256; i++)
		OUTREG(R128_PALETTE_DATA, (i << 16) | (i << 8) | i );

	Rage128_EngineInit(mode);

	return B_OK;
}
Пример #3
0
status_t
Mach64_SetDisplayMode(const DisplayModeEx& mode)
{
	// The code to actually configure the display.
	// All the error checking must be done in ProposeDisplayMode(),
	// and assume that the mode values we get here are acceptable.

	SharedInfo& si = *gInfo.sharedInfo;

	if (si.displayType == MT_VGA) {
		// Chip is connected to a monitor via a VGA connector.

		SetCrtcRegisters(mode);
		SetClockRegisters(mode);

		if (si.chipType >= MACH64_264VTB)
			SetDSPRegisters(mode);

	} else {
		// Chip is connected to a laptop LCD monitor; or via a DVI interface.

		uint16 vesaMode = GetVesaModeNumber(display_mode(mode), mode.bitsPerPixel);
		if (vesaMode == 0)
			return B_BAD_VALUE;

		status_t status = ioctl(gInfo.deviceFileDesc, ATI_SET_VESA_DISPLAY_MODE,
				&vesaMode, sizeof(vesaMode));
		if (status != B_OK)
			return status;
	}

	Mach64_AdjustFrame(mode);

	// Initialize the palette so that the various color depths will display
	// the correct colors.

	OUTREGM(DAC_CNTL, DAC_8BIT_EN, DAC_8BIT_EN);
	OUTREG8(DAC_MASK, 0xff);
	OUTREG8(DAC_W_INDEX, 0);		// initial color index

	for (int i = 0; i < 256; i++) {
		OUTREG8(DAC_DATA, i);
		OUTREG8(DAC_DATA, i);
		OUTREG8(DAC_DATA, i);
	}

	Mach64_EngineInit(mode);

	return B_OK;
}
Пример #4
0
__interrupt void Port_1(void)
{
  if((P3IN & 0x20))                         // /Charge=1; battery, Blink Red
  {
    BSP_TURN_ON_LED1();
    __delay_cycles(10000);
    BSP_TURN_OFF_LED1();
  }
  else                                      // /Charge=0; Solar, blink green
  {
    BSP_TURN_ON_LED2();
    __delay_cycles(10000);
    BSP_TURN_OFF_LED2();
  }

  // If successful link, change timer state.
  if(status == status_six || status == status_five)
  {
    if(timer_state >= timer_state_6)        // If transmit time is == 6,
    {                                       // Set timer_state = 1
      timer_state = timer_state_1;
      display_mode();                       // Change GUI display time
    }
    else
    {
      timer_state++;                        // Change transmit time state
      display_mode();                       // Change GUI display time
    }
    if(in_delay)                            // If in transmit delay, exit and
    {                                       // send a new packet with new time
      __bic_SR_register_on_exit(LPM4_bits); // Clear LPM3 bit from 0(SR)
    }
  }
  __delay_cycles(150000);                   // Debounce software delay
  while(!(P1IN & 0x04));                    // Loop if button is still pressed
  P1IFG &= ~0x04;                           // P1.2 IFG cleared key interuped
}
Пример #5
0
int main(void)
{
    setup();
    sei(); // Enable interrupts

    power_up_melody();

    while(1)
    {
        display_mode();

        if (input_button_pressed()) {
            _delay_ms(100);
            input_clear_button_pressed();
            game_start(DEFAULT_STARTING_LENGTH);
        }

        input_clear_button_pressed();
    }
}
Пример #6
0
/**
 * Moves the cursor on the vehicle editing window.
 * @param dx How far to move the cursor on the x-axis.
 * @param dy How far to move the cursor on the y-axis.
 */
void veh_interact::move_cursor (int dx, int dy)
{
    mvwputch (w_disp, cursor_y + 6, cursor_x + 6, cpart >= 0 ? veh->part_color (cpart) : c_black,
              special_symbol(cpart >= 0 ? veh->part_sym (cpart) : ' '));
    cursor_x += dx;
    cursor_y += dy;
    cpart = part_at (cursor_x, cursor_y);
    int vdx = -ddx - cursor_y;
    int vdy = cursor_x - ddy;
    int vx, vy;
    veh->coord_translate (vdx, vdy, vx, vy);
    int vehx = veh->global_x() + vx;
    int vehy = veh->global_y() + vy;
    bool obstruct = g->m.move_cost_ter_furn (vehx, vehy) == 0;
    vehicle *oveh = g->m.veh_at (vehx, vehy);
    if (oveh && oveh != veh)
    {
        obstruct = true;
    }
    nc_color col = cpart >= 0 ? veh->part_color (cpart) : c_black;
    mvwputch (w_disp, cursor_y + 6, cursor_x + 6, obstruct ? red_background(col) : hilite(col),
              special_symbol(cpart >= 0 ? veh->part_sym (cpart) : ' '));
    wrefresh (w_disp);
    werase (w_parts);
    veh->print_part_desc (w_parts, 0, winw2, cpart, -1);
    wrefresh (w_parts);

    can_mount.clear();
    if (!obstruct)
    {
        for (std::map<std::string, vpart_info>::iterator
                part_type_iterator = vehicle_part_types.begin();
                part_type_iterator != vehicle_part_types.end();
                ++part_type_iterator) {
            if (veh->can_mount (vdx, vdy, part_type_iterator->first))
            {
                can_mount.push_back (part_type_iterator->second);
            }
        }
    }
    need_repair.clear();
    parts_here.clear();
    ptank = NULL;
    wheel = NULL;
    if (cpart >= 0)
    {
        //Misleading, internal_parts actually returns all parts at that square
        parts_here = veh->internal_parts(cpart);
        parts_here.insert (parts_here.begin(), cpart);
        for (int i = 0; i < parts_here.size(); i++)
        {
            int p = parts_here[i];
            if (veh->parts[p].hp < veh->part_info(p).durability)
            {
                need_repair.push_back (i);
            }
            if (veh->part_flag(p, "FUEL_TANK") && veh->parts[p].amount < veh->part_info(p).size)
            {
                ptank = &veh->parts[p];
            }
            if (veh->part_flag(p, "WHEEL") && veh->parts[p].amount < veh->part_info(p).size)
            {
                wheel = &veh->parts[p];
            }
        }
    }
    has_fuel = ptank != NULL ? g->refill_vehicle_part(*veh, ptank, true) : false;
    werase (w_msg);
    wrefresh (w_msg);
    display_mode (' ');
}
Пример #7
0
/**
 * Creates a veh_interact window based on the given parameters.
 * @param v The vehicle the player is interacting with.
 * @param x The x-coordinate of the square the player is 'e'xamining.
 * @param y The y-coordinate of the square the player is 'e'xamining.
 */
void veh_interact::exec (game *gm, vehicle *v, int x, int y)
{
    g = gm;
    veh = v;
    //        x1      x2
    // y1 ----+------+--
    //        |      |
    // y2 ----+------+
    //               |
    //               |
    winw1 = 12;
    winw2 = 35;
    winh1 = 3;
    winh2 = 12;
    winw12 = winw1 + winw2 + 1;
    winw3 = FULL_SCREEN_WIDTH - winw1 - winw2 - 2;
    winh3 = FULL_SCREEN_HEIGHT - winh1 - winh2 - 2;
    winh23 = winh2 + winh3 + 1;
    winx1 = winw1;
    winx2 = winw1 + winw2 + 1;
    winy1 = winh1;
    winy2 = winh1 + winh2 + 1;

    // changed FALSE value to 1, to keep w_border from starting at a negative x,y
    const int iOffsetX = (TERMX > FULL_SCREEN_WIDTH) ? (TERMX-FULL_SCREEN_WIDTH)/2 : 1;
    const int iOffsetY = (TERMY > FULL_SCREEN_HEIGHT) ? (TERMY-FULL_SCREEN_HEIGHT)/2 : 1;

    page_size = winh23;

    //               h   w    y     x
    WINDOW *w_border= newwin(FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH,  -1 + iOffsetY,    -1 + iOffsetX);
    w_grid  = newwin(FULL_SCREEN_HEIGHT -2, FULL_SCREEN_WIDTH-2,  iOffsetY,    iOffsetX);
    w_mode  = newwin(1,  FULL_SCREEN_WIDTH-2, iOffsetY,    iOffsetX);
    w_msg   = newwin(winh1 - 1, FULL_SCREEN_WIDTH-2, 1 + iOffsetY,    iOffsetX);
    w_disp  = newwin(winh2-1, winw1,  winy1 + 1 + iOffsetY, iOffsetX);
    w_parts = newwin(winh2-1, winw2,  winy1 + 1 + iOffsetY, winx1 + 1 + iOffsetX);
    w_stats = newwin(winh3-1, winw12, winy2 + iOffsetY, iOffsetX);
    w_list  = newwin(winh23, winw3, winy1 + 1 + iOffsetY, winx2 + 1 + iOffsetX);

    wborder(w_border, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
                      LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX );

    mvwputch(w_border, 16, 0, c_ltgray, LINE_XXXO); // |-
    mvwputch(w_border, 4, 0, c_ltgray, LINE_XXXO); // |-
    mvwputch(w_border, 4, FULL_SCREEN_WIDTH-1, c_ltgray, LINE_XOXX); // -|
    mvwputch(w_border, 24, 49, c_ltgray, LINE_XXOX);

    wrefresh(w_border);

    for (int i = 0; i < FULL_SCREEN_HEIGHT; i++)
    {
        mvwputch(w_grid, i, winx2, c_ltgray, i == winy1 || i == winy2-1? LINE_XOXX : LINE_XOXO);
        if (i >= winy1 && i < winy2) {
            mvwputch(w_grid, i, winx1, c_ltgray, LINE_XOXO);
        }
    }
    for (int i = 0; i < FULL_SCREEN_WIDTH; i++)
    {
        mvwputch(w_grid, winy1, i, c_ltgray,
                 i == winx1? LINE_OXXX : (i == winx2? LINE_OXXX : LINE_OXOX));
        if (i < winx2) {
            mvwputch(w_grid, winy2-1, i, c_ltgray, i == winx1? LINE_XXOX : LINE_OXOX);
        }
    }
    wrefresh(w_grid);

    crafting_inv = gm->crafting_inventory(&gm->u);

    int charges = static_cast<it_tool *>(g->itypes["welder"])->charges_per_use;
    int charges_crude = static_cast<it_tool *>(g->itypes["welder_crude"])->charges_per_use;
    has_wrench = crafting_inv.has_amount("wrench", 1) ||
        crafting_inv.has_amount("toolset", 1);
    has_hacksaw = crafting_inv.has_amount("hacksaw", 1) ||
        crafting_inv.has_amount("toolset", 1);
    has_welder = (crafting_inv.has_amount("welder", 1) &&
                  crafting_inv.has_charges("welder", charges)) ||
                  (crafting_inv.has_amount("welder_crude", 1) &&
                  crafting_inv.has_charges("welder_crude", charges_crude)) ||
                (crafting_inv.has_amount("toolset", 1) &&
                 crafting_inv.has_charges("toolset", charges/20));
    has_jack = crafting_inv.has_amount("jack", 1);
    has_siphon = crafting_inv.has_amount("hose", 1);

    has_wheel = crafting_inv.has_amount( "wheel", 1 ) ||
                crafting_inv.has_amount( "wheel_wide", 1 ) ||
                crafting_inv.has_amount( "wheel_bicycle", 1 ) ||
                crafting_inv.has_amount( "wheel_motorbike", 1 ) ||
                crafting_inv.has_amount( "wheel_small", 1 );

    display_stats ();
    display_veh   ();
    move_cursor (0, 0);
    bool finish = false;
    while (!finish)
    {
        char ch = input(); // See keypress.h
        int dx, dy;
        get_direction (dx, dy, ch);
        if (ch == KEY_ESCAPE || ch == 'q' )
        {
            finish = true;
        } 
        else
        {
            if (dx != -2 && (dx || dy) &&
                cursor_x + dx >= -6 && cursor_x + dx < 6 &&
                cursor_y + dy >= -6 && cursor_y + dy < 6)
            {
                move_cursor(dx, dy);
            }
            else
            {
                int mval = cant_do(ch);
                display_mode (ch);
                switch (ch)
                {
                    case 'i': do_install(mval); break;
                    case 'r': do_repair(mval);  break;
                    case 'f': do_refill(mval);  break;
                    case 'o': do_remove(mval);  break;
                    case 'e': do_rename(mval);  break;
                    case 's': do_siphon(mval);  break;
                    case 'c': do_tirechange(mval); break;
                    case 'd': do_drain(mval);  break;
                }
                if (sel_cmd != ' ')
                {
                    finish = true;
                }
                display_mode (' ');
            }
        }
    }
    werase(w_grid);
    werase(w_mode);
    werase(w_msg);
    werase(w_disp);
    werase(w_parts);
    werase(w_stats);
    werase(w_list);
    delwin(w_grid);
    delwin(w_mode);
    delwin(w_msg);
    delwin(w_disp);
    delwin(w_parts);
    delwin(w_stats);
    delwin(w_list);
    erase();
}
Пример #8
0
int main(int argc, char **argv)
{		
	int check_busy = 0;
	if (argc < 3)
		usage();

	//init spi oled
	init_spi_oled(argv[1]);

	argc-=2;
	argv+=2;

	while (argc >= 1) {
		const char *cmd = argv[0];
		int args = 0;
		if (strcmp(cmd, "-B") == 0) {
			check_busy = 0;
			args = 1;
			check_busy_flag3(atoi(argv[1]));
		}
		if (strcmp(cmd, "-b") == 0)
			check_busy = 1;
		if (check_busy)
			check_busy_flag();
		if (strcmp(cmd, "-f") == 0) {
			select_font(atoi(argv[1]));
			args = 1;
		}
		if (strcmp(cmd, "-e") == 0) {
			entry_mode_set(atoi(argv[1]), atoi(argv[2]));
			args = 2;
		}
		if (strcmp(cmd, "-m") == 0) {
			display_mode(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));
			args = 3;
		}
		if (strcmp(cmd, "-c") == 0)
			clear_display();
		if (strcmp(cmd, "-g") == 0) {
			set_ddram_address(atoi(argv[1]) * 0x40 + atoi(argv[2]));
			args = 2;
		}
		if (strcmp(cmd, "-a") == 0) {
			set_ddram_address(strtoul(argv[1], NULL, 0));
			args = 1;
		}
		if (strcmp(cmd, "-A") == 0) {
			set_cgram_address(strtoul(argv[1], NULL, 0));
			args = 1;
		}
		if (strcmp(cmd, "-w") == 0) {
			write_data(strtoul(argv[1], NULL, 0));
			args = 1;
		}
		if (strcmp(cmd, "-h") == 0)
			return_home();
		if (strcmp(cmd, "-C") == 0) {
			shift_cursor(*argv[1] == 'r');
			args = 1;
		}
		if (strcmp(cmd, "-S") == 0) {
			shift_display(*argv[1] == 'r');
			args = 1;
		}
		if (strcmp(cmd, "-t") == 0) {
			write_str(argv[1]);
			args = 1;
		}
		if (*cmd != '-')
			write_str(cmd);
		check_busy = 1;
		argc -= 1 + args;
		argv += 1 + args;
	}
}
Пример #9
0
void veh_interact::exec (game *gm, vehicle *v, int x, int y)
{
    g = gm;
    veh = v;
    ex = x;
    ey = y;
    //        x1      x2
    // y1 ----+------+--
    //        |      |
    // y2 ----+------+
    //               |
    //               |
    winw1 = 12;
    winw2 = 35;
    winh1 = 3;
    winh2 = 12;
    winw12 = winw1 + winw2 + 1;
    winw3 = 80 - winw1 - winw2 - 2;
    winh3 = 25 - winh1 - winh2 - 2;
    winh23 = winh2 + winh3 + 1;
    winx1 = winw1;
    winx2 = winw1 + winw2 + 1;
    winy1 = winh1;
    winy2 = winh1 + winh2 + 1;

    page_size = winh23;
    //               h   w    y     x
    w_grid  = newwin(25, 80,  0,    0);
    w_mode  = newwin(1,  80, 0,    0);
    w_msg   = newwin(winh1 - 1, 80, 1,    0);
    w_disp  = newwin(winh2, winw1,  winy1 + 1, 0);
    w_parts = newwin(winh2, winw2,  winy1 + 1, winx1 + 1);
    w_stats = newwin(winh3, winw12, winy2 + 1, 0);
    w_list  = newwin(winh23, winw3, winy1 + 1, winx2 + 1);

    for (int i = 0; i < 25; i++)
    {
        mvwputch(w_grid, i, winx2, c_ltgray, i == winy1 || i == winy2? LINE_XOXX : LINE_XOXO);
        if (i >= winy1 && i < winy2)
            mvwputch(w_grid, i, winx1, c_ltgray, LINE_XOXO);
    }
    for (int i = 0; i < 80; i++)
    {
        mvwputch(w_grid, winy1, i, c_ltgray, i == winx1? LINE_OXXX : (i == winx2? LINE_OXXX : LINE_OXOX));
        if (i < winx2)
            mvwputch(w_grid, winy2, i, c_ltgray, i == winx1? LINE_XXOX : LINE_OXOX);
    }
    wrefresh(w_grid);

    crafting_inv = gm->crafting_inventory();

    int charges = ((it_tool *) g->itypes["welder"])->charges_per_use;
    has_wrench = crafting_inv.has_amount("wrench", 1) ||
                 crafting_inv.has_amount("toolset", 1);
    has_hacksaw = crafting_inv.has_amount("hacksaw", 1) ||
                  crafting_inv.has_amount("toolset", 1);
    has_welder = (crafting_inv.has_amount("welder", 1) &&
                  crafting_inv.has_charges("welder", charges)) ||
                 (crafting_inv.has_amount("toolset", 1) &&
                 crafting_inv.has_charges("toolset", charges/5));

    display_stats ();
    display_veh   ();
    move_cursor (0, 0);
    bool finish = false;
    while (!finish)
    {
        char ch = input(); // See keypress.h
        int dx, dy;
        get_direction (gm, dx, dy, ch);
        if (ch == KEY_ESCAPE)
            finish = true;
        else
        if (dx != -2 && (dx || dy) &&
            cx + dx >= -6 && cx + dx < 6 &&
            cy + dy >= -6 && cy + dy < 6)
            move_cursor(dx, dy);
        else
        {
            int mval = cant_do(ch);
            display_mode (ch);
            switch (ch)
            {
            case 'i': do_install(mval); break;
            case 'r': do_repair(mval);  break;
            case 'f': do_refill(mval);  break;
            case 'o': do_remove(mval);  break;
            case 'e': do_rename(mval);  break;
            default:;
            }
            if (sel_cmd != ' ')
                finish = true;
            display_mode (' ');
        }
    }
    werase(w_grid);
    werase(w_mode);
    werase(w_msg);
    werase(w_disp);
    werase(w_parts);
    werase(w_stats);
    werase(w_list);
    delwin(w_grid);
    delwin(w_mode);
    delwin(w_msg);
    delwin(w_disp);
    delwin(w_parts);
    delwin(w_stats);
    delwin(w_list);
    erase();
}
Пример #10
0
/**
 * Creates a veh_interact window based on the given parameters.
 * @param v The vehicle the player is interacting with.
 * @param x The x-coordinate of the square the player is 'e'xamining.
 * @param y The y-coordinate of the square the player is 'e'xamining.
 */
void veh_interact::exec (game *gm, vehicle *v, int x, int y)
{
    veh = v;
    //        winw1   winw2   winw3
    //  winh1       |       |
    //        ------+-------+------
    //  winh2       |       |
    //        ------+-------+------
    //  winh3       |       |
    //
    // +-------------------------+
    // |         w_mode          |
    // |         w_msg           |
    // +-------+---------+-------+
    // |w_disp | w_parts | w_list|
    // +-------+---------+-------+
    // |         w_stats         |
    // +-------------------------+
    int winw1 = 12;
    int winw2 = 35;
    int winh1 = 3;
    int winh2 = 13;
    int winw3 = FULL_SCREEN_WIDTH - winw1 - winw2 - 4;
    int winh3 = FULL_SCREEN_HEIGHT - winh1 - winh2 - 2;
    int winx1 = winw1;
    int winx2 = winw1 + winw2 + 1;
    int winy1 = winh1;
    int winy2 = winh1 + winh2 + 1;

    mode_h = 1;
    mode_w = FULL_SCREEN_WIDTH - 2;
    msg_h = winh1 - 1;
    msg_w = FULL_SCREEN_WIDTH - 2;
    disp_h = winh2 - 1;
    disp_w = winw1;
    parts_h = winh2 - 1;
    parts_w = winw2;
    stats_h = winh3 - 1;
    stats_w = FULL_SCREEN_WIDTH - 2;
    list_h = winh2 - 1;
    list_w = winw3;

    const int iOffsetX = 1 + ((TERMX > FULL_SCREEN_WIDTH) ? (TERMX-FULL_SCREEN_WIDTH)/2 : 0);
    const int iOffsetY = 1 + ((TERMY > FULL_SCREEN_HEIGHT) ? (TERMY-FULL_SCREEN_HEIGHT)/2 : 0);

    page_size = list_h;

    //               h   w    y     x
    WINDOW *w_border = newwin( FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, -1 + iOffsetY, -1 + iOffsetX );
    w_grid  = newwin( FULL_SCREEN_HEIGHT - 2, FULL_SCREEN_WIDTH - 2, iOffsetY, iOffsetX );
    w_mode  = newwin( mode_h,  mode_w,   iOffsetY,                           iOffsetX );
    w_msg   = newwin( msg_h,   msg_w,    mode_h + iOffsetY,                  iOffsetX );
    w_disp  = newwin( disp_h,  disp_w,   mode_h + msg_h + 1 + iOffsetY,  iOffsetX );
    w_parts = newwin( parts_h, parts_w,  mode_h + msg_h + 1 + iOffsetY,  disp_w + 1 + iOffsetX );
    w_list  = newwin( list_h,  list_w,   mode_h + msg_h + 1 + iOffsetY,
                      disp_w + 1 + parts_w + 1 + iOffsetX );
    w_stats = newwin( stats_h, stats_w,  mode_h + msg_h + 1 + disp_h + 1 + iOffsetY, iOffsetX );


    wborder(w_border, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
                      LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX );

    mvwputch(w_border, mode_h + msg_h + 1 + disp_h + 1, 0, c_ltgray, LINE_XXXO); // |-
    mvwputch(w_border, mode_h + msg_h + 1, 0, c_ltgray, LINE_XXXO); // |-
    mvwputch(w_border, mode_h + msg_h + 1 + disp_h + 1, FULL_SCREEN_WIDTH - 1, c_ltgray, LINE_XOXX);
    mvwputch(w_border, mode_h + msg_h + 1, FULL_SCREEN_WIDTH - 1, c_ltgray, LINE_XOXX);

    wrefresh(w_border);

    // Two lines dividing the three middle sections.
    for (int i = winy1; i < winy2; i++) {
        mvwputch(w_grid, i, winx2, c_ltgray, LINE_XOXO);
        mvwputch(w_grid, i, winx1, c_ltgray, LINE_XOXO);
    }
    // Two lines dividing the vertical menu sections.
    for (int i = 0; i < FULL_SCREEN_WIDTH; i++) {
        mvwputch( w_grid, winy1, i, c_ltgray, LINE_OXOX );
        mvwputch( w_grid, winy2-1, i, c_ltgray, LINE_OXOX );
    }
    // Fix up the line intersections.
    mvwputch( w_grid, winy1, winx1, c_ltgray, LINE_OXXX );
    mvwputch( w_grid, winy1, winx2, c_ltgray, LINE_OXXX );
    mvwputch( w_grid, winy2 - 1, winx1, c_ltgray, LINE_XXOX );
    mvwputch( w_grid, winy2 - 1, winx2, c_ltgray, LINE_XXOX );

    wrefresh(w_grid);

    crafting_inv = g->crafting_inventory(&g->u);

    int charges = static_cast<it_tool *>(g->itypes["welder"])->charges_per_use;
    int charges_crude = static_cast<it_tool *>(g->itypes["welder_crude"])->charges_per_use;
    has_wrench = crafting_inv.has_amount("wrench", 1) ||
        crafting_inv.has_amount("toolset", 1);
    has_hacksaw = crafting_inv.has_amount("hacksaw", 1) ||
        crafting_inv.has_amount("toolset", 1);
    has_welder = (crafting_inv.has_amount("welder", 1) &&
                  crafting_inv.has_charges("welder", charges)) ||
                  (crafting_inv.has_amount("welder_crude", 1) &&
                  crafting_inv.has_charges("welder_crude", charges_crude)) ||
                (crafting_inv.has_amount("toolset", 1) &&
                 crafting_inv.has_charges("toolset", charges/20));
    has_jack = crafting_inv.has_amount("jack", 1);
    has_siphon = crafting_inv.has_amount("hose", 1);

    has_wheel = crafting_inv.has_amount( "wheel", 1 ) ||
                crafting_inv.has_amount( "wheel_wide", 1 ) ||
                crafting_inv.has_amount( "wheel_bicycle", 1 ) ||
                crafting_inv.has_amount( "wheel_motorbike", 1 ) ||
                crafting_inv.has_amount( "wheel_small", 1 );

    display_stats ();
    display_veh   ();
    move_cursor (0, 0);
    bool finish = false;
    while (!finish)
    {
        char ch = input(); // See keypress.h
        int dx, dy;
        get_direction (dx, dy, ch);
        if (ch == KEY_ESCAPE || ch == 'q' ) {
            finish = true;
        } else {
            if (dx != -2 && (dx || dy) &&
                cursor_x + dx >= -6 && cursor_x + dx < 6 &&
                cursor_y + dy >= -6 && cursor_y + dy < 6)
            {
                move_cursor(dx, dy);
            }
            else
            {
                int mval = cant_do(ch);
                display_mode (ch);
                switch (ch)
                {
                    case 'i': do_install(mval); break;
                    case 'r': do_repair(mval);  break;
                    case 'f': do_refill(mval);  break;
                    case 'o': do_remove(mval);  break;
                    case 'e': do_rename(mval);  break;
                    case 's': do_siphon(mval);  break;
                    case 'c': do_tirechange(mval); break;
                    case 'd': do_drain(mval);  break;
                }
                if (sel_cmd != ' ')
                {
                    finish = true;
                }
                display_mode (' ');
            }
        }
    }
    werase(w_grid);
    werase(w_mode);
    werase(w_msg);
    werase(w_disp);
    werase(w_parts);
    werase(w_stats);
    werase(w_list);
    delwin(w_grid);
    delwin(w_mode);
    delwin(w_msg);
    delwin(w_disp);
    delwin(w_parts);
    delwin(w_stats);
    delwin(w_list);
    erase();
}
Пример #11
0
/**
 * Moves the cursor on the vehicle editing window.
 * @param dx How far to move the cursor on the x-axis.
 * @param dy How far to move the cursor on the y-axis.
 */
void veh_interact::move_cursor (int dx, int dy)
{
    mvwputch (w_disp, 6, 6, cpart >= 0 ? veh->part_color (cpart) : c_black,
              special_symbol(cpart >= 0 ? veh->part_sym (cpart) : ' '));
    ddx += dy;
    ddy -= dx;
    display_veh();
    cpart = part_at (0, 0);
    int vdx = -ddx;
    int vdy = -ddy;
    int vx, vy;
    veh->coord_translate (vdx, vdy, vx, vy);
    int vehx = veh->global_x() + vx;
    int vehy = veh->global_y() + vy;
    bool obstruct = g->m.move_cost_ter_furn (vehx, vehy) == 0;
    vehicle *oveh = g->m.veh_at (vehx, vehy);
    if (oveh && oveh != veh) {
        obstruct = true;
    }
    nc_color col = cpart >= 0 ? veh->part_color (cpart) : c_black;
    mvwputch (w_disp, 6, 6, obstruct ? red_background(col) : hilite(col),
              special_symbol(cpart >= 0 ? veh->part_sym (cpart) : ' '));
    wrefresh (w_disp);
    werase (w_parts);
    veh->print_part_desc (w_parts, 0, parts_w, cpart, -1);
    wrefresh (w_parts);

    can_mount.clear();
    if (!obstruct) {
        for (std::map<std::string, vpart_info>::iterator
             part_type_iterator = vehicle_part_types.begin();
             part_type_iterator != vehicle_part_types.end();
             ++part_type_iterator) {
            if (veh->can_mount (vdx, vdy, part_type_iterator->first)) {
                can_mount.push_back (part_type_iterator->second);
            }
        }
    }

    //Only build the wheel list once
    if(wheel_types.empty()) {
        for (std::map<std::string, vpart_info>::iterator
             part_type_iterator = vehicle_part_types.begin();
             part_type_iterator != vehicle_part_types.end();
             ++part_type_iterator) {
            if (part_type_iterator->second.has_flag("WHEEL")) {
                wheel_types.push_back (part_type_iterator->second);
            }
        }
    }

    need_repair.clear();
    parts_here.clear();
    ptank = NULL;
    wheel = NULL;
    if (cpart >= 0) {
        parts_here = veh->parts_at_relative(veh->parts[cpart].mount_dx, veh->parts[cpart].mount_dy);
        for (int i = 0; i < parts_here.size(); i++) {
            int p = parts_here[i];
            if (veh->parts[p].hp < veh->part_info(p).durability) {
                need_repair.push_back (i);
            }
            if (veh->part_flag(p, "FUEL_TANK") && veh->parts[p].amount < veh->part_info(p).size) {
                ptank = &veh->parts[p];
            }
            if (veh->part_flag(p, "WHEEL")) {
                wheel = &veh->parts[p];
            }
        }
    }
    has_fuel = ptank != NULL ? g->refill_vehicle_part(*veh, ptank, true) : false;
    werase (w_msg);
    wrefresh (w_msg);
    display_mode (' ');
}