Changeset 214
- Timestamp:
- 06/23/07 10:50:19 (1 year ago)
- Files:
-
- trunk/src/dungeon.c (modified) (1 diff)
- trunk/src/externs.h (modified) (1 diff)
- trunk/src/main-win.c (modified) (1 diff)
- trunk/src/main-x11.c (modified) (16 diffs)
- trunk/src/main.c (modified) (2 diffs)
- trunk/src/variable.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/dungeon.c
r189 r214 2013 2013 2014 2014 2015 /* Set or clear "rogue_like_commands" if requested */2016 if (arg_force_original) rogue_like_commands = FALSE;2017 if (arg_force_roguelike) rogue_like_commands = TRUE;2018 2019 2020 2015 /* React to changes */ 2021 2016 Term_xtra(TERM_XTRA_REACT, 0); trunk/src/externs.h
r213 r214 98 98 extern bool arg_sound; 99 99 extern bool arg_graphics; 100 extern bool arg_force_original;101 extern bool arg_force_roguelike;102 100 extern bool character_generated; 103 101 extern bool character_dungeon; trunk/src/main-win.c
r189 r214 1034 1034 arg_wizard = (GetPrivateProfileInt("Angband", "Wizard", 0, ini_file) != 0); 1035 1035 1036 /* Extract the "arg_roguelike" flag */1037 arg_force_roguelike = (GetPrivateProfileInt("Angband", "force_roguelike", 0, ini_file) != 0);1038 1039 /* Extract the "arg_original" flag */1040 arg_force_original = (GetPrivateProfileInt("Angband", "force_original", 0, ini_file) != 0);1041 1042 1036 #ifdef SUPPORT_GAMMA 1043 1037 trunk/src/main-x11.c
r189 r214 104 104 #include "main.h" 105 105 106 107 106 #ifndef __MAKEDEPEND__ 108 107 #include <X11/Xlib.h> … … 110 109 #include <X11/keysym.h> 111 110 #include <X11/keysymdef.h> 112 #include <X11/Xatom.h>113 111 #endif /* __MAKEDEPEND__ */ 114 112 … … 1506 1504 1507 1505 1508 /* Use short names for the most commonly used elements of various structures. */1509 #define DPY (Metadpy->dpy)1510 #define WIN (Infowin->win)1511 1512 1506 1513 1507 /* … … 1515 1509 */ 1516 1510 static int term_windows_open; 1517 1518 1519 /* Describe a set of co-ordinates. */1520 typedef struct co_ord co_ord;1521 struct co_ord1522 {1523 int x;1524 int y;1525 };1526 1527 1528 /*1529 * A special structure to store information about the text currently1530 * selected.1531 */1532 typedef struct x11_selection_type x11_selection_type;1533 struct x11_selection_type1534 {1535 bool select; /* The selection is currently in use. */1536 bool drawn; /* The selection is currently displayed. */1537 term *t; /* The window where the selection is found. */1538 co_ord init; /* The starting co-ordinates. */1539 co_ord cur; /* The end co-ordinates (the current ones if still copying). */1540 co_ord old; /* The previous end co-ordinates. */1541 Time time; /* The time at which the selection was finalised. */1542 };1543 1544 static x11_selection_type x11_selection[1];1545 1511 1546 1512 … … 1668 1634 } 1669 1635 1670 /* 1671 * Find the pixel at the top-left corner of a square. 1672 */ 1673 static void square_to_pixel(int * const x, int * const y, 1674 const int ox, const int oy) 1675 { 1676 term_data *td = (term_data*)(Term->data); 1677 1678 (*x) = ox * td->tile_wid + Infowin->ox; 1679 (*y) = oy * td->tile_hgt + Infowin->oy; 1680 } 1681 1682 1683 /* 1684 * Convert co-ordinates from starting corner/opposite corner to minimum/maximum. 1685 */ 1686 static void sort_co_ord(co_ord *min, co_ord *max, 1687 const co_ord *b, const co_ord *a) 1688 { 1689 min->x = MIN(a->x, b->x); 1690 min->y = MIN(a->y, b->y); 1691 max->x = MAX(a->x, b->x); 1692 max->y = MAX(a->y, b->y); 1693 } 1694 1695 1696 /* 1697 * Remove the selection by redrawing it. 1698 */ 1699 static void mark_selection_clear(int x1, int y1, int x2, int y2) 1700 { 1701 Term_redraw_section(x1, y1, x2, y2); 1702 } 1703 1704 1705 /* 1706 * Select an area by drawing a grey box around it. 1707 * NB. These two functions can cause flicker as the selection is modified, 1708 * as the game redraws the entire marked section. 1709 */ 1710 static void mark_selection_mark(int x1, int y1, int x2, int y2) 1711 { 1712 term_data *td = (term_data*)(Term->data); 1713 1714 square_to_pixel(&x1, &y1, x1, y1); 1715 square_to_pixel(&x2, &y2, x2, y2); 1716 XDrawRectangle(Metadpy->dpy, Infowin->win, clr[2]->gc, x1, y1, 1717 x2-x1+td->tile_wid - 1, y2-y1+td->tile_hgt - 1); 1718 } 1719 1720 1721 /* 1722 * Mark a selection by drawing boxes around it (for now). 1723 */ 1724 static void mark_selection(void) 1725 { 1726 co_ord min, max; 1727 term *old = Term; 1728 bool draw = x11_selection->select; 1729 bool clear = x11_selection->drawn; 1730 1731 /* Open the correct term if necessary. */ 1732 if (x11_selection->t != old) Term_activate(x11_selection->t); 1733 1734 if (clear) 1735 { 1736 sort_co_ord(&min, &max, &x11_selection->init, &x11_selection->old); 1737 mark_selection_clear(min.x, min.y, max.x, max.y); 1738 } 1739 1740 if (draw) 1741 { 1742 sort_co_ord(&min, &max, &x11_selection->init, &x11_selection->cur); 1743 mark_selection_mark(min.x, min.y, max.x, max.y); 1744 } 1745 1746 /* Finish on the current term. */ 1747 if (x11_selection->t != old) Term_activate(old); 1748 1749 x11_selection->old.x = x11_selection->cur.x; 1750 x11_selection->old.y = x11_selection->cur.y; 1751 x11_selection->drawn = x11_selection->select; 1752 } 1753 1754 1755 /* 1756 * Forget a selection for one reason or another. 1757 */ 1758 static void copy_x11_release(void) 1759 { 1760 /* Deselect the current selection. */ 1761 x11_selection->select = FALSE; 1762 1763 /* Remove its graphical represesntation. */ 1764 mark_selection(); 1765 } 1766 1767 1768 /* 1769 * Start to select some text on the screen. 1770 */ 1771 static void copy_x11_start(int x, int y) 1772 { 1773 if (x11_selection->select) copy_x11_release(); 1774 1775 /* Remember where the selection started. */ 1776 x11_selection->t = Term; 1777 x11_selection->init.x = x11_selection->cur.x = x11_selection->old.x = x; 1778 x11_selection->init.y = x11_selection->cur.y = x11_selection->old.y = y; 1779 } 1780 1781 1782 /* 1783 * Respond to movement of the mouse when selecting text. 1784 */ 1785 static void copy_x11_cont(int x, int y, unsigned int buttons) 1786 { 1787 /* Use the nearest square within bounds if the mouse is outside. */ 1788 x = MIN(MAX(x, 0), Term->wid-1); 1789 y = MIN(MAX(y, 0), Term->hgt-1); 1790 1791 /* The left mouse button isn't pressed. */ 1792 if (~buttons & Button1Mask) return; 1793 1794 /* Not a selection in this window. */ 1795 if (x11_selection->t != Term) return; 1796 1797 /* Not enough movement. */ 1798 if ((x == x11_selection->old.x) && (y == x11_selection->old.y) && x11_selection->select) return; 1799 1800 /* Something is being selected. */ 1801 x11_selection->select = TRUE; 1802 1803 /* Track the selection. */ 1804 x11_selection->cur.x = x; 1805 x11_selection->cur.y = y; 1806 1807 /* Hack - display it inefficiently. */ 1808 mark_selection(); 1809 } 1810 1811 1812 /* 1813 * Respond to release of the left mouse button by putting the selected text in 1814 * the primary buffer. 1815 */ 1816 static void copy_x11_end(const Time time) 1817 { 1818 /* No selection. */ 1819 if (!x11_selection->select) return; 1820 1821 /* Not a selection in this window. */ 1822 if (x11_selection->t != Term) return; 1823 1824 /* Remember when the selection was finalised. */ 1825 x11_selection->time = time; 1826 1827 /* Acquire the primary selection. */ 1828 XSetSelectionOwner(Metadpy->dpy, XA_PRIMARY, Infowin->win, time); 1829 1830 if (XGetSelectionOwner(Metadpy->dpy, XA_PRIMARY) != Infowin->win) 1831 { 1832 /* Failed to acquire the selection, so forget it. */ 1833 bell("Failed to acquire primary buffer."); 1834 x11_selection->select = FALSE; 1835 mark_selection(); 1836 } 1837 } 1838 1839 1840 /* 1841 * Send some text requested by another X client 1842 */ 1843 static void paste_x11_send(XSelectionRequestEvent *rq) 1844 { 1845 XEvent event; 1846 XSelectionEvent *ptr = &(event.xselection); 1847 1848 static Atom xa_targets = None; 1849 1850 if (xa_targets == None) 1851 xa_targets = XInternAtom(DPY, "TARGETS", False); 1852 1853 /* Set the event parameters */ 1854 ptr->type = SelectionNotify; 1855 ptr->property = rq->property; 1856 ptr->display = rq->display; 1857 ptr->requestor = rq->requestor; 1858 ptr->selection = rq->selection; 1859 ptr->target = rq->target; 1860 ptr->time = rq->time; 1861 1862 if (rq->target == xa_targets) 1863 { 1864 Atom target_list[2]; 1865 target_list[0] = xa_targets; 1866 target_list[1] = XA_STRING; 1867 1868 XChangeProperty(DPY, rq->requestor, rq->property, rq->target, 1869 (8 * sizeof(target_list[0])), PropModeReplace, 1870 (unsigned char *)target_list, 1871 (sizeof(target_list) / sizeof(target_list[0]))); 1872 1873 event.xselection.property = rq->property; 1874 } 1875 else if (rq->target == XA_STRING) 1876 { 1877 /* Reply to a known target received recently with data */ 1878 unsigned char buf[1024]; 1879 co_ord max, min; 1880 int x, y, i; 1881 byte a; 1882 char c; 1883 1884 /* Work out which way around to paste */ 1885 sort_co_ord(&min, &max, &x11_selection->init, &x11_selection->cur); 1886 1887 /* Delete the old value of the property */ 1888 XDeleteProperty(DPY, rq->requestor, rq->property); 1889 1890 for (y = 0; y < Term->hgt; y++) 1891 { 1892 if (y < min.y) continue; 1893 if (y > max.y) break; 1894 1895 for (x = i = 0; x < Term->wid; x++) 1896 { 1897 if (x < min.x) continue; 1898 if (x > max.x) break; 1899 1900 /* Protect the buffer boundary */ 1901 if (i >= (sizeof(buf) - 2)) break; 1902 1903 /* Find the character */ 1904 Term_what(x, y, &a, &c); 1905 1906 /* Add it */ 1907 buf[i++] = c; 1908 } 1909 1910 /* Terminate all but the last line in an appropriate way */ 1911 if (y != max.y) buf[i++] = '\n'; 1912 1913 /* Send the (non-empty) string */ 1914 XChangeProperty(DPY, rq->requestor, rq->property, rq->target, 8, 1915 PropModeAppend, buf, i); 1916 } 1917 } 1918 else 1919 { 1920 /* Respond to all bad requests with property None */ 1921 ptr->property = None; 1922 } 1923 1924 /* Send whatever event we're left with */ 1925 XSendEvent(DPY, rq->requestor, FALSE, NoEventMask, &event); 1926 } 1927 1928 1929 /* 1930 * Handle various events conditional on presses of a mouse button. 1931 */ 1932 static void handle_button(Time time, int x, int y, int button, bool press) 1933 { 1934 /* The co-ordinates are only used in Angband format. */ 1935 pixel_to_square(&x, &y, x, y); 1936 1937 #if 0 1938 if (press && button == 1) copy_x11_start(x, y); 1939 if (!press && button == 1) copy_x11_end(time); 1940 #endif 1941 1942 if (press) Term_mousepress(x,y,button); 1943 } 1636 1944 1637 1945 1638 … … 1956 1649 infowin *iwin = NULL; 1957 1650 1958 int i ;1651 int i, x, y; 1959 1652 int window = 0; 1960 1653 1961 1654 /* Do not wait unless requested */ 1962 1655 if (!wait && !XPending(Metadpy->dpy)) return (1); 1963 1964 /*1965 * Hack - redraw the selection, if needed.1966 * This doesn't actually check that one of its squares was drawn to,1967 * only that this may have happened.1968 */1969 if (x11_selection->select && !x11_selection->drawn) mark_selection();1970 1656 1971 1657 /* Load the Event */ … … 2008 1694 { 2009 1695 case ButtonPress: 2010 case ButtonRelease: 2011 { 2012 bool press = (xev->type == ButtonPress); 1696 { 1697 int z = 0; 2013 1698 2014 1699 /* Where is the mouse */ 2015 1700 int x = xev->xbutton.x; 2016 1701 int y = xev->xbutton.y; 2017 2018 int z;2019 1702 2020 1703 /* Which button is involved */ … … 2026 1709 else z = 0; 2027 1710 2028 /* XXX Handle */ 2029 handle_button(xev->xbutton.time, x, y, z, press); 1711 /* The co-ordinates are only used in Angband format. */ 1712 pixel_to_square(&x, &y, x, y); 1713 Term_mousepress(x, y, 0); 2030 1714 2031 1715 break; 2032 1716 } 2033 1717 1718 #if 0 2034 1719 case MotionNotify: 2035 1720 { … … 2041 1726 /* Convert to co-ordinates Angband understands. */ 2042 1727 pixel_to_square(&x, &y, x, y); 2043 2044 #if 02045 /* Alter the selection if appropriate. */2046 copy_x11_cont(x, y, z);2047 #endif2048 1728 2049 1729 break; 2050 1730 } 2051 2052 case SelectionRequest: 2053 { 2054 paste_x11_send(&(xev->xselectionrequest)); 2055 break; 2056 } 2057 2058 case SelectionClear: 2059 { 2060 x11_selection->select = FALSE; 2061 mark_selection(); 2062 break; 2063 } 2064 2065 case KeyRelease: 2066 { 2067 /* Nothing */ 2068 break; 2069 } 1731 #endif 2070 1732 2071 1733 case KeyPress: 2072 1734 { 1735 /* Save the mouse location */ 1736 x = xev->xkey.x; 1737 y = xev->xkey.y; 1738 2073 1739 /* Hack -- use "old" term */ 2074 1740 Term_activate(&old_td->t); … … 2261 1927 case TERM_XTRA_LEVEL: return (Term_xtra_x11_level(v)); 2262 1928 2263 /* Clear the screen and redraw any selection later*/2264 case TERM_XTRA_CLEAR: Infowin_wipe(); x11_selection->drawn = FALSE;return (0);1929 /* Clear the screen */ 1930 case TERM_XTRA_CLEAR: Infowin_wipe(); return (0); 2265 1931 2266 1932 /* Delay for some milliseconds */ … … 2323 1989 Infofnt_text_non(x, y, "", n); 2324 1990 2325 /* Redraw the selection if any, as it may have been obscured. (later) */2326 x11_selection->drawn = FALSE;2327 2328 1991 /* Success */ 2329 1992 return (0); … … 2341 2004 /* Draw the text */ 2342 2005 Infofnt_text_std(x, y, s, n); 2343 2344 /* Redraw the selection if any, as it may have been obscured. (later) */2345 x11_selection->drawn = FALSE;2346 2006 2347 2007 /* Success */ … … 2446 2106 x += td->tile_wid; 2447 2107 } 2448 2449 /* Redraw the selection if any, as it may have been obscured. (later) */2450 x11_selection->drawn = FALSE;2451 2108 2452 2109 /* Success */ … … 2784 2441 2785 2442 /* Ask for certain events */ 2786 Infowin_set_mask(ExposureMask | StructureNotifyMask | KeyPressMask | 2787 PointerMotionMask | ButtonPressMask | ButtonReleaseMask); 2443 Infowin_set_mask(ExposureMask | StructureNotifyMask | KeyPressMask); 2788 2444 2789 2445 /* Set the window name */ … … 2968 2624 #ifdef USE_GRAPHICS 2969 2625 2970 cptr bitmap_file = "";2626 cptr bitmap_file; 2971 2627 char filename[1024]; 2972 2628 … … 3307 2963 3308 2964 #endif /* USE_X11 */ 2965 trunk/src/main.c
r213 r214 370 370 } 371 371 372 case 'R':373 case 'r':374 {375 arg_force_roguelike = TRUE;376 break;377 }378 379 case 'O':380 case 'o':381 {382 arg_force_original = TRUE;383 break;384 }385 386 372 case 'S': 387 373 case 's': … … 431 417 /* Dump usage information */ 432 418 puts("Usage: angband [options] [-- subopts]"); 433 puts(" -n Start a new character"); 434 puts(" -w Resurrect dead character"); 435 puts(" -f Request fiddle (verbose) mode"); 436 puts(" -v Request sound mode"); 437 puts(" -g Request graphics mode"); 438 puts(" -o Request original keyset (default)"); 439 puts(" -r Request rogue-like keyset"); 440 puts(" -s<num> Show <num> high scores (default: 10)"); 441 puts(" -u<who> Use your <who> savefile"); 442 puts(" -d<def> Define a 'lib' dir sub-path"); 443 puts(" -m<sys> use Module <sys>, where <sys> can be:"); 419 puts(" -n Start a new character"); 420 puts(" -w Resurrect dead character (marks savefile)"); 421 puts(" -f Request fiddle (verbose) mode"); 422 puts(" -v Request sound mode"); 423 puts(" -g Request graphics mode"); 424 puts(" -s<num> Show <num> high scores (default: 10)"); 425 puts(" -u<who> Use your <who> savefile"); 426 puts(" -d<def>=<path> Instead of lib/<def>, use <path>"); 427 puts(" -m<sys> Use module <sys>, where <sys> can be:"); 444 428 445 429 /* Print the name and help for each available module */ trunk/src/variable.c
r213 r214 54 54 bool arg_sound; /* Command arg -- Request special sounds */ 55 55 bool arg_graphics; /* Command arg -- Request graphics mode */ 56 bool arg_force_original; /* Command arg -- Request original keyset */57 bool arg_force_roguelike; /* Command arg -- Request roguelike keyset */58 56 59 57 /*
