static int term_xtra_clear(Term_Data td) { Console.Clear(); /* Success */ return(0); }
//DISABLED: //we use ConsoleColor //#if 0 ///* // * Often, it is helpful to create an array of "color data" containing // * a representation of the "angband_color_table" array in some "local" form. // * // * Often, the "Term_xtra(TERM_XTRA_REACT, 0)" hook is used to initialize // * "color_data" from "angband_color_table". XXX XXX XXX // */ //static local_color_data_type color_data[MAX_COLORS]; //#endif /*** Function hooks needed by "Term" ***/ /* * Init a new "term" * * This function should do whatever is necessary to prepare a new "term" * for use by the "z-term.c" package. This may include clearing the window, * preparing the cursor, setting the font/colors, etc. Usually, this * function does nothing, and the "init_xxx()" function does it all. */ static void Term_init_xxx(Term t) { Term_Data td = (Term_Data)(t.data); /* XXX XXX XXX */ //TODO: something //throw new NotImplementedException(); }
/* * Draw some text on the screen * * This function should actually display an array of characters * starting at the given location, using the given "attribute", * and using the given string of characters, which contains * exactly "n" characters and which is NOT null-terminated. * * You may assume "valid" input if the window is properly sized. * * You must be sure that the string, when written, erases anything * (including any visual cursor) that used to be where the text is * drawn. On many machines this happens automatically, on others, * you must first call "Term_wipe_xxx()" to clear the area. * * In color environments, you should activate the color contained * in "color_data[a & BASIC_COLORS]", if needed, before drawing anything. * * You may ignore the "attribute" if you are only supporting a * monochrome environment, since this routine is normally never * called to display "black" (invisible) text, including the * default "spaces", and all other colors should be drawn in * the "normal" color in a monochrome environment. * * Note that if you have changed the "attr_blank" to something * which is not black, then this function must be able to draw * the resulting "blank" correctly. * * Note that this function must correctly handle "black" text if * the "always_text" flag is set, if this flag is not set, all the * "black" text will be handled by the "Term_wipe_xxx()" hook. */ //return type errr static int Term_text_xxx(int x, int y, int n, ConsoleColor a, char[] cp) { Term_Data td = (Term_Data)(Term.instance.data); for (int i = 0; i < cp.Length; i++) { cp[i] = Term_xchar_xxx(cp[i]); } Console.SetCursorPosition(x, y); Console.ForegroundColor = a; Console.Write(cp); /* If the cursor is Visible in the TERM, it is visible in real life */ Console.CursorVisible = td.t.scr.cv; /* Success */ return(0); }
/* * Initialization function */ //ret type = errr static int init_xxx(string[] args) { /* Process the command line arguments */ //for (int i = 0; i < args.Count; i++){ // string arg = argv[i]; // /* Require proper options */ // if (*arg++ != '-') goto usage; // /* Analyze option */ // switch (*arg++) // { // case 'n': // new_game = true; // break; // case 'w': // arg_wizard = true; // break; // case 'r': // arg_rebalance = true; // break; // case 'g': // /* Default graphics tile */ // arg_graphics = GRAPHICS_ADAM_BOLT; // break; // case 'u': // if (!*arg) goto usage; // /* Get the savefile name */ // my_strcpy(op_ptr.full_name, arg, sizeof(op_ptr.full_name)); // continue; // case 'm': // if (!*arg) goto usage; // mstr = arg; // continue; // case 's': // if (!*arg) goto usage; // soundstr = arg; // continue; // case 'd': // change_path(arg); // continue; // case 'x': // debug_opt(arg); // continue; // case '-': // argv[i] = argv[0]; // argc = argc - i; // argv = argv + i; // args = false; // break; // default: // usage: // puts("Usage: angband [options] [-- subopts]"); // puts(" -n Start a new character (WARNING: overwrites default savefile without -u)"); // puts(" -w Resurrect dead character (marks savefile)"); // puts(" -r Rebalance monsters"); // puts(" -g Request graphics mode"); // puts(" -x<opt> Debug options; see -xhelp"); // puts(" -u<who> Use your <who> savefile"); // puts(" -d<path> Store pref files and screendumps in <path>"); // puts(" -s<mod> Use sound module <sys>:"); // for (i = 0; i < (int)N_ELEMENTS(sound_modules); i++) // printf(" %s %s\n", sound_modules[i].name, // sound_modules[i].help); // puts(" -m<sys> Use module <sys>, where <sys> can be:"); // /* Print the name and help for each available module */ // for (i = 0; i < (int)N_ELEMENTS(modules); i++) // printf(" %s %s\n", // modules[i].name, modules[i].help); // /* Actually abort the process */ // quit(null); // } // if (*arg) goto usage; //} /* Initialize globals XXX XXX XXX */ /* Initialize "term_data" structures XXX XXX XXX */ for (int i = MAX_XXX_TERM; i-- > 0;) { /* Link */ data[i] = new Term_Data(); } /* Initialize the "color_data" array XXX XXX XXX */ /* Create windows (backwards!) */ for (int i = MAX_XXX_TERM; i-- > 0;) { /* Link */ term_data_link(i); } /* Success */ return(0); }
/*** Internal Functions ***/ /* * Instantiate a "term_data" structure * * This is one way to prepare the "term_data" structures and to * "link" the various informational pieces together. * * This function assumes that every window should be 80x24 in size * (the standard size) and should be able to queue 256 characters. * Technically, only the "main screen window" needs to queue any * characters, but this method is simple. One way to allow some * variation is to add fields to the "term_data" structure listing * parameters for that window, initialize them in the "init_xxx()" * function, and then use them in the code below. * * Note that "activation" calls the "Term_init_xxx()" hook for * the "term" structure, if needed. */ static void term_data_link(int i) { Term_Data td = data[i]; Term t = td.t; /* Initialize the term */ t.init(80, 24, 256); //TODO: Come back and properly configure the below, most are just the defaults /* Choose "soft" or "hard" cursor XXX XXX XXX */ /* A "soft" cursor must be explicitly "drawn" by the program */ /* while a "hard" cursor has some "physical" existance and is */ /* moved whenever text is drawn on the screen. See "z-term.c". */ t.soft_cursor = true; /* Avoid the "corner" of the window XXX XXX XXX */ t.icky_corner = true; /* Use "Term_pict()" for all attr/char pairs XXX XXX XXX */ /* See the "Term_pict_xxx()" function above. */ t.always_pict = false; //Default is true, I'd rather not since I don't understand all the input /* Use "Term_pict()" for some attr/char pairs XXX XXX XXX */ /* See the "Term_pict_xxx()" function above. */ t.higher_pict = true; /* Use "Term_text()" even for "black" text XXX XXX XXX */ /* See the "Term_text_xxx()" function above. */ t.always_text = true; /* Ignore the "TERM_XTRA_BORED" action XXX XXX XXX */ /* This may make things slightly more efficient. */ t.never_bored = true; /* Ignore the "TERM_XTRA_FROSH" action XXX XXX XXX */ /* This may make things slightly more efficient. */ t.never_frosh = true; /* Erase with "white space" XXX XXX XXX */ t.attr_blank = ConsoleColor.White; t.char_blank = ' '; /* Prepare the init/nuke hooks */ t.init_hook = Term_init_xxx; t.nuke_hook = Term_nuke_xxx; /* Prepare the template hooks */ t.xtra_hook = Term_xtra_xxx; t.curs_hook = Term_curs_xxx; t.wipe_hook = Term_wipe_xxx; t.text_hook = Term_text_xxx; t.pict_hook = Term_pict_xxx; t.xchar_hook = Term_xchar_xxx; /* Remember where we came from */ t.data = td; /* Activate it */ t.activate(); /* Global pointer */ Misc.angband_term[i] = t; }
/* * Do a "special thing" to the current "term" * * This function must react to a large number of possible arguments, each * corresponding to a different "action request" by the "z-term.c" package, * or by the application itself. * * The "action type" is specified by the first argument, which must be a * constant of the form "TERM_XTRA_*" as given in "z-term.h", and the second * argument specifies the "information" for that argument, if any, and will * vary according to the first argument. * * In general, this function should return zero if the action is successfully * handled, and non-zero if the action is unknown or incorrectly handled. */ //used to return "errr" static int Term_xtra_xxx(TERM_XTRA n, int v) { Term_Data td = (Term_Data)(Term.instance.data); //TODO: Actual stuff /* Analyze */ switch (n) { case TERM_XTRA.EVENT: { /* * Process some pending events XXX XXX XXX * * Wait for at least one event if "v" is non-zero * otherwise, if no events are ready, return at once. * When "keypress" events are encountered, the "ascii" * value corresponding to the key should be sent to the * "Term_keypress()" function. Certain "bizarre" keys, * such as function keys or arrow keys, may send special * sequences of characters, such as control-underscore, * plus letters corresponding to modifier keys, plus an * underscore, plus carriage return, which can be used by * the main program for "macro" triggers. This action * should handle as many events as is efficiently possible * but is only required to handle a single event, and then * only if one is ready or "v" is true. * * This action is required. */ return(CheckEvents(v == 1)?1:0); } case TERM_XTRA.FLUSH: { /* * Flush all pending events XXX XXX XXX * * This action should handle all events waiting on the * queue, optionally discarding all "keypress" events, * since they will be discarded anyway in "z-term.c". * * This action is required, but may not be "essential". */ while (!CheckEvents(false)) { ; } return(0); } case TERM_XTRA.CLEAR: { /* * Clear the entire window XXX XXX XXX * * This action should clear the entire window, and redraw * any "borders" or other "graphic" aspects of the window. * * This action is required. */ return(term_xtra_clear(td)); //return (0); } case TERM_XTRA.SHAPE: { /* * Set the cursor visibility XXX XXX XXX * * This action should change the visibility of the cursor, * if possible, to the requested value (0=off, 1=on) * * This action is optional, but can improve both the * efficiency (and attractiveness) of the program. */ throw new NotImplementedException(); //return (0); } case TERM_XTRA.FROSH: { /* * Flush a row of output XXX XXX XXX * * This action should make sure that row "v" of the "output" * to the window will actually appear on the window. * * This action is optional, assuming that "Term_text_xxx()" * (and similar functions) draw directly to the screen, or * that the "TERM_XTRA_FRESH" entry below takes care of any * necessary flushing issues. */ throw new NotImplementedException(); //return (0); } case TERM_XTRA.FRESH: { /* * Flush output XXX XXX XXX * * This action should make sure that all "output" to the * window will actually appear on the window. * * This action is optional, assuming that "Term_text_xxx()" * (and similar functions) draw directly to the screen, or * that the "TERM_XTRA_FROSH" entry above takes care of any * necessary flushing issues. */ //TODO: Make sure this is correct //throw new NotImplementedException(); return(0); } case TERM_XTRA.NOISE: { /* * Make a noise XXX XXX XXX * * This action should produce a "beep" noise. * * This action is optional, but convenient. */ throw new NotImplementedException(); //return (0); } case TERM_XTRA.BORED: { /* * Handle random events when bored XXX XXX XXX * * This action is optional, and normally not important */ throw new NotImplementedException(); //return (0); } case TERM_XTRA.REACT: { /* * React to global changes XXX XXX XXX * * For example, this action can be used to react to * changes in the global "angband_color_table[MAX_COLORS][4]" array. * * This action is optional, but can be very useful for * handling "color changes" and the "arg_sound" and/or * "arg_graphics" options. */ return(0); } case TERM_XTRA.ALIVE: { /* * Change the "hard" level XXX XXX XXX * * This action is used if the program changes "aliveness" * by being either "suspended" (v=0) or "resumed" (v=1) * This action is optional, unless the computer uses the * same "physical screen" for multiple programs, in which * case this action should clean up to let other programs * use the screen, or resume from such a cleaned up state. * * This action is currently only used by "main-gcu.c", * on UNIX machines, to allow proper "suspending". */ throw new NotImplementedException(); //return (0); } case TERM_XTRA.LEVEL: { /* * Change the "soft" level XXX XXX XXX * * This action is used when the term window changes "activation" * either by becoming "inactive" (v=0) or "active" (v=1) * * This action can be used to do things like activate the proper * font / drawing mode for the newly active term window. This * action should NOT change which window has the "focus", which * window is "raised", or anything like that. * * This action is optional if all the other things which depend * on what term is active handle activation themself, or if only * one "term_data" structure is supported by this file. */ //throw new NotImplementedException(); return(0); } case TERM_XTRA.DELAY: { /* * Delay for some milliseconds XXX XXX XXX * * This action is useful for proper "timing" of certain * visual effects, such as breath attacks. * * This action is optional, but may be required by this file, * especially if special "macro sequences" must be supported. */ Thread.Sleep(v); return(0); } } /* Unknown or Unhandled action */ throw new NotImplementedException(); //return (1); }
static int term_xtra_clear(Term_Data td) { Console.Clear(); /* Success */ return 0; }
/* * Initialization function */ //ret type = errr static int init_xxx(string[] args) { /* Process the command line arguments */ //for (int i = 0; i < args.Count; i++){ // string arg = argv[i]; // /* Require proper options */ // if (*arg++ != '-') goto usage; // /* Analyze option */ // switch (*arg++) // { // case 'n': // new_game = true; // break; // case 'w': // arg_wizard = true; // break; // case 'r': // arg_rebalance = true; // break; // case 'g': // /* Default graphics tile */ // arg_graphics = GRAPHICS_ADAM_BOLT; // break; // case 'u': // if (!*arg) goto usage; // /* Get the savefile name */ // my_strcpy(op_ptr.full_name, arg, sizeof(op_ptr.full_name)); // continue; // case 'm': // if (!*arg) goto usage; // mstr = arg; // continue; // case 's': // if (!*arg) goto usage; // soundstr = arg; // continue; // case 'd': // change_path(arg); // continue; // case 'x': // debug_opt(arg); // continue; // case '-': // argv[i] = argv[0]; // argc = argc - i; // argv = argv + i; // args = false; // break; // default: // usage: // puts("Usage: angband [options] [-- subopts]"); // puts(" -n Start a new character (WARNING: overwrites default savefile without -u)"); // puts(" -w Resurrect dead character (marks savefile)"); // puts(" -r Rebalance monsters"); // puts(" -g Request graphics mode"); // puts(" -x<opt> Debug options; see -xhelp"); // puts(" -u<who> Use your <who> savefile"); // puts(" -d<path> Store pref files and screendumps in <path>"); // puts(" -s<mod> Use sound module <sys>:"); // for (i = 0; i < (int)N_ELEMENTS(sound_modules); i++) // printf(" %s %s\n", sound_modules[i].name, // sound_modules[i].help); // puts(" -m<sys> Use module <sys>, where <sys> can be:"); // /* Print the name and help for each available module */ // for (i = 0; i < (int)N_ELEMENTS(modules); i++) // printf(" %s %s\n", // modules[i].name, modules[i].help); // /* Actually abort the process */ // quit(null); // } // if (*arg) goto usage; //} /* Initialize globals XXX XXX XXX */ /* Initialize "term_data" structures XXX XXX XXX */ for(int i = MAX_XXX_TERM; i-- > 0; ) { /* Link */ data[i] = new Term_Data(); } /* Initialize the "color_data" array XXX XXX XXX */ /* Create windows (backwards!) */ for(int i = MAX_XXX_TERM; i-- > 0; ) { /* Link */ term_data_link(i); } /* Success */ return (0); }