home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: vmsnet.sources.games
- Path: uunet!zaphod.mps.ohio-state.edu!rpi!usenet.coe.montana.edu!news.u.washington.edu!raven.alaska.edu!acad2.alaska.edu!asdmf
- From: asdmf@acad2.alaska.edu
- Subject: Vmsnetrek 45/47
- Message-ID: <1992Nov20.210948.1@acad2.alaska.edu>
- Lines: 495
- Sender: news@raven.alaska.edu (USENET News System)
- Nntp-Posting-Host: acad2.alaska.edu
- Organization: University of Alaska
- Date: Sat, 21 Nov 1992 01:09:48 GMT
- Xref: uunet vmsnet.sources.games:545
-
- -+-+-+-+-+-+-+-+ START OF PART 45 -+-+-+-+-+-+-+-+
- X`009W_WriteText(war, 0, menunum, gColor, buf, strlen(buf), 0);
- X `125
- X`125
- X
- Xwaraction(data)
- XW_Event *data;
- X`123
- X int enemyteam;
- X
- X if (data->y == 4) `123
- X`009W_UnmapWindow(war);
- X`009sendWarReq(newhostile);
- X`009return;
- X `125
- X
- X if (data->y == 5) `123
- X`009W_UnmapWindow(war);
- X`009return;
- X `125
- X if (data->y == 0) enemyteam=FED;
- X if (data->y == 1) enemyteam=ROM;
- X if (data->y == 2) enemyteam=KLI;
- X if (data->y == 3) enemyteam=ORI;
- X
- X if (me->p_swar & enemyteam) `123
- X`009warning("You are already at war!");
- X`009W_Beep();
- X `125 else `123
- X`009if (me->p_team == enemyteam) `123
- X`009 warning("It would never work ... your crew would have you in the bri
- Vg in no time.");
- X`009`125 else `123
- X`009 newhostile `094= enemyteam;
- X`009`125
- X `125
- X warrefresh();
- X`125
- X
- $ CALL UNPACK WAR.C;1 1529531742
- $ create/nolog 'f'
- X/*
- X * warning.c
- X */
- X#include "copyright.h"
- X
- X#include <stdio.h>
- X#include <math.h>
- X#include <signal.h>
- X#include "Wlib.h"
- X#include "defs.h"
- X#include "struct.h"
- X#include "data.h"
- X
- X/*
- X** The warning in text will be printed in the warning window.
- X** The message will last WARNTIME/10 seconds unless another message
- X** comes through and overwrites it.
- X*/
- Xwarning(text)
- Xchar *text;
- X`123
- X warntimer = udcounter + WARNTIME; /* set the line to be cleared */
- X
- X if (warncount > 0) `123
- X`009W_ClearArea(warnw, 5,5, W_Textwidth*warncount, W_Textheight,backColor);
- X `125
- X warncount = strlen(text);
- X W_WriteText(warnw, 5, 5, textColor, text, warncount, W_RegularFont);
- X`125
- $ CALL UNPACK WARNING.C;1 773588199
- $ create/nolog 'f'
- X/* Wlib.h
- X *
- X * Include file for the Windowing interface.
- X *
- X * Kevin P. Smith 6/11/89
- X *`032
- X * The deal is this:
- X * Call W_Initialize(), and then you may call any of the listed fuinctions
- V.
- X * Also, externals you are allowed to pass or use include W_BigFont,
- X * W_RegularFont, W_UnderlineFont, W_HighlightFont, W_White, W_Black,
- X * W_Red, W_Green, W_Yellow, W_Cyan, W_Grey, W_Textwidth, and W_Textheig
- Vht.
- X */
- X#include "copyright2.h"
- X
- Xtypedef char *W_Window;
- Xtypedef char *W_Icon;
- Xtypedef char *W_Font;
- Xtypedef int W_Color;
- X
- Xextern W_Font W_BigFont, W_RegularFont, W_UnderlineFont, W_HighlightFont;
- Xextern W_Color W_White, W_Black, W_Red, W_Green, W_Yellow, W_Cyan, W_Grey;
- Xextern int W_Textwidth, W_Textheight;
- Xextern int W_FastClear;
- X
- Xextern void W_Initialize(/* display */);
- Xextern W_Window W_MakeWindow(/* name, x, y, width, height, parent, border, c
- Volor */);
- Xextern W_Icon W_StoreBitmap(/* width, height, data, window */);
- Xextern W_Window W_MakeTextWindow(/* name, x, y, width, height, parent, borde
- Vr */);
- Xextern W_Window W_MakeScrollingWindow(/* name, x, y, width, height, parent,b
- Vorder */);
- Xextern W_Window W_MakeMenu(/* name, x, y, width, height, parent, border */);
- Xextern void W_WriteText(/* window, x, y, color, str, length, font */);
- Xextern void W_MaskText(/* window, x, y, color, str, length, font */);
- Xextern void W_WriteBitmap(/* x, y, icon, color */);
- Xextern void W_ClearArea(/* window, x, y, width, height, color */);
- Xextern void W_MakeLine(/* window, x0, y0, x1, y1, color */);
- Xextern void W_MapWindow(/* window */);
- Xextern void W_UnmapWindow(/* window */);
- Xextern int W_EventsPending(/* void */);
- Xextern void W_NextEvent(/* W_Event *event */);
- Xextern void W_TileWindow(/* window, bitmap */);
- Xextern void W_UnTileWindow(/* window */);
- Xextern void W_ChangeBorder(/* window, color */);
- Xextern void W_DefineCursor(/* window, width, height, data, mask, xhot, yhot
- V */);
- Xextern int W_IsMapped(/* window */);
- Xextern void W_Beep(/* void */);
- Xextern void W_DestroyWindow(/* window */);
- Xextern int W_WindowWidth(/* window */);
- Xextern int W_WindowHeight(/* window */);
- Xextern int W_Socket(/* void */);
- Xextern void W_ClearWindow(/* window */);
- Xextern void W_SetIconWindow(/* mainwindow, iconwindow */);
- X
- X#define W_EV_EXPOSE`0091
- X#define W_EV_KEY`0092
- X#define W_EV_BUTTON`0093
- X
- X#define W_LBUTTON`0091
- X#define W_MBUTTON`0092
- X#define W_RBUTTON`0093
- X
- Xtypedef struct event `123
- X`009int`009type;
- X`009W_Window Window;
- X`009int`009key;
- X`009int`009x,y;
- X`125 W_Event;
- X
- X#define W_BoldFont W_HighlightFont
- $ CALL UNPACK WLIB.H;1 1903131216
- $ create/nolog 'f'
- X/* x11window.c
- X *
- X * Kevin P. Smith 6/11/89
- X */
- X#include "copyright2.h"
- X#include <stdio.h>
- X#include <assert.h>
- X#include "Wlib.h"
- X#include <x11/xlib.h>
- X#include <x11/xutil.h>
- X
- X#define FONTS 4
- X#define BITGC 4
- X
- X#define WHITE 0
- X#define BLACK 1
- X#define RED 2
- X#define GREEN 3
- X#define YELLOW 4
- X#define CYAN 5
- X#define GREY`0096
- X
- Xstatic int zero=0;
- Xstatic int one=1;
- Xstatic int two=2;
- Xstatic int three=3;
- Xint W_FastClear=0;
- X
- XDisplay *W_Display;
- XWindow W_Root;
- XColormap W_Colormap;
- Xint W_Screen;
- XW_Font W_BigFont= (W_Font) &zero, W_RegularFont= (W_Font) &one;
- XW_Font W_HighlightFont= (W_Font) &two, W_UnderlineFont= (W_Font) &three;
- XW_Color W_White=WHITE, W_Black=BLACK, W_Red=RED, W_Green=GREEN;
- XW_Color W_Yellow=YELLOW, W_Cyan=CYAN, W_Grey=GREY;
- Xint W_Textwidth, W_Textheight;
- Xchar *getdefault();
- Xchar *strdup();
- X
- Xstatic XClassHint class_hint = `123
- X`009"netrek", "Netrek",
- X`125;
- X
- Xstatic XWMHints wm_hint = `123
- X InputHint, 1,`032
- X`125; `032
- X
- Xstatic W_Event W_myevent;
- Xstatic int W_isEvent=0;
- X
- Xstruct fontInfo `123
- X int baseline;
- X`125;
- X
- Xstruct colors `123
- X char *name;
- X GC contexts`091FONTS+1`093;
- X Pixmap pixmap;
- X int pixelValue;
- X`125;
- X
- Xstruct icon `123
- X Window window;
- X Pixmap bitmap;
- X int width, height;
- X Pixmap pixmap;
- X`125;
- X
- X#define WIN_GRAPH`0091
- X#define WIN_TEXT`0092
- X#define WIN_MENU`0093
- X#define WIN_SCROLL`0094
- X
- Xstruct window `123
- X Window window;
- X int type;
- X char *data;
- X int mapped;
- X int width,height;
- X char *name;
- X`125;
- X
- Xstruct stringList `123
- X char *string;
- X W_Color color;
- X struct stringList *next;
- X`125;
- X
- Xstruct menuItem `123
- X char *string;
- X W_Color color;
- X`125;
- X
- Xstruct colors colortable`091`093 = `123
- X `123 "white" `009 `125,
- X `123 "black"`009 `125,
- X `123 "red" `009 `125,
- X `123 "green" `009 `125,
- X `123 "yellow" `009 `125,
- X `123 "cyan" `009 `125,
- X `123 "light grey" `125
- X`125;
- X
- Xstruct windowlist `123
- X struct window *window;
- X struct windowlist *next;
- X`125;
- X
- X#define HASHSIZE 29
- X#define hash(x) (((int) (x)) % HASHSIZE)
- X
- Xstruct windowlist *hashtable`091HASHSIZE`093;
- Xstruct fontInfo fonts`091FONTS`093;
- X
- Xstruct window *newWindow();
- Xstruct window *findWindow();
- Xchar *malloc();
- Xshort *x11tox10bits();
- X
- Xstruct window myroot;
- X
- X#define NCOLORS (sizeof(colortable)/sizeof(colortable`0910`093))
- X#define W_Void2Window(win) ((win) ? (struct window *) (win) : &myroot)
- X#define W_Window2Void(window) ((W_Window) (window))
- X#define W_Void2Icon(bit) ((struct icon *) (bit))
- X#define W_Icon2Void(bit) ((W_Icon) (bit))
- X#define fontNum(font) (*((int *) font))
- X#define TILESIDE 16
- X
- X#define WIN_EDGE 5`009/* border on l/r edges of text windows */
- X#define MENU_PAD 4`009/* border on t/b edges of text windows */
- X#define MENU_BAR 4`009/* width of menu bar */
- X
- Xstatic char gray`091`093 = `123
- X`0090xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55,
- X`0090xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55,
- X`0090xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55,
- X`0090xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55
- X`125;
- X
- Xstatic char striped`091`093 = `123
- X`0090x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,
- X`0090xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f,
- X`0090xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00,
- X`0090x0f, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0
- X`125;
- X
- Xstatic char solid`091`093 = `123
- X`0090xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- X`0090xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- X`0090xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- X`0090xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
- X`125;
- X
- Xvoid W_Initialize(str)
- Xchar *str;
- X`123
- X int i;
- X
- X#ifdef DEBUG
- X printf("Initializing...\n");
- X#endif
- X#ifdef VMS
- X /* for some reason we can't specify anything but NULL in XOpenDisplay un
- Vder VMS */
- X str = NULL;
- X#endif
- X for (i=0; i<HASHSIZE; i++) `123
- X`009hashtable`091i`093=NULL;
- X `125
- X if ((W_Display = XOpenDisplay(str)) == NULL) `123
- X`009fprintf(stderr, "I cannot open your display!\n");
- X`009exit(1);
- X `125
- X
- X /*XSynchronize(W_Display, True);*/
- X W_Root=DefaultRootWindow(W_Display);
- X W_Screen=DefaultScreen(W_Display);
- X W_Colormap=DefaultColormap(W_Display, W_Screen);
- X myroot.window=W_Root;
- X myroot.type=WIN_GRAPH;
- X
- X GetFonts();
- X GetColors();
- X
- X`125
- X
- XGetFonts()
- X`123
- X Font regular, italic, bold, big;
- X int i,j;
- X XGCValues values;
- X XFontStruct *fontinfo;
- X char *fontname;
- X
- X fontname=getdefault("font");
- X if (fontname==NULL)
- X fontname="sys$common:`091sysfont.decw.common`093decw$font_directory_comm
- Von.dat;2";
- X fontinfo=XLoadQueryFont(W_Display, fontname);
- X if (fontinfo==NULL) `123
- X`009printf("Couldn't find 6x10 font!\n");
- X`009exit(1);
- X `125
- X regular=fontinfo->fid;
- X W_Textwidth=fontinfo->max_bounds.width;
- X W_Textheight=fontinfo->max_bounds.descent+fontinfo->max_bounds.ascent;
- X fonts`0911`093.baseline=fontinfo->max_bounds.ascent;
- X
- X fontname=getdefault("boldfont");
- X if (fontname==NULL) fontname="6x10B";
- X fontinfo=XLoadQueryFont(W_Display, fontname);
- X if (fontinfo==NULL) `123
- X`009bold=regular;
- X`009fonts`0912`093.baseline=fonts`0911`093.baseline;
- X `125 else `123
- X`009bold=fontinfo->fid;
- X`009fonts`0912`093.baseline=fontinfo->max_bounds.ascent;
- X`009if (fontinfo->max_bounds.width > W_Textwidth)`032
- X`009 W_Textwidth=fontinfo->max_bounds.width;
- X`009if (fontinfo->max_bounds.descent+fontinfo->max_bounds.ascent > W_Texthei
- Vght)
- X`009 W_Textheight=fontinfo->max_bounds.descent+fontinfo->max_bounds.ascen
- Vt;
- X `125
- X
- X fontname=getdefault("italicfont");
- X if (fontname==NULL) fontname="6x10I";
- X fontinfo=XLoadQueryFont(W_Display, "6x10I");
- X if (fontinfo==NULL) `123
- X`009italic=regular;
- X`009fonts`0913`093.baseline=fonts`0911`093.baseline;
- X `125 else `123
- X`009italic=fontinfo->fid;
- X`009fonts`0913`093.baseline=fontinfo->max_bounds.ascent;
- X`009if (fontinfo->max_bounds.width > W_Textwidth)`032
- X`009 W_Textwidth=fontinfo->max_bounds.width;
- X`009if (fontinfo->max_bounds.descent+fontinfo->max_bounds.ascent > W_Texthei
- Vght)
- X`009 W_Textheight=fontinfo->max_bounds.descent+fontinfo->max_bounds.ascen
- Vt;
- X `125
- X
- X fontname=getdefault("bigfont");
- X if (fontname==NULL) fontname="charB24";
- X fontinfo=XLoadQueryFont(W_Display, fontname);
- X if (fontinfo==NULL) `123
- X`009big=regular;
- X`009fonts`0910`093.baseline=fonts`0911`093.baseline;
- X `125 else `123
- X`009big=fontinfo->fid;
- X`009fonts`0910`093.baseline=fontinfo->max_bounds.ascent;
- X `125
- X for (i=0; i<NCOLORS; i++) `123
- X`009values.font=big;
- X`009colortable`091i`093.contexts`0910`093=XCreateGC(W_Display, W_Root, GCFon
- Vt, &values);
- X`009values.font=regular;
- X`009colortable`091i`093.contexts`0911`093=XCreateGC(W_Display, W_Root, GCFon
- Vt, &values);
- X`009values.font=bold;
- X`009colortable`091i`093.contexts`0912`093=XCreateGC(W_Display, W_Root, GCFon
- Vt, &values);
- X`009values.font=italic;
- X`009colortable`091i`093.contexts`0913`093=XCreateGC(W_Display, W_Root, GCFon
- Vt, &values);
- X`009values.function=GXor;
- X`009colortable`091i`093.contexts`091BITGC`093=XCreateGC(W_Display, W_Root, G
- VCFunction,
- X`009 &values);
- X `125
- X`125
- X
- XGetColors()
- X`123
- X int i,j;
- X XColor foo;
- X int white, black;
- X unsigned long pixel;
- X unsigned long planes`0913`093;
- X char defaultstring`091100`093;
- X char *defaults;
- X
- X if (DisplayCells(W_Display, W_Screen) <= 2) `123
- X`009white=WhitePixel(W_Display, W_Screen);
- X`009black=BlackPixel(W_Display, W_Screen);
- X`009for (i=0; i<NCOLORS; i++) `123
- X`009 if (i != W_Black) `123
- X`009`009colortable`091i`093.pixelValue=white;
- X`009 `125 else `123
- X`009`009colortable`091i`093.pixelValue=black;
- X`009 `125
- X`009 if (i==W_Red) `123
- X`009`009colortable`091i`093.pixmap=XCreatePixmapFromBitmapData(W_Display,
- X`009`009 W_Root, striped, TILESIDE, TILESIDE,
- X`009`009 white, black,
- X`009`009 DefaultDepth(W_Display, W_Screen));
- X`009 `125 else if (i==W_Yellow) `123
- X`009`009colortable`091i`093.pixmap=XCreatePixmapFromBitmapData(W_Display,
- X`009`009 W_Root, gray, TILESIDE, TILESIDE,
- X`009`009 white, black,
- X`009`009 DefaultDepth(W_Display, W_Screen));
- X`009 `125 else `123
- X`009`009colortable`091i`093.pixmap=XCreatePixmapFromBitmapData(W_Display,
- X`009`009 W_Root, solid, TILESIDE, TILESIDE,`032
- X`009`009 colortable`091i`093.pixelValue,
- X`009`009 colortable`091i`093.pixelValue,`032
- X`009`009 DefaultDepth(W_Display, W_Screen));
- X`009 `125
- X`009 /* We assume white is 0 or 1, and black is 0 or 1.
- X`009 * We adjust graphics function based upon who is who.
- X`009 */
- X`009 if (white==0) `123`009/* Black is 1 */
- X`009`009XSetFunction(W_Display, colortable`091i`093.contexts`091BITGC`093,`0
- V32
- X`009`009 GXand);
- X`009 `125
- X`009`125
- X `125 else `123
- X`009XAllocColorCells(W_Display, W_Colormap, False, planes, 3, &pixel, 1);
- X`009for (i=0; i<NCOLORS; i++) `123
- X`009 sprintf(defaultstring, "color.%s", colortable`091i`093.name);
- X`009 defaults=getdefault(defaultstring);
- X`009 if (defaults==NULL) defaults=colortable`091i`093.name;
- X`009 XParseColor(W_Display, W_Colormap, defaults, &foo);
- X`009 /* Black must be the color with all the planes off.
- X`009 * That is the only restriction I concerned myself with in
- X`009 * the following case statement.
- X`009 */
- X`009 switch(i) `123
- X`009 case WHITE:
- X`009`009foo.pixel=pixel`124planes`0910`093`124planes`0911`093`124planes`0912
- V`093;
- X`009`009break;
- X`009 case BLACK:
- X`009`009foo.pixel=pixel;
- X`009`009break;
- X`009 case RED:
- X`009`009foo.pixel=pixel`124planes`0910`093;
- X`009`009break;
- X`009 case CYAN:
- X`009`009foo.pixel=pixel`124planes`0911`093;
- X`009`009break;
- X`009 case YELLOW:
- X`009`009foo.pixel=pixel`124planes`0912`093;
- +-+-+-+-+-+-+-+- END OF PART 45 +-+-+-+-+-+-+-+-
-