initial shim graphics

This commit is contained in:
Adam Powers
2020-08-26 19:17:40 -07:00
committed by nhmall
parent ef6978ec51
commit 741e6fd5b7
5 changed files with 196 additions and 20 deletions

View File

@@ -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 */

View File

@@ -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

View File

@@ -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,