Changeset 816
- Timestamp:
- 03/25/08 19:49:01 (6 months ago)
- Files:
-
- trunk/src/cmd4.c (modified) (3 diffs)
- trunk/src/defines.h (modified) (1 diff)
- trunk/src/dungeon.c (modified) (1 diff)
- trunk/src/externs.h (modified) (2 diffs)
- trunk/src/load.c (modified) (1 diff)
- trunk/src/save.c (modified) (1 diff)
- trunk/src/util.c (modified) (19 diffs)
- trunk/src/variable.c (modified) (2 diffs)
- trunk/src/wizard.c (modified) (1 diff)
- trunk/src/xtra2.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/cmd4.c
r815 r816 2909 2909 2910 2910 /* Do not wait for keys */ 2911 inkey_scan = TRUE;2911 inkey_scan = SCAN_INSTANT; 2912 2912 2913 2913 /* Attempt to read a key */ … … 3916 3916 3917 3917 3918 bool askfor_aux_numbers(char *buf, size_t buflen, size_t *curs, size_t *len, char keypress, bool firsttime) 3919 { 3920 switch (keypress) 3921 { 3922 case ESCAPE: 3923 case '\n': 3924 case '\r': 3925 case ARROW_LEFT: 3926 case ARROW_RIGHT: 3927 case 0x7F: 3928 case '\010': 3929 case '0': 3930 case '1': 3931 case '2': 3932 case '3': 3933 case '4': 3934 case '5': 3935 case '6': 3936 case '7': 3937 case '8': 3938 case '9': 3939 return askfor_aux_keypress(buf, buflen, curs, len, keypress, firsttime); 3940 } 3941 3942 return FALSE; 3943 } 3944 3945 /* 3946 * Set "lazy-movement" delay 3947 */ 3948 static void do_cmd_lazymove_delay(void) 3949 { 3950 bool res; 3951 char tmp[4] = ""; 3952 3953 strnfmt(tmp, sizeof(tmp), "%i", lazymove_delay); 3954 3955 /* Prompt */ 3956 prt("Command: Movement Delay Factor", 20, 0); 3957 3958 prt(format("Current movement delay: %d (%d msec)", 3959 lazymove_delay, lazymove_delay * 10), 22, 0); 3960 prt("New movement delay: ", 21, 0); 3961 3962 /* Ask the user for a string */ 3963 res = askfor_aux(tmp, sizeof(tmp), askfor_aux_numbers); 3964 3965 /* Process input */ 3966 if (res) 3967 { 3968 lazymove_delay = (u16b) strtoul(tmp, NULL, 0); 3969 } 3970 } 3971 3972 3973 3918 3974 /* 3919 3975 * Ask for a "user pref file" and process it. … … 3986 4042 {'d', "Set base delay factor", (action_f) do_cmd_delay, 0}, 3987 4043 {'h', "Set hitpoint warning", (action_f) do_cmd_hp_warn, 0}, 3988 { 0, 0, 0, 0}, /* Special choices */4044 {'i', "Set movement delay", (action_f) do_cmd_lazymove_delay, 0}, 3989 4045 {'l', "Load a user pref file", (action_f) do_cmd_pref_file_hack, (void*)20}, 3990 4046 {'o', "Dump options", do_dump_options, 0}, trunk/src/defines.h
r789 r816 2651 2651 2652 2652 #endif /* !INCLUDED_DEFINES_H */ 2653 2654 2655 #define SCAN_INSTANT ((u32b) -1) 2656 #define SCAN_OFF 0 2657 #define SCAN_MACRO 45 trunk/src/dungeon.c
r815 r816 1087 1087 { 1088 1088 /* Do not wait */ 1089 inkey_scan = TRUE;1089 inkey_scan = SCAN_INSTANT; 1090 1090 1091 1091 /* Check for a key */ trunk/src/externs.h
r815 r816 116 116 extern bool inkey_base; 117 117 extern bool inkey_xtra; 118 extern boolinkey_scan;118 extern u32b inkey_scan; 119 119 extern bool inkey_flag; 120 120 extern s16b coin_type; … … 696 696 697 697 #endif /* !INCLUDED_EXTERNS_H */ 698 699 700 extern u16b lazymove_delay; trunk/src/load.c
r789 r816 882 882 op_ptr->hitpoint_warn = b; 883 883 884 /* Old cheating options*/884 /* Read lazy movement delay */ 885 885 rd_u16b(&tmp16u); 886 lazymove_delay = (tmp16u < 1000) ? tmp16u : 0; 886 887 887 888 trunk/src/save.c
r789 r816 322 322 wr_byte(op_ptr->hitpoint_warn); 323 323 324 wr_u16b(0); /* oops */ 324 /* Write movement delay */ 325 wr_u16b(lazymove_delay); 325 326 326 327 trunk/src/util.c
r815 r816 790 790 * known not to be that macro trigger. XXX XXX XXX 791 791 */ 792 static ui_event_data inkey_aux( void)792 static ui_event_data inkey_aux(int scan_cutoff) 793 793 { 794 794 int k = 0, n, p = 0, w = 0; … … 800 800 801 801 char buf[1024]; 802 802 803 803 /* Initialize the no return */ 804 ke0.type = EVT_ KBRD;804 ke0.type = EVT_NONE; 805 805 ke0.key = 0; 806 806 ke0.index = 0; /* To fix GCC warnings on X11 */ … … 809 809 810 810 /* Wait for a keypress */ 811 (void)(Term_inkey(&ke, TRUE, TRUE)); 812 ch = ke.key; 811 if (scan_cutoff == SCAN_OFF) 812 { 813 (void)(Term_inkey(&ke, TRUE, TRUE)); 814 ch = ke.key; 815 } 816 else 817 { 818 w = 0; 819 820 /* Wait only as long as macro activation would wait*/ 821 while (Term_inkey(&ke, FALSE, TRUE) != 0) 822 { 823 /* Increase "wait" */ 824 w++; 825 826 /* Excessive delay */ 827 if (w >= scan_cutoff) 828 { 829 ke0.type = EVT_KBRD; 830 return ke0; 831 } 832 833 /* Delay */ 834 Term_xtra(TERM_XTRA_DELAY, 10); 835 } 836 ch = ke.key; 837 } 838 813 839 814 840 /* End "macro action" */ … … 862 888 { 863 889 /* Increase "wait" */ 864 w + = 10;890 w ++; 865 891 866 892 /* Excessive delay */ 867 if (w >= 100) break;893 if (w >= SCAN_MACRO) break; 868 894 869 895 /* Delay */ 870 Term_xtra(TERM_XTRA_DELAY, w);896 Term_xtra(TERM_XTRA_DELAY, 10); 871 897 } 872 898 } … … 1040 1066 /* Initialise keypress */ 1041 1067 ke.key = 0; 1042 ke.type = EVT_ KBRD;1068 ke.type = EVT_NONE; 1043 1069 1044 1070 /* Hack -- Use the "inkey_next" pointer */ … … 1047 1073 /* Get next character, and advance */ 1048 1074 ke.key = *inkey_next++; 1075 ke.type = EVT_KBRD; 1049 1076 1050 1077 /* Cancel the various "global parameters" */ … … 1080 1107 /* End "macro action" */ 1081 1108 parse_macro = FALSE; 1082 ke.type = EVT_KBRD;1083 1109 1084 1110 /* End "macro trigger" */ … … 1106 1132 1107 1133 /* Get a key */ 1108 while ( !ke.key)1109 { 1110 /* Hack -- Handle "inkey_scan "*/1111 if (!inkey_base && inkey_scan &&1134 while (ke.type == EVT_NONE) 1135 { 1136 /* Hack -- Handle "inkey_scan == SCAN_INSTANT */ 1137 if (!inkey_base && inkey_scan == SCAN_INSTANT && 1112 1138 (0 != Term_inkey(&kk, FALSE, FALSE))) 1113 1139 { 1140 ke.type = EVT_KBRD; 1114 1141 break; 1115 1142 } … … 1152 1179 { 1153 1180 /* Done */ 1181 ke.type = EVT_KBRD; 1154 1182 break; 1155 1183 } … … 1166 1194 { 1167 1195 /* Done */ 1196 ke.type = EVT_KBRD; 1168 1197 break; 1169 1198 } … … 1173 1202 { 1174 1203 /* Increase "wait" */ 1175 w + = 10;1204 w ++; 1176 1205 1177 1206 /* Excessive delay */ 1178 if (w >= 100) break;1207 if (w >= SCAN_MACRO) break; 1179 1208 1180 1209 /* Delay */ 1181 Term_xtra(TERM_XTRA_DELAY, w);1210 Term_xtra(TERM_XTRA_DELAY, 10); 1182 1211 1183 1212 } … … 1190 1219 1191 1220 /* Get a key (see above) */ 1192 ke = inkey_aux( );1221 ke = inkey_aux(inkey_scan); 1193 1222 1194 1223 /* Handle mouse buttons */ … … 1218 1247 { 1219 1248 /* Strip this key */ 1220 ke. key = 0;1249 ke.type = EVT_NONE; 1221 1250 1222 1251 /* Continue */ … … 1230 1259 1231 1260 /* End "macro trigger" */ 1232 if (parse_under && (ke.key <= 32))1261 if (parse_under && (ke.key >=0 && ke.key <= 32)) 1233 1262 { 1234 1263 /* Strip this key */ 1264 ke.type = EVT_NONE; 1235 1265 ke.key = 0; 1236 1266 … … 1243 1273 { 1244 1274 /* Strip this key */ 1275 ke.type = EVT_NONE; 1245 1276 ke.key = 0; 1246 1277 } … … 1250 1281 { 1251 1282 /* Strip this key */ 1283 ke.type = EVT_NONE; 1252 1284 ke.key = 0; 1253 1285 … … 1260 1292 { 1261 1293 /* Strip this key */ 1294 ke.type = EVT_NONE; 1262 1295 ke.key = 0; 1263 1296 } … … 2831 2864 } 2832 2865 2833 2834 2866 /* Special case for the arrow keys */ 2835 2867 if (isarrow(ke.key)) … … 2843 2875 } 2844 2876 } 2845 2846 2877 2847 2878 /* Allow "keymaps" to be bypassed */ trunk/src/variable.c
r670 r816 103 103 bool inkey_base; /* See the "inkey()" function */ 104 104 bool inkey_xtra; /* See the "inkey()" function */ 105 boolinkey_scan; /* See the "inkey()" function */105 u32b inkey_scan; /* See the "inkey()" function */ 106 106 bool inkey_flag; /* See the "inkey()" function */ 107 107 … … 786 786 bool new_save; 787 787 788 789 /* Delay in centiseconds before moving to allow another keypress */ 790 /* Zero means normal instant movement. */ 791 u16b lazymove_delay = 0; trunk/src/wizard.c
r793 r816 734 734 { 735 735 /* Do not wait */ 736 inkey_scan = TRUE;736 inkey_scan = SCAN_INSTANT; 737 737 738 738 /* Allow interupt */ trunk/src/xtra2.c
r789 r816 1890 1890 1891 1891 1892 int dir_transitions[10][10] = 1893 { 1894 /* 0-> */ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, 1895 /* 1-> */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 1896 /* 2-> */ { 0, 0, 2, 0, 1, 0, 3, 0, 5, 0 }, 1897 /* 3-> */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 1898 /* 4-> */ { 0, 0, 1, 0, 4, 0, 5, 0, 7, 0 }, 1899 /* 5-> */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 1900 /* 6-> */ { 0, 0, 3, 0, 5, 0, 6, 0, 9, 0 }, 1901 /* 7-> */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 1902 /* 8-> */ { 0, 0, 5, 0, 7, 0, 9, 0, 8, 0 }, 1903 /* 9-> */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 1904 }; 1905 1892 1906 1893 1907 /* … … 1984 1998 default: 1985 1999 { 1986 dir = target_dir(ke.key); 1987 break; 2000 int keypresses_handled = 0; 2001 2002 while (ke.key != 0) 2003 { 2004 int this_dir; 2005 2006 /* XXX Ideally show and move the cursor here to indicate 2007 the currently "Pending" direction. XXX */ 2008 this_dir = target_dir(ke.key); 2009 2010 if (this_dir) 2011 { 2012 dir = dir_transitions[dir][this_dir]; 2013 } 2014 else 2015 { 2016 break; 2017 } 2018 2019 if (lazymove_delay == 0 || ++keypresses_handled > 1) 2020 break; 2021 2022 /* See if there's a second keypress within the defined 2023 period of time. */ 2024 inkey_scan = lazymove_delay; 2025 ke = inkey_ex(); 2026 } 1988 2027 } 1989 2028 } … … 2021 2060 return (TRUE); 2022 2061 } 2023 2024 2062 2025 2063 … … 2045 2083 ui_event_data ke; 2046 2084 2047 cptr p;2048 2049 2085 if (repeat_pull(dp)) 2050 2086 { … … 2061 2097 while (!dir) 2062 2098 { 2063 /* Choose a prompt */ 2064 p = "Direction or <click> (Escape to cancel)? "; 2065 2066 /* Get a command (or Cancel) */ 2067 if (!get_com_ex(p, &ke)) break; 2099 /* Paranoia XXX XXX XXX */ 2100 message_flush(); 2101 2102 /* Get first keypress - the first test is to avoid displaying the 2103 prompt for direction if there's already a keypress queued up 2104 and waiting - this just avoids a flickering prompt if there is 2105 a "lazy" movement delay. */ 2106 inkey_scan = SCAN_INSTANT; 2107 ke = inkey_ex(); 2108 inkey_scan = SCAN_OFF; 2109 2110 if (ke.key != '\xff' && target_dir(ke.key) == 0) 2111 { 2112 prt("Direction or <click> (Escape to cancel)? ", 0, 0); 2113 ke = inkey_ex(); 2114 } 2068 2115 2069 2116 /* Check mouse coordinates */ … … 2089 2136 else dir = 6; 2090 2137 } 2091 /* else continue; */ 2092 } 2093 2094 /* Convert keypress into a direction */ 2095 else dir = target_dir(ke.key); 2138 } 2139 2140 /* Get other keypresses until a direction is chosen. */ 2141 else 2142 { 2143 int keypresses_handled = 0; 2144 2145 while (ke.key != 0) 2146 { 2147 int this_dir; 2148 2149 if (ke.key == ESCAPE) 2150 { 2151 /* Clear the prompt */ 2152 prt("", 0, 0); 2153 2154 return (FALSE); 2155 } 2156 2157 /* XXX Ideally show and move the cursor here to indicate 2158 the currently "Pending" direction. XXX */ 2159 this_dir = target_dir(ke.key); 2160 2161 if (this_dir) 2162 { 2163 dir = dir_transitions[dir][this_dir]; 2164 } 2165 2166 if (lazymove_delay == 0 || ++keypresses_handled > 1) 2167 break; 2168 2169 inkey_scan = lazymove_delay; 2170 ke = inkey_ex(); 2171 } 2172 2173 /* 5 is equivalent to "escape" */ 2174 if (dir == 5) 2175 { 2176 /* Clear the prompt */ 2177 prt("", 0, 0); 2178 2179 return (FALSE); 2180 } 2181 } 2096 2182 2097 2183 /* Oops */ … … 2099 2185 } 2100 2186 2187 /* Clear the prompt */ 2188 prt("", 0, 0); 2189 2101 2190 /* Aborted */ 2102 2191 if (!dir) return (FALSE);
