src/extprocs.c
changeset 0 acc07f1f4b1e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/extprocs.c	Mon Jan 29 20:22:01 2007 +0000
     1.3 @@ -0,0 +1,162 @@
     1.4 +/*
     1.5 + * $Id: extprocs.c,v 1.5 2004/12/30 09:07:47 ali Exp $
     1.6 + * Copyright (C) 2007 J. Ali Harlow
     1.7 + * Min Hack may be freely redistributed.  See license for details. 
     1.8 + */
     1.9 +
    1.10 +#include <stdlib.h>
    1.11 +#include <stdio.h>
    1.12 +#include <string.h>
    1.13 +#include "minhack.h"
    1.14 +
    1.15 +struct nhproxy_cb_get_glyph_mapping_res *glyph_map;
    1.16 +struct minhack_window *windows=NULL;
    1.17 +int no_windows=0;
    1.18 +
    1.19 +static int v_hook(void)
    1.20 +{
    1.21 +    fprintf(stderr,"v_hook called\n");
    1.22 +}
    1.23 +
    1.24 +struct nhproxy_clnt_ext_procs minhack_ext_procs = {
    1.25 +    "minhack",
    1.26 +    minhack_init_nhwindows,
    1.27 +    minhack_player_selection,
    1.28 +    minhack_askname,
    1.29 +    NULL,			/* get_nh_event */
    1.30 +    minhack_exit_nhwindows,
    1.31 +    NULL,			/* suspend_nhwindows */
    1.32 +    NULL,			/* resume_nhwindows */
    1.33 +    minhack_create_nhwindow,
    1.34 +    minhack_clear_nhwindow,
    1.35 +    minhack_display_nhwindow,
    1.36 +    minhack_destroy_nhwindow,
    1.37 +    minhack_curs,
    1.38 +    minhack_putstr,
    1.39 +    minhack_display_file,
    1.40 +    minhack_start_menu,
    1.41 +    minhack_add_menu,
    1.42 +    minhack_end_menu,
    1.43 +    minhack_select_menu,
    1.44 +    minhack_message_menu,
    1.45 +    NULL,			/* update_inventory */
    1.46 +    NULL,			/* mark_sync */
    1.47 +    NULL,			/* wait_sync */
    1.48 +    NULL,			/* cliparound */
    1.49 +    NULL,			/* update_positionbar */
    1.50 +    minhack_print_glyph,
    1.51 +    minhack_raw_print,
    1.52 +    minhack_raw_print_bold,
    1.53 +    minhack_nhgetch,
    1.54 +    minhack_nh_poskey,
    1.55 +    NULL,			/* nhbell */
    1.56 +    NULL,			/* doprev_message */
    1.57 +    minhack_yn_function,
    1.58 +    minhack_getlin,
    1.59 +    minhack_get_ext_cmd,
    1.60 +    NULL,			/* number_pad */
    1.61 +    NULL,			/* delay_output */
    1.62 +    NULL,			/* change_color */
    1.63 +    NULL,			/* change_background */
    1.64 +    NULL,			/* set_font_name */
    1.65 +    NULL,			/* get_color_string */
    1.66 +    NULL,			/* start_screen,*/
    1.67 +    NULL,			/* end_screen,*/
    1.68 +    minhack_outrip,
    1.69 +    minhack_preference_update,
    1.70 +    NULL,			/* status */
    1.71 +    v_hook,			/* print_glyph_layered */
    1.72 +    minhack_send_config_file,
    1.73 +};
    1.74 +
    1.75 +int minhack_init_nhwindows(int *argc, char **argv, char ***capv)
    1.76 +{
    1.77 +    initscr();
    1.78 +    nonl();
    1.79 +    cbreak();
    1.80 +    noecho();
    1.81 +    refresh();
    1.82 +    glyph_map=nhproxy_cb_get_glyph_mapping();
    1.83 +    return nhproxy_true;
    1.84 +}
    1.85 +
    1.86 +int minhack_player_selection(int *role, int *race, int *gend, int *align)
    1.87 +{
    1.88 +    return nhproxy_false;
    1.89 +}
    1.90 +
    1.91 +char *minhack_askname(void)
    1.92 +{
    1.93 +    return "ali";
    1.94 +}
    1.95 +
    1.96 +void minhack_exit_nhwindows(const char *str)
    1.97 +{
    1.98 +    endwin();
    1.99 +    minhack_raw_print(str);
   1.100 +}
   1.101 +
   1.102 +void minhack_curs(int window, int x, int y)
   1.103 +{
   1.104 +    wmove(windows[window].win,y,x);
   1.105 +}
   1.106 +
   1.107 +void minhack_putstr(int window, int attr, const char *str)
   1.108 +{
   1.109 +    waddstr(windows[window].win,str);
   1.110 +}
   1.111 +
   1.112 +void minhack_display_file(int fh)
   1.113 +{
   1.114 +    /* FIXME: Implement */
   1.115 +}
   1.116 +
   1.117 +void minhack_print_glyph(int id, int x, int y, int glyph)
   1.118 +{
   1.119 +    struct nhproxy_glyph_map_info info;
   1.120 +    struct nhproxy_glyph_mapping *map;
   1.121 +    map=nhproxy_glyph_map_first(&info,glyph_map);
   1.122 +    while(glyph--)
   1.123 +	map=nhproxy_glyph_map_next(&info);
   1.124 +    mvwaddch(windows[id].win,y,x,map->rgbsym&0xFF);
   1.125 +    nhproxy_glyph_map_close(&info);
   1.126 +}
   1.127 +
   1.128 +void minhack_raw_print(const char *str)
   1.129 +{
   1.130 +    if (*str)
   1.131 +	puts(str);
   1.132 +}
   1.133 +
   1.134 +void minhack_raw_print_bold(const char *str)
   1.135 +{
   1.136 +    minhack_raw_print(str);
   1.137 +}
   1.138 +
   1.139 +int minhack_nhgetch(void)
   1.140 +{
   1.141 +    int i;
   1.142 +    for(i=0;i<no_windows;i++)
   1.143 +	if (windows[i].win && windows[i].type!=NHPROXY_EXT_NHW_MENU &&
   1.144 +	  windows[i].type!=NHPROXY_EXT_NHW_TEXT)
   1.145 +	    wrefresh(windows[i].win);
   1.146 +    return getch();
   1.147 +}
   1.148 +
   1.149 +int minhack_nh_poskey(int *x, int *y, int *mod)
   1.150 +{
   1.151 +    return minhack_nhgetch();
   1.152 +}
   1.153 +
   1.154 +int minhack_outrip(int window, char *killed_by)
   1.155 +{
   1.156 +    return nhproxy_false;
   1.157 +}
   1.158 +
   1.159 +void minhack_preference_update(const char *optnam, const char *value)
   1.160 +{
   1.161 +}
   1.162 +
   1.163 +void minhack_send_config_file(int fh)
   1.164 +{
   1.165 +}