initial shim graphics
This commit is contained in:
@@ -64,7 +64,7 @@
|
||||
* Define the default window system. This should be one that is compiled
|
||||
* into your system (see defines above). Known window systems are:
|
||||
*
|
||||
* tty, X11, mac, amii, BeOS, Qt, Gem, Gnome
|
||||
* tty, X11, mac, amii, BeOS, Qt, Gem, Gnome, shim
|
||||
*/
|
||||
|
||||
/* MAC also means MAC windows */
|
||||
@@ -144,6 +144,12 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SHIM_GRAPHICS
|
||||
#ifndef DEFAULT_WINDOW_SYS
|
||||
#define DEFAULT_WINDOW_SYS "shim"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef X11_GRAPHICS
|
||||
/*
|
||||
* There are two ways that X11 tiles may be defined. (1) using a custom
|
||||
|
||||
@@ -130,6 +130,9 @@ static struct win_info window_opts[] = {
|
||||
#ifdef MSWIN_GRAPHICS /* win32 */
|
||||
{ "mswin", "Windows GUI", TRUE },
|
||||
#endif
|
||||
#ifdef SHIM_GRAPHICS
|
||||
{ "shim", "Nethack Library Windowing Shim", TRUE },
|
||||
#endif
|
||||
|
||||
#if 0 /* remainder have been retired */
|
||||
#ifdef GNOME_GRAPHICS /* unmaintained/defunct */
|
||||
|
||||
38
src/rip.c
38
src/rip.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 rip.c $NHDT-Date: 1597967808 2020/08/20 23:56:48 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.33 $ */
|
||||
/* NetHack 3.7 rip.c $NHDT-Date: 1596498204 2020/08/03 23:43:24 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.32 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2017. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "hack.h"
|
||||
|
||||
#if defined(TTY_GRAPHICS) || defined(X11_GRAPHICS) || defined(GEM_GRAPHICS) \
|
||||
|| defined(MSWIN_GRAPHICS) || defined(DUMPLOG) || defined(CURSES_GRAPHICS)
|
||||
|| defined(MSWIN_GRAPHICS) || defined(DUMPLOG) || defined(CURSES_GRAPHICS) || defined(SHIM_GRAPHICS)
|
||||
#define TEXT_TOMBSTONE
|
||||
#endif
|
||||
#if defined(mac) || defined(__BEOS__) || defined(WIN32_GRAPHICS)
|
||||
@@ -60,10 +60,12 @@ static const char *rip_txt[] = {
|
||||
};
|
||||
#define STONE_LINE_CENT 19 /* char[] element of center of stone face */
|
||||
#endif /* NH320_DEDICATION */
|
||||
#define STONE_LINE_LEN 16 /* # chars that fit on one line
|
||||
* (note 1 ' ' border) */
|
||||
#define NAME_LINE 6 /* *char[] line # for player name */
|
||||
#define GOLD_LINE 7 /* *char[] line # for amount of gold */
|
||||
#define STONE_LINE_LEN \
|
||||
16 /* # chars that fit on one line \
|
||||
* (note 1 ' ' border) \
|
||||
*/
|
||||
#define NAME_LINE 6 /* *char[] line # for player name */
|
||||
#define GOLD_LINE 7 /* *char[] line # for amount of gold */
|
||||
#define DEATH_LINE 8 /* *char[] line # for death description */
|
||||
#define YEAR_LINE 12 /* *char[] line # for year */
|
||||
|
||||
@@ -88,9 +90,9 @@ time_t when;
|
||||
register char **dp;
|
||||
register char *dpx;
|
||||
char buf[BUFSZ];
|
||||
long year;
|
||||
register int x;
|
||||
int line, year;
|
||||
long cash;
|
||||
int line;
|
||||
|
||||
g.rip = dp = (char **) alloc(sizeof(rip_txt));
|
||||
for (x = 0; rip_txt[x]; ++x)
|
||||
@@ -98,15 +100,13 @@ time_t when;
|
||||
dp[x] = (char *) 0;
|
||||
|
||||
/* Put name on stone */
|
||||
Sprintf(buf, "%.*s", (int) STONE_LINE_LEN, g.plname);
|
||||
Sprintf(buf, "%s", g.plname);
|
||||
buf[STONE_LINE_LEN] = 0;
|
||||
center(NAME_LINE, buf);
|
||||
|
||||
/* Put $ on stone */
|
||||
cash = max(g.done_money, 0L);
|
||||
/* arbitrary upper limit; practical upper limit is quite a bit less */
|
||||
if (cash > 999999999L)
|
||||
cash = 999999999L;
|
||||
Sprintf(buf, "%ld Au", cash);
|
||||
Sprintf(buf, "%ld Au", g.done_money);
|
||||
buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */
|
||||
center(GOLD_LINE, buf);
|
||||
|
||||
/* Put together death description */
|
||||
@@ -114,11 +114,11 @@ time_t when;
|
||||
|
||||
/* Put death type on stone */
|
||||
for (line = DEATH_LINE, dpx = buf; line < YEAR_LINE; line++) {
|
||||
register int i, i0;
|
||||
char tmpchar;
|
||||
int i, i0 = (int) strlen(dpx);
|
||||
|
||||
if (i0 > STONE_LINE_LEN) {
|
||||
for (i = STONE_LINE_LEN; (i > 0) && (i0 > STONE_LINE_LEN); --i)
|
||||
if ((i0 = strlen(dpx)) > STONE_LINE_LEN) {
|
||||
for (i = STONE_LINE_LEN; ((i0 > STONE_LINE_LEN) && i); i--)
|
||||
if (dpx[i] == ' ')
|
||||
i0 = i;
|
||||
if (!i)
|
||||
@@ -135,8 +135,8 @@ time_t when;
|
||||
}
|
||||
|
||||
/* Put year on stone */
|
||||
year = (int) ((yyyymmdd(when) / 10000L) % 10000L);
|
||||
Sprintf(buf, "%4d", year);
|
||||
year = yyyymmdd(when) / 10000L;
|
||||
Sprintf(buf, "%4ld", year);
|
||||
center(YEAR_LINE, buf);
|
||||
|
||||
#ifdef DUMPLOG
|
||||
|
||||
@@ -44,6 +44,9 @@ extern struct window_procs Gnome_procs;
|
||||
#ifdef MSWIN_GRAPHICS
|
||||
extern struct window_procs mswin_procs;
|
||||
#endif
|
||||
#ifdef SHIM_GRAPHICS
|
||||
extern struct window_procs shim_procs;
|
||||
#endif
|
||||
#ifdef WINCHAIN
|
||||
extern struct window_procs chainin_procs;
|
||||
extern void FDECL(chainin_procs_init, (int));
|
||||
@@ -128,6 +131,9 @@ static struct win_choices {
|
||||
#ifdef MSWIN_GRAPHICS
|
||||
{ &mswin_procs, 0 CHAINR(0) },
|
||||
#endif
|
||||
#ifdef SHIM_GRAPHICS
|
||||
{ &shim_procs, 0 CHAINR(0) },
|
||||
#endif
|
||||
#ifdef WINCHAIN
|
||||
{ &chainin_procs, chainin_procs_init, chainin_procs_chain },
|
||||
{ (struct window_procs *) &chainout_procs, chainout_procs_init,
|
||||
|
||||
161
win/shim/winshim.c
Normal file
161
win/shim/winshim.c
Normal file
@@ -0,0 +1,161 @@
|
||||
/* NetHack 3.7 winshim.c $NHDT-Date: 1596498345 2020/08/03 23:45:45 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.259 $ */
|
||||
/* Copyright (c) Adam Powers, 2020 */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
/* not an actual windowing port, but a fake win port for libnethack */
|
||||
|
||||
#include "hack.h"
|
||||
|
||||
#ifdef SHIM_GRAPHICS
|
||||
|
||||
enum win_types {
|
||||
WINSTUB_MESSAGE = 1,
|
||||
WINSTUB_MAP,
|
||||
WINSTUB_MENU,
|
||||
WINSTUB_EXT
|
||||
};
|
||||
|
||||
#define VSTUB(name, args) \
|
||||
void name args { \
|
||||
printf ("Running " #name "...\n"); \
|
||||
}
|
||||
|
||||
#define STUB(name, retval, args) \
|
||||
name args { \
|
||||
printf ("Running " #name "...\n"); \
|
||||
return retval; \
|
||||
}
|
||||
|
||||
#define DECL(name, args) \
|
||||
void name args;
|
||||
|
||||
VSTUB(shim_init_nhwindows,(int *argcp, char **argv))
|
||||
VSTUB(shim_player_selection,(void))
|
||||
VSTUB(shim_askname,(void))
|
||||
VSTUB(shim_get_nh_event,(void))
|
||||
VSTUB(shim_exit_nhwindows,(const char *a))
|
||||
VSTUB(shim_suspend_nhwindows,(const char *a))
|
||||
VSTUB(shim_resume_nhwindows,(void))
|
||||
winid STUB(shim_create_nhwindow, WINSTUB_MAP, (int a))
|
||||
VSTUB(shim_clear_nhwindow,(winid a))
|
||||
VSTUB(shim_display_nhwindow,(winid a, BOOLEAN_P b))
|
||||
VSTUB(shim_destroy_nhwindow,(winid a))
|
||||
VSTUB(shim_curs,(winid a, int x, int y))
|
||||
DECL(shim_putstr,(winid w, int attr, const char *str))
|
||||
VSTUB(shim_display_file,(const char *a, BOOLEAN_P b))
|
||||
VSTUB(shim_start_menu,(winid w, unsigned long mbehavior))
|
||||
VSTUB(shim_add_menu,(winid a, int b, const ANY_P *c, CHAR_P d, CHAR_P e, int f, const char *h, unsigned int k))
|
||||
VSTUB(shim_end_menu,(winid a, const char *b))
|
||||
int STUB(shim_select_menu,0,(winid a, int b, MENU_ITEM_P **c))
|
||||
char STUB(shim_message_menu,'y',(CHAR_P a, int b, const char *c))
|
||||
VSTUB(shim_update_inventory,(void))
|
||||
VSTUB(shim_mark_synch,(void))
|
||||
VSTUB(shim_wait_synch,(void))
|
||||
VSTUB(shim_cliparound,(int a, int b))
|
||||
VSTUB(shim_update_positionbar,(char *a))
|
||||
DECL(shim_print_glyph,(winid w, XCHAR_P x, XCHAR_P y, int glyph, int bkglyph))
|
||||
DECL(shim_raw_print,(const char *str))
|
||||
VSTUB(shim_raw_print_bold,(const char *a))
|
||||
int STUB(shim_nhgetch,0,(void))
|
||||
int STUB(shim_nh_poskey,0,(int *a, int *b, int *c))
|
||||
VSTUB(shim_nhbell,(void))
|
||||
int STUB(shim_doprev_message,0,(void))
|
||||
char STUB(shim_yn_function,'y',(const char *a, const char *b, CHAR_P c))
|
||||
VSTUB(shim_getlin,(const char *a, char *b))
|
||||
int STUB(shim_get_ext_cmd,0,(void))
|
||||
VSTUB(shim_number_pad,(int a))
|
||||
VSTUB(shim_delay_output,(void))
|
||||
VSTUB(shim_change_color,(int a, long b, int c))
|
||||
VSTUB(shim_change_background,(int a))
|
||||
short STUB(set_shim_font_name,0,(winid a, char *b))
|
||||
VSTUB(shim_get_color_string,(void))
|
||||
|
||||
/* other defs that really should go away (they're tty specific) */
|
||||
VSTUB(shim_start_screen, (void))
|
||||
VSTUB(shim_end_screen, (void))
|
||||
VSTUB(shim_preference_update, (const char *a))
|
||||
char *STUB(shim_getmsghistory, (char *)"", (BOOLEAN_P a))
|
||||
VSTUB(shim_putmsghistory, (const char *a, BOOLEAN_P b))
|
||||
VSTUB(shim_status_init, (void))
|
||||
VSTUB(shim_status_enablefield, (int a, const char *b, const char *c, BOOLEAN_P d))
|
||||
VSTUB(shim_status_update, (int a, genericptr_t b, int c, int d, int e, unsigned long *f))
|
||||
|
||||
|
||||
/* old: | WC_TILED_MAP */
|
||||
/* Interface definition, for windows.c */
|
||||
struct window_procs shim_procs = {
|
||||
"shim",
|
||||
(0
|
||||
| WC_ASCII_MAP
|
||||
| WC_COLOR | WC_HILITE_PET | WC_INVERSE | WC_EIGHT_BIT_IN),
|
||||
(0
|
||||
#if defined(SELECTSAVED)
|
||||
| WC2_SELECTSAVED
|
||||
#endif
|
||||
#if defined(STATUS_HILITES)
|
||||
| WC2_HILITE_STATUS | WC2_HITPOINTBAR | WC2_FLUSH_STATUS
|
||||
| WC2_RESET_STATUS
|
||||
#endif
|
||||
| WC2_DARKGRAY | WC2_SUPPRESS_HIST | WC2_STATUSLINES),
|
||||
#ifdef TEXTCOLOR
|
||||
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
|
||||
#else
|
||||
{1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1},
|
||||
#endif
|
||||
shim_init_nhwindows, shim_player_selection, shim_askname, shim_get_nh_event,
|
||||
shim_exit_nhwindows, shim_suspend_nhwindows, shim_resume_nhwindows,
|
||||
shim_create_nhwindow, shim_clear_nhwindow, shim_display_nhwindow,
|
||||
shim_destroy_nhwindow, shim_curs, shim_putstr, genl_putmixed,
|
||||
shim_display_file, shim_start_menu, shim_add_menu, shim_end_menu,
|
||||
shim_select_menu, shim_message_menu, shim_update_inventory, shim_mark_synch,
|
||||
shim_wait_synch,
|
||||
#ifdef CLIPPING
|
||||
shim_cliparound,
|
||||
#endif
|
||||
#ifdef POSITIONBAR
|
||||
shim_update_positionbar,
|
||||
#endif
|
||||
shim_print_glyph, shim_raw_print, shim_raw_print_bold, shim_nhgetch,
|
||||
shim_nh_poskey, shim_nhbell, shim_doprev_message, shim_yn_function,
|
||||
shim_getlin, shim_get_ext_cmd, shim_number_pad, shim_delay_output,
|
||||
#ifdef CHANGE_COLOR /* the Mac uses a palette device */
|
||||
shim_change_color,
|
||||
#ifdef MAC
|
||||
shim_change_background, set_shim_font_name,
|
||||
#endif
|
||||
shim_get_color_string,
|
||||
#endif
|
||||
|
||||
/* other defs that really should go away (they're tty specific) */
|
||||
shim_start_screen, shim_end_screen, genl_outrip,
|
||||
shim_preference_update,
|
||||
shim_getmsghistory, shim_putmsghistory,
|
||||
shim_status_init,
|
||||
genl_status_finish, genl_status_enablefield,
|
||||
#ifdef STATUS_HILITES
|
||||
shim_status_update,
|
||||
#else
|
||||
genl_status_update,
|
||||
#endif
|
||||
genl_can_suspend_yes,
|
||||
};
|
||||
|
||||
void shim_print_glyph(winid w, XCHAR_P x, XCHAR_P y, int glyph, int bkglyph) {
|
||||
/* map glyph to character and color */
|
||||
// (void) mapglyph(glyph, &ch, &color, &special, x, y, 0);
|
||||
|
||||
fprintf(stdout, "shim_print_glyph (%d,%d): %c\n", x,y,(char)glyph);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void shim_raw_print(const char *str) {
|
||||
fprintf(stdout, "shim_raw_print: %s\n", str);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void shim_putstr(winid w, int attr, const char *str) {
|
||||
fprintf(stdout, "shim_putstr (win %d): %s\n", w, str);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
#endif /* SHIM_GRAPHICS */
|
||||
Reference in New Issue
Block a user