예제 #1
0
static uint32 ConvertAllegroKeyIntoMy(WChar *character)
{
	int scancode;
	int unicode = ureadkey(&scancode);

	const VkMapping *map;
	uint key = 0;

	for (map = _vk_mapping; map != endof(_vk_mapping); ++map) {
		if ((uint)(scancode - map->vk_from) <= map->vk_count) {
			key = scancode - map->vk_from + map->map_to;
			break;
		}
	}

	if (key_shifts & KB_SHIFT_FLAG) key |= WKC_SHIFT;
	if (key_shifts & KB_CTRL_FLAG)  key |= WKC_CTRL;
	if (key_shifts & KB_ALT_FLAG)   key |= WKC_ALT;
#if 0
	DEBUG(driver, 0, "Scancode character pressed %u", scancode);
	DEBUG(driver, 0, "Unicode character pressed %u", unicode);
#endif

	*character = unicode;
	return key;
}
예제 #2
0
파일: test.cpp 프로젝트: Fomka/ufo2000
int main(int argc, char *argv[])
{
    int i, idx, color_depth = -1;
    if (argc >= 2) color_depth = atoi(argv[1]);
    if (color_depth != 16 && color_depth != 24 && color_depth != 32) {
        printf("Usage: test [color_depth]\n");
        return -1;
    }

    allegro_init();
    install_keyboard();
    set_color_depth(color_depth);
    if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0) != 0) return -1;
    backbuffer = create_bitmap(SCREEN_W, SCREEN_H);
    BITMAP *backbuffer1 = create_bitmap(SCREEN_W, SCREEN_H);
    BITMAP *backbuffer2 = create_bitmap(SCREEN_W, SCREEN_H);

    // Load fire sprites (alpha transparency used)
    fire_ex = load_bitmap_alpha("fire.tga", true);
    for (int idx = 0; idx < SPRITE_COUNT; idx++) {
        i = idx % 8;
        fire_ex_bitmaps[idx] = create_sub_bitmap(fire_ex, (i % 4) * 33, (i / 4) * 41, 32, 40);
        fire_ex_rle_sprites[idx] = get_rle_sprite(fire_ex_bitmaps[i]);
        fire_ex_alpha_sprites[idx] = get_alpha_sprite(fire_ex_bitmaps[i]);
    }

    // Load fire sprites (no alpha transparency used)
    fire = load_bitmap_alpha("fire.tga", false);
    for (int idx = 0; idx < SPRITE_COUNT; idx++) {
        i = idx % 8;
        fire_bitmaps[idx] = create_sub_bitmap(fire, (i % 4) * 33, (i / 4) * 41, 32, 40);
        fire_rle_sprites[idx] = get_rle_sprite(fire_bitmaps[i]);
        fire_alpha_sprites[idx] = get_alpha_sprite(fire_bitmaps[i]);
    }

    // Load explosion sprites (alpha transparency used)
    explosion = load_bitmap_alpha("explosion.tga", true);
    for (i = 0; i < 10; i++) {
        explosion_bitmaps[i] = create_sub_bitmap(explosion, 0, 179 * i, 256, 178);
        explosion_rle_sprites[i] = get_rle_sprite(explosion_bitmaps[i]);
        explosion_alpha_sprites[i] = get_alpha_sprite(explosion_bitmaps[i]);
    }

    printf("---\n");
    printf("explosion sprites per second (spritelib)      = %.1lf\n", run_test(backbuffer1, test_explosion_spritelib));
    printf("explosion sprites per second (allegro rle)    = %.1lf\n", run_test(backbuffer2, test_explosion_allegro_rle));
    printf("explosion sprites per second (allegro bitmap) = %.1lf\n", run_test(backbuffer2, test_explosion_allegro));
    if (!compare_bitmaps(backbuffer1, backbuffer2)) printf("Error: results do not match!\n");
    TESTS_COUNT = 500000;
    printf("---\n");
    printf("normal fire sprites per second (spritelib)    = %.1lf\n", run_test(backbuffer1, test_fire_spritelib));
    printf("normal fire sprites per second (allegro rle)  = %.1lf\n", run_test(backbuffer2, test_fire_allegro_rle));
    if (!compare_bitmaps(backbuffer1, backbuffer2)) printf("Error: results do not match!\n");
    printf("---\n");
    printf("lit fire sprites per second (spritelib)       = %.1lf\n", run_test(backbuffer1, test_fire_lit_spritelib));
    printf("lit fire sprites per second (allegro rle)     = %.1lf\n", run_test(backbuffer2, test_fire_lit_allegro_rle));
    if (!compare_bitmaps(backbuffer1, backbuffer2)) printf("Error: results do not match!\n");
    printf("---\n");
    printf("alpha fire sprites per second (spritelib)     = %.1lf\n", run_test(backbuffer1, test_fire_alpha_spritelib));
    printf("alpha fire sprites per second (allegro rle)   = %.1lf\n", run_test(backbuffer2, test_fire_alpha_allegro_rle));
    if (!compare_bitmaps(backbuffer1, backbuffer2)) printf("Error: results do not match!\n");

    i = 0;
    while (true) {
        if (keypressed()) {
            int scancode;
            ureadkey(&scancode);
            if (scancode == KEY_ESC) break;
        }
        clear_to_color(backbuffer, makecol(64, 64, 64));
        int brightness = (i % 512) - 256;
        if (brightness < 0) brightness = -brightness;
        draw_alpha_sprite(backbuffer, explosion_alpha_sprites[i % 10], 0, 0, brightness);
        draw_alpha_sprite(backbuffer, fire_alpha_sprites[i % 4], 300, 0, brightness);
        draw_alpha_sprite(backbuffer, fire_alpha_sprites[(i % 4) + 4], 300, 50, 256 - brightness);
        draw_alpha_sprite(backbuffer, fire_alpha_sprites[i % 4], 300, 100, 250);
        draw_alpha_sprite(backbuffer, fire_alpha_sprites[(i % 4) + 4], 300, 150, 250);
        blit(backbuffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
        rest(100);
        i++;
    }

    destroy_bitmap(backbuffer);
    destroy_bitmap(backbuffer1);
    destroy_bitmap(backbuffer2);

    for (idx = 0; idx < SPRITE_COUNT; idx++) {
        destroy_bitmap(fire_ex_bitmaps[idx]);
        destroy_rle_sprite(fire_ex_rle_sprites[idx]);
        destroy_alpha_sprite(fire_ex_alpha_sprites[idx]);
        destroy_bitmap(fire_bitmaps[idx]);
        destroy_rle_sprite(fire_rle_sprites[idx]);
        destroy_alpha_sprite(fire_alpha_sprites[idx]);
    }
    destroy_bitmap(fire_ex);
    destroy_bitmap(fire);

    // Load explosion sprites (alpha transparency used)
    for (i = 0; i < 10; i++) {
        destroy_bitmap(explosion_bitmaps[i]);
        destroy_rle_sprite(explosion_rle_sprites[i]);
        destroy_alpha_sprite(explosion_alpha_sprites[i]);
    }
    destroy_bitmap(explosion);

    allegro_exit();

    return 0;
}
예제 #3
0
static void test_key_map(void)
{
   int i, k, u;
   static int key_was_pressed[KEY_MAX + 1] = {0};
   static int key_is_pressed[KEY_MAX + 1] = {0};
   static char *welcome[] = {
      "Key that is pressed now is marked with red",
      "Key that was pressed is marked with yellow",
      "Press mouse button or Escape to exit test",
      0
   };

   /* Clear screen and output prompt.  */
   clear_to_color(screen, white);
   for (i = 0; welcome[i] != 0; i++)
      textout_ex(screen, font, welcome[i], 8, i * 8 + 8, black, -1);

   clear_to_color(screen, white);
   for (i = 0; i < KEY_MAX; i++)
      textprintf_ex(screen, font, 32 + (i % 4) * 160,
	      32 + (i / 4) * 14, black, -1, "%s", scancode_to_name (i));
   do {
      poll_keyboard();
      poll_mouse();
   }
   while ((key[KEY_ESC]) || (mouse_b));

   do {
      
      while (keypressed()) {
	 u = ureadkey (&k);
	 textprintf_centre_ex (screen, font, SCREEN_W / 2, 8,
	    red, white, ">   %c   <", u);
      }
      
      poll_keyboard();
      poll_mouse();

      for (i = 0; i < KEY_MAX; i++) {
	 if (key[i])
	    key_was_pressed[i] = key_is_pressed[i] = 1;
	 else
	    key_is_pressed[i] = 0;
      }

      for (i = 0; i < KEY_MAX; i++) {
	 int x = 16 + (i % 4) * 160;
	 int y = 32 + (i / 4) * 14;

	 if (key_is_pressed[i])
	    rectfill(screen, x, y, x + 7, y + 7, red);
	 else if (key_was_pressed[i])
	    rectfill(screen, x, y, x + 7, y + 7, yellow);
	 else
	    rectfill(screen, x, y, x + 7, y + 7, white);
      }

      rest(1);
   }
   while ((!key[KEY_ESC]) && (!mouse_b));

   do {
      poll_keyboard();
      poll_mouse();
   }
   while ((key[KEY_ESC]) || (mouse_b));

   clear_keybuf();
}
예제 #4
0
    void OpenLayerInput::pollKeyInput()
    {
        int unicode, scancode;

        if (keyboard_needs_poll())
        {
            poll_keyboard();
        }

        while (keypressed())
        {
            unicode = ureadkey(&scancode);
            Key keyObj = convertToKey(scancode, unicode);

            KeyInput keyInput(keyObj, KeyInput::Pressed);

            keyInput.setNumericPad(isNumericPad(scancode));
            keyInput.setShiftPressed(key_shifts & KB_SHIFT_FLAG);
            keyInput.setAltPressed(key_shifts & KB_ALT_FLAG);
            keyInput.setControlPressed(key_shifts & KB_CTRL_FLAG);
#ifdef KB_COMMAND_FLAG
            keyInput.setMetaPressed(key_shifts & (KB_COMMAND_FLAG |
                                                  KB_LWIN_FLAG |
                                                  KB_RWIN_FLAG));
#else
            keyInput.setMetaPressed(key_shifts & (KB_LWIN_FLAG |
                                                  KB_RWIN_FLAG));
#endif


            mKeyQueue.push(keyInput);

            mPressedKeys[scancode] = keyInput;
        }

        if (key[KEY_ALT] && mPressedKeys.find(KEY_ALT) == mPressedKeys.end())
        {
            KeyInput keyInput(convertToKey(KEY_ALT, 0), KeyInput::Pressed);
            mKeyQueue.push(keyInput);
            mPressedKeys[KEY_ALT] = keyInput;
        }

        if (key[KEY_ALTGR] && mPressedKeys.find(KEY_ALTGR) == mPressedKeys.end())
        {
            KeyInput keyInput(convertToKey(KEY_ALTGR, 0), KeyInput::Pressed);
            mKeyQueue.push(keyInput);
            mPressedKeys[KEY_ALTGR] = keyInput;
        }

        if (key[KEY_LSHIFT] && mPressedKeys.find(KEY_LSHIFT) == mPressedKeys.end())
        {
            KeyInput keyInput(convertToKey(KEY_LSHIFT, 0), KeyInput::Pressed);
            mKeyQueue.push(keyInput);
            mPressedKeys[KEY_LSHIFT] = keyInput;
        }
    
        if (key[KEY_RSHIFT] && mPressedKeys.find(KEY_RSHIFT) == mPressedKeys.end())
        {
            KeyInput keyInput(convertToKey(KEY_RSHIFT, 0), KeyInput::Pressed);
            mKeyQueue.push(keyInput);
            mPressedKeys[KEY_RSHIFT] = keyInput;
        }
		
        if (key[KEY_LCONTROL] && mPressedKeys.find(KEY_LCONTROL) == mPressedKeys.end())
        {
            KeyInput keyInput(convertToKey(KEY_LCONTROL, 0), KeyInput::Pressed);
            mKeyQueue.push(keyInput);
            mPressedKeys[KEY_LCONTROL] = keyInput;
        }

        if (key[KEY_RCONTROL] && mPressedKeys.find(KEY_RCONTROL) == mPressedKeys.end())
        {
            KeyInput keyInput(convertToKey(KEY_RCONTROL, 0), KeyInput::Pressed);
            mKeyQueue.push(keyInput);
            mPressedKeys[KEY_RCONTROL] = keyInput;
        }

        // Check for released keys
        std::map<int, KeyInput>::iterator iter, tempIter;
        for (iter = mPressedKeys.begin(); iter != mPressedKeys.end(); )
        {
            if (!key[iter->first])
            {
                KeyInput keyInput(iter->second.getKey(), KeyInput::Released);
                keyInput.setNumericPad(iter->second.isNumericPad());
                keyInput.setShiftPressed(iter->second.isShiftPressed());
                keyInput.setAltPressed(iter->second.isAltPressed());
                keyInput.setControlPressed(iter->second.isControlPressed());

                mKeyQueue.push(keyInput);

                tempIter = iter;
                iter++;
                mPressedKeys.erase(tempIter);
            }
            else
            {
                iter++;
            }
        }
    }
예제 #5
0
/* handle the test command */
int tester()
{
   char buf[256];
   int a, i;

   show_mouse(NULL);

   acquire_screen();
   clear_to_color(screen, palette_color[8]);

   for (i=0; i<KEY_MAX; i++)
      textout_ex(screen, font, scancode_to_name(i), 32+(i%4)*160, 60+(i/4)*10, palette_color[255], palette_color[8]);

   release_screen();

   do {
      poll_keyboard();
      poll_mouse();
   } while ((key[KEY_ESC]) || (mouse_b));

   do {
      poll_keyboard();
      poll_mouse();

      acquire_screen();

      for (i=0; i<KEY_MAX; i++)
	 textout_ex(screen, font, key[i] ? "*" : " ", 16+(i%4)*160, 60+(i/4)*10, palette_color[255], palette_color[8]);

      buf[0] = 0;

      if (key_shifts & KB_SHIFT_FLAG)
	 strcat(buf, "shift ");

      if (key_shifts & KB_CTRL_FLAG)
	 strcat(buf, "ctrl ");

      if (key_shifts & KB_ALT_FLAG)
	 strcat(buf, "alt ");

      if (key_shifts & KB_LWIN_FLAG)
	 strcat(buf, "lwin ");

      if (key_shifts & KB_RWIN_FLAG)
	 strcat(buf, "rwin ");

      if (key_shifts & KB_MENU_FLAG)
	 strcat(buf, "menu ");

      if (key_shifts & KB_COMMAND_FLAG)
	 strcat(buf, "command ");

      if (key_shifts & KB_SCROLOCK_FLAG)
	 strcat(buf, "scrolock ");

      if (key_shifts & KB_NUMLOCK_FLAG)
	 strcat(buf, "numlock ");

      if (key_shifts & KB_CAPSLOCK_FLAG)
	 strcat(buf, "capslock ");

      if (key_shifts & KB_INALTSEQ_FLAG)
	 strcat(buf, "inaltseq ");

      if (key_shifts & KB_ACCENT1_FLAG)
	 strcpy(buf, "accent1 ");

      if (key_shifts & KB_ACCENT2_FLAG)
	 strcpy(buf, "accent2 ");

      if (key_shifts & KB_ACCENT3_FLAG)
	 strcpy(buf, "accent3 ");

      if (key_shifts & KB_ACCENT4_FLAG)
	 strcpy(buf, "accent4 ");

      while (strlen(buf) < 128)
	 strcat(buf, " ");

      textout_ex(screen, font, buf, 0, 0, palette_color[255], palette_color[8]);

      release_screen();

      if (keypressed()) {
	 a = ureadkey(&i);
	 if (!a)
	    a = ' ';
	 textprintf_ex(screen, font, 32, 34, palette_color[255], palette_color[8], "ureadkey() returns scancode 0x%02X, U+0x%04X, '%c'", i, a, a);
      }

   } while ((!key[KEY_ESC]) && (!mouse_b));

   do {
      poll_keyboard();
      poll_mouse();
   } while ((key[KEY_ESC]) || (mouse_b));

   clear_keybuf();

   show_mouse(screen);
   return D_REDRAW;
}
예제 #6
0
파일: editor.cpp 프로젝트: Fomka/ufo2000
// See also: Inventory::draw(), Soldier::draw_inventory()
// Called by: Connect::do_planner() via Units::execute and execute_main()
void Editor::show()
{
    reset_video();
    destroy_bitmap(screen2);
    screen2 = create_bitmap(640, 400); 
    clear(screen2);

    // Prepare background picture for editor screen to improve 
    // performance a bit (static image that is never changed)
    BITMAP *editor_bg = create_bitmap(640, 400);
    clear_to_color(editor_bg, COLOR_BLACK1);
    SPK *tac01 = new SPK("$(xcom)/ufograph/tac01.scr");  // Picture with buttons
    tac01->show(editor_bg, 0, 0); // draw buttons: OK, Next-Man, Prev-Man, Unload-clip, Scroll-right
    delete tac01;
    BITMAP *b5 = create_bitmap(32, 15); clear(b5);  // Button for Scroll-left
    blit(editor_bg, b5, 288, 137, 0, 0, 32, 15);
    draw_sprite_vh_flip(editor_bg, b5, 255, 137); // Button: Scroll-left
    destroy_bitmap(b5);
    rectfill(editor_bg, 288, 32, 319, 57, COLOR_GRAY15);    //hide unused "unload" button
    text_mode(-1);
    textout(editor_bg, g_small_font, _("Click-and-drop weapons from the armory to the soldier, right-click to remove"), 0, 364 + 22, COLOR_WHITE); 

    position_mouse(320, 200);
    MouseRange temp_mouse_range(0, 0, 639, 400);

    int DONE = 0;
    int mouse_leftr = 1, mouse_rightr = 1;
    int i;
    int color = COLOR_LT_OLIVE;
    int A1 = 0, A2 = 0;

    while (mouse_b & 3) rest(1);

    g_console->resize(SCREEN_W, SCREEN_H - 400);
    g_console->set_full_redraw();
    g_console->redraw(screen, 0, 400);

    while (!DONE) {

        net->check();

        rest(1); // Don't eat all CPU resources

        if (CHANGE) {
            g_console->redraw(screen, 0, 400);

            blit(editor_bg, screen2, 0, 0, 0, 0, editor_bg->w, editor_bg->h);
            man->showspk(screen2); // Show "bigpicture" of soldier in choosen armor

            color = COLOR_DK_GRAY;
            if (man->x != 0)   // ??? This soldier already selected for the mission ?
                color = COLOR_LT_OLIVE;
            text_mode(-1);
            textout(screen2, large, man->md.Name, 0, 0, color);

            for (i = 0; i < NUMBER_OF_PLACES; i++) //man->drawgrid();
                man->place(i)->drawgrid(screen2, i);
            m_armoury->drawgrid(screen2, P_ARMOURY);

            man->draw_unibord(1, 320, 0);  // Attribute-Barchart
            if (sel_item != NULL) {
                if (sel_item_place == P_ARMOURY)
                    sel_item->od_info(330, 235, COLOR_WHITE);
                else
                    sel_item->od_info(330, 235, COLOR_OLIVE);

                textprintf(screen2, g_small_font, 128, 140, COLOR_GREEN,  "%s", sel_item->name().c_str());

                if (sel_item->haveclip()) {
                    //textprintf(screen2, font, 272, 80, color, "%d", sel_item->roundsremain());
                    textout(screen2, g_small_font, _("AMMO:"),  272, 64, COLOR_LT_OLIVE);
                    textout(screen2, g_small_font, _("ROUNDS"), 272, 72, COLOR_LT_OLIVE);
                    textout(screen2, g_small_font, _("LEFT="),  272, 80, COLOR_LT_OLIVE);
                    textprintf(screen2, g_small_font,           299, 80, COLOR_ORANGE, "%d", sel_item->roundsremain());
                    rect(screen2, 272, 88, 303, 135, COLOR_DK_GRAY);      //clip
                    PCK::showpck(sel_item->clip()->obdata_pInv(), 272, 88 + 8);
                } else if (sel_item->obdata_isAmmo()) {
                    //textprintf(screen2, font, 272, 80, color, "%d", sel_item->rounds);
                    textout(screen2, g_small_font, _("AMMO:"),  272, 64, COLOR_LT_OLIVE);
                    textout(screen2, g_small_font, _("ROUNDS"), 272, 72, COLOR_LT_OLIVE);
                    textout(screen2, g_small_font, _("LEFT="),  272, 80, COLOR_LT_OLIVE);
                    textprintf(screen2, g_small_font,           299, 80, COLOR_ORANGE, "%d", sel_item->m_rounds);
                    rect(screen2, 272, 88, 303, 135, COLOR_DK_GRAY);      //clip
                    PCK::showpck(sel_item->obdata_pInv(), 272, 88 + 8);
                }
                PCK::showpck(sel_item->obdata_pInv(),
                                mouse_x - sel_item->obdata_width()  * 16 / 2,
                                mouse_y - sel_item->obdata_height() * 16 / 2 + 8);
            } else {
                Item *it = m_armoury->item_under_mouse(0, 0);
                if (it != NULL) {
                    if (is_item_allowed(it->m_type))
                        it->od_info(330, 235, COLOR_GRAY05);
                    else
                        it->od_info(330, 235, COLOR_GRAY10);
                } else {
                    //textprintf(screen2, large, 330, 220, COLOR_LT_BLUE, _("Click here to change equipment set"));
                    int ty = 235;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("       F1: Help")); ty += 10;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("    F2/F3: Save/load team")); ty += 10;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("       F4: Edit soldier attributes")); ty += 10;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("       F5: Change weaponset")); ty += 15;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("       F6: Save as weapon set template")); ty += 15;

                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _(" Ctrl+Ins: Copy current soldier")); ty += 10;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("Shift+Ins: Paste on current soldier")); ty += 15;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("      Del: Delete items of current man")); /*ty += 10;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("Shift+Del: Drop items of current man"));*/ ty += 15;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("      F11: Cycle through appearences")); ty += 10;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("      F12: Cycle through human armours")); ty += 10;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("Shift+F12: Cycle through alien races")); ty += 15;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("      Tab: Next soldier")); ty += 10;
                    textprintf(screen2, font,  330, ty, COLOR_BLUE,     _("Shift+Tab: Previous soldier")); ty += 10;
                }
            }

            int wht = man->count_weight();
            int max_wht = man->md.Strength;
            color       = max_wht < wht ? COLOR_RED03 : COLOR_GRAY02;
            textprintf(screen2, g_small_font, 0, 20, color, _("Equipment weight: %2d/%2d"), wht, max_wht);
            char str1[64]; // to adjust position of translated string
          //int x1 = 120;
            int x2 = 236;
            sprintf(str1, "%s: %4d", _("Soldier cost"), man->calc_full_ammunition_cost() );
            int w1 = text_length(g_small_font, str1);  // right-justify string
            textprintf(screen2, g_small_font, x2-w1, 20, COLOR_GRAY02, "%s", str1);

            draw_alpha_sprite(screen2, mouser, mouse_x, mouse_y);
            blit(screen2, screen, 0, 0, 0, 0, screen2->w, screen2->h);
            CHANGE = 0;
        }

        if ((mouse_b & 1) && (mouse_leftr)) { //left mouseclick
            mouse_leftr = 0;
            CHANGE = 1;

            if (handle_mouse_leftclick())
                DONE = 1;
        }

        if ((mouse_b & 2) && (mouse_rightr)) { //right mouseclick: get & put items
            mouse_rightr = 0;
            CHANGE = 1;
            if (sel_item != NULL) {
                if (sel_item_place == P_ARMOURY) {
                    // If item was taken from the armoury - just delete it
                    delete sel_item;
                    sel_item = NULL;
                } else {
                    // If item was taken from the the soldier - put it back
                    man->putitem(sel_item, sel_item_place, sel_item->m_x, sel_item->m_y);
                    sel_item = NULL;
                }
            } else {
                // Delete item under mouse cursor
                for (i = 0; i < NUMBER_OF_PLACES; i++) {
                    Item *it = man->place(i)->mselect(0, 0);
                    if (it != NULL) delete(it);
                }
            }
        }

        if (!(mouse_b & 1)) {
            mouse_leftr = 1;
        }

        if (!(mouse_b & 2)) {
            mouse_rightr = 1;
        }

        if (keypressed()) {
            CHANGE = 1;
          //int c = readkey();
          //switch (c >> 8) {
            int scancode; int keycode = ureadkey(&scancode); 
            switch (scancode) { 
                case KEY_F1:
                    help( HELP_INVENTORY );
                    break;
                // Todo: Change from "Save&Load Team" to "Save&Load Soldier" 
                // Todo: move "Save&Load Team" to Mission-planner (connect.cpp)
                case KEY_F2:
                    //if (askmenu("SAVE DATA")) {
                    save();
                    //}
                    break;
                case KEY_F3:
                    //if (askmenu("LOAD DATA")) {
                    load();
                    //}
                    break;
                case KEY_F4:
                    edit_soldier();   // Edit Attributes+Armor
                    break;

                case KEY_F5:
                    change_equipment();
                    break;

                case KEY_F6:
                    export_weaponset();
                    break;

                case KEY_F10:
                    change_screen_mode();
                    break;

                case KEY_F11:  // cycle thru apperances:
                    A1 = man->md.Appearance;
                    A2 = man->md.fFemale;
                    if ((key[KEY_LSHIFT]) || (key[KEY_RSHIFT]) ) { // Shift-F11: 
                        A2++;
                        if (A2 >= 2) A2 = 0;
                        man->md.fFemale    = A2;
                    } else { // F11: 
                        A1 = A1 + (A2 ? 4 : 0);
                        A1++;
                        if (A1 >= 8) A1 = 0;
                        man->md.fFemale    = A1 >= 4;
                        man->md.Appearance = A1 % 4;
                    }
                    man->process_MANDATA();
                    break;
                case KEY_F12:  // cycle thru armor-types:
                    A1 = man->md.SkinType;
                    if ((key[KEY_LSHIFT]) || (key[KEY_RSHIFT]) ) // Shift-F12: Aliens
                        man->skin()->next_alien();
                    else // F12: Human Armor
                        man->skin()->next_human();
                    man->process_MANDATA();
                    break;
//
                case KEY_INSERT:  // Todo: Copy items from last DEL to current man
                    if ((key[KEY_LCONTROL]) || (key[KEY_RCONTROL])) {
                        copy_soldier(man);
                        break;
                    }
                    if ((key[KEY_LSHIFT]) || (key[KEY_RSHIFT])) {
                        paste_soldier(man);
                        break;
                    }
                    break;
                case KEY_DEL:  // Todo: store the deleted items (where?) for KEY_INSERT
                    if ((key[KEY_LSHIFT]) || (key[KEY_RSHIFT]) ) { // Shift-DEL:
                      // Drop all carried items:   // Todo: drop to common pool
                        Item * it;
                        for (int i = 0; i < NUMBER_OF_CARRIED_PLACES; i++) {
                            it = man->item(i);
                            if (it != NULL)
                                man->putitem(it, P_MAP);
                        }
                    } else { // DEL:
                        // Destroy items of current man, including those on the ground:
                        man->destroy_all_items();
                    }
                    break;

                case KEY_TAB:   // jump to next/prev. soldier
                    if ((key[KEY_LSHIFT]) || (key[KEY_RSHIFT]) ) { // Shift-TAB:
                        man = man->prevman();
                    } else { // TAB:
                        man = man->nextman();
                    }
                    break;
                case KEY_LEFT:
                    man = man->prevman();
                    break;
                case KEY_RIGHT:
                    man = man->nextman();
                    break;     

                 case KEY_PGUP:
                    scroll_equipment(-1);
                    break;
                 case KEY_PGDN:
                    scroll_equipment(+1);
                    break;
                case KEY_PRTSCR:
                    if (askmenu(_("SCREEN-SNAPSHOT"))) {
                        savescreen();
                    }
                    break;
                case KEY_ESC:
                    DONE = 1;
                    break;
                default: 
                    if (g_console->process_keyboard_input(keycode, scancode))
                        net->send_message((char *)g_console->get_text());
            }
        }
    }

    m_plt->save_FULLDATA("$(home)/squad.lua");

    destroy_bitmap(editor_bg);
    destroy_bitmap(screen2);
    screen2 = create_bitmap(SCREEN2W, SCREEN2H); clear(screen2);

    g_console->resize(SCREEN_W, SCREEN_H - SCREEN2H);
    g_console->set_full_redraw();

    clear(screen);
}