diff -bw -c -r civ-0.5/pic/elvis.xpm civ-0.5a/pic/elvis.xpm *** civ-0.5/pic/elvis.xpm Fri Jul 18 20:37:14 1997 --- civ-0.5a/pic/elvis.xpm Mon Nov 17 15:10:58 1997 *************** *** 1,22 **** /* XPM */ static char *elvis_xpm[] = { ! "8 12 6 1", "0 c #8b8b00000000", "+ c #c8c898986060", "o c #e8e8e8e8e8e8", - "X c #78788c8cfcfc", ". c None", "O c #8c8c58582828", ! "..000XXX", ! "XX0O0X.+", ! "..O+OXXo", ! "XXoOoXoo", ".oooooo.", "oOOOOo..", "oOO0OOOO", ! "XoOOOX.X", ! "X.oooX..", ! "XXoXoXX.", ! "..oX.o.X", ! ".00X.0XX" }; --- 1,21 ---- /* XPM */ static char *elvis_xpm[] = { ! "8 12 5 1", "0 c #8b8b00000000", "+ c #c8c898986060", "o c #e8e8e8e8e8e8", ". c None", "O c #8c8c58582828", ! "..000...", ! "..0O0..+", ! "..O+O..o", ! "..oOo.oo", ".oooooo.", "oOOOOo..", "oOO0OOOO", ! ".oOOO...", ! "..ooo...", ! "..o.o...", ! "..o..o..", ! ".00..0.." }; diff -bw -c -r civ-0.5/src/X11Displays.cc civ-0.5a/src/X11Displays.cc *** civ-0.5/src/X11Displays.cc Fri Oct 17 10:10:03 1997 --- civ-0.5a/src/X11Displays.cc Mon Nov 17 14:35:25 1997 *************** *** 80,85 **** --- 80,89 ---- XFlush(dpy); } + void X11DisplayData::ChangeColorMap() { + XSetWindowColormap(dpy, frame, screen->colormap); + } + void X11DisplayData::WriteStr(int x, int y, char *str, int color) { XSetForeground(dpy, screen->gc, color); diff -bw -c -r civ-0.5/src/X11Displays.h civ-0.5a/src/X11Displays.h *** civ-0.5/src/X11Displays.h Fri Oct 17 10:09:56 1997 --- civ-0.5a/src/X11Displays.h Mon Nov 17 14:34:40 1997 *************** *** 21,26 **** --- 21,27 ---- void WriteStr(int x, int y, char *str, int color); virtual void ExposeNotify(int x, int y, int width, int height) = 0; + void ChangeColorMap(); X11Screen *screen; Display *dpy; diff -bw -c -r civ-0.5/src/X11Screen.cc civ-0.5a/src/X11Screen.cc *** civ-0.5/src/X11Screen.cc Fri Oct 17 10:10:03 1997 --- civ-0.5a/src/X11Screen.cc Mon Nov 17 14:53:22 1997 *************** *** 4,9 **** --- 4,11 ---- #include "X11Screen.h" #include + #include "misc.h" + #include "display.h" X11Screen::X11Screen(int argc, char **argv) {;} *************** *** 47,63 **** return dest; } PixmapInfo *X11Screen::CompilePixmap(char **data) { Pixmap shape, image; XpmAttributes xpmatts; ! xpmatts.valuemask = 0; // FIXME: DefaultRootWindow is an approximation ! #ifdef BIGPIXMAPS ! XpmCreatePixmapFromData(dpy, DefaultRootWindow(dpy) , BigPixmap(data), &image, &shape, &xpmatts); ! #else ! XpmCreatePixmapFromData(dpy, DefaultRootWindow(dpy) , data, &image, &shape, &xpmatts); #endif if (!image) return NULL; PixmapInfo *info = new PixmapInfo; if (info) { --- 49,99 ---- return dest; } + void FreeBigPic(char **pic) { + int i, height, colors; + sscanf(pic[0], "%*d %d %d %*d", &height, &colors); + delete []pic[0]; + for (i = 0; i < height/2; i++) + delete []pic[colors+1+2*i]; + delete []pic; + } + + void X11Screen::SwitchColorMap() { + if (!DefaultColorMap) + Error("Color Map Full\n"); + DefaultColorMap = FALSE; + colormap = XCopyColormapAndFree(dpy, colormap); + for (Lister l = windows; l; l.Next()) + l.Elem()->ChangeColorMap(); + } + PixmapInfo *X11Screen::CompilePixmap(char **data) { Pixmap shape, image; XpmAttributes xpmatts; ! xpmatts.valuemask = XpmCloseness | XpmColormap; ! xpmatts.closeness = 40000; // some slack if the color isn't quite right ! xpmatts.colormap = colormap; ! int error; ! ! #ifdef BIGPIXMAPS ! data = BigPixmap(data); ! #endif ! // FIXME: DefaultRootWindow is an approximation ! + while ((error = XpmCreatePixmapFromData(dpy, DefaultRootWindow(dpy), data, + &image, &shape, &xpmatts)) + != XpmSuccess) { + if (error == XpmColorError || error == XpmColorFailed) { + SwitchColorMap(); + xpmatts.colormap = colormap; + } else + Error("Compile Pixmap Failed\n"); + } #ifdef BIGPIXMAPS ! FreeBigPic(data); #endif + if (!image) return NULL; PixmapInfo *info = new PixmapInfo; if (info) { diff -bw -c -r civ-0.5/src/X11Screen.h civ-0.5a/src/X11Screen.h *** civ-0.5/src/X11Screen.h Fri Oct 17 10:09:56 1997 --- civ-0.5a/src/X11Screen.h Mon Nov 17 14:28:28 1997 *************** *** 23,33 **** virtual void FreePixmap(PixmapInfo *handle); virtual void GetPixmapInfo(PixmapInfo *handle, int &w, int &h); //protected: Display *dpy; - Colormap colormap; GC gc; }; struct PixmapInfo { --- 23,38 ---- virtual void FreePixmap(PixmapInfo *handle); virtual void GetPixmapInfo(PixmapInfo *handle, int &w, int &h); + Colormap colormap; + //protected: + void SwitchColorMap(); + int DefaultColorMap; + Display *dpy; GC gc; + static Window MainWindow; }; struct PixmapInfo { diff -bw -c -r civ-0.5/src/XawDisplays.cc civ-0.5a/src/XawDisplays.cc *** civ-0.5/src/XawDisplays.cc Fri Oct 17 10:38:32 1997 --- civ-0.5a/src/XawDisplays.cc Mon Nov 17 14:41:04 1997 *************** *** 45,50 **** --- 45,51 ---- else shell = XtAppCreateShell("shell", name, shellWidgetClass, dpy, NULL, 0); + XtVaSetValues(shell, XtNcolormap, Xawscreen->colormap, NULL); XawFrame = XtCreateManagedWidget("frame", formWidgetClass, shell, NULL, 0); topbox = XtVaCreateManagedWidget("box", boxWidgetClass, XawFrame, XtNorientation, XtorientHorizontal, diff -bw -c -r civ-0.5/src/XawScreen.cc civ-0.5a/src/XawScreen.cc *** civ-0.5/src/XawScreen.cc Fri Oct 17 10:10:03 1997 --- civ-0.5a/src/XawScreen.cc Mon Nov 17 14:57:35 1997 *************** *** 83,88 **** --- 83,89 ---- | GCClipMask, &gcvalues); colormap = DefaultColormap(dpy, DefaultScreen(dpy)); + DefaultColorMap = TRUE; // place to hold read handlers readHandlers = new ReadHandlerP[FD_SETSIZE]; diff -bw -c -r civ-0.5/src/XvDisplays.cc civ-0.5a/src/XvDisplays.cc *** civ-0.5/src/XvDisplays.cc Fri Oct 17 10:10:04 1997 --- civ-0.5a/src/XvDisplays.cc Mon Nov 17 15:02:47 1997 *************** *** 191,196 **** --- 191,197 ---- { xv_set(XvFrame, XV_SHOW, TRUE, NULL); frame = xv_get(XvFrame, XV_XID); + XSetWindowColormap(dpy, frame, Xvscreen->colormap); } void XvDisplayData::ExposeNotify(int x, int y, int width, int height) { diff -bw -c -r civ-0.5/src/XvScreen.cc civ-0.5a/src/XvScreen.cc *** civ-0.5/src/XvScreen.cc Fri Oct 17 10:10:04 1997 --- civ-0.5a/src/XvScreen.cc Mon Nov 17 14:57:12 1997 *************** *** 134,139 **** --- 134,140 ---- | GCClipMask, &gcvalues); colormap = DefaultColormap(dpy, DefaultScreen(dpy)); + DefaultColorMap = TRUE; readHandlers = new ReadHandlerP[FD_SETSIZE]; for (int i = 0; i < (int)FD_SETSIZE; ++i) diff -bw -c -r civ-0.5/src/display.cc civ-0.5a/src/display.cc *** civ-0.5/src/display.cc Fri Oct 17 10:10:05 1997 --- civ-0.5a/src/display.cc Mon Nov 17 15:00:20 1997 *************** *** 6,15 **** --- 6,21 ---- displayData::~displayData() {;} + WDisplay::WDisplay(Player *p) { + player = p; + screen->windows.Insert(this); + } + WDisplay::~WDisplay() { if (data != NULL) delete data; data = NULL; + screen->windows.Delete(this); } void WDisplay::WriteInt(int x, int y, int n, int width, int color) diff -bw -c -r civ-0.5/src/display.h civ-0.5a/src/display.h *** civ-0.5/src/display.h Fri Oct 17 10:09:59 1997 --- civ-0.5a/src/display.h Mon Nov 17 14:59:56 1997 *************** *** 28,39 **** virtual void CreateDrawingArea(int width, int height, WDisplay *window) = 0; virtual void AddButton(char *name, void (*callback)(void *), void *call_data) = 0; virtual void AddMenu(char *name, MenuItem *list, void (*callback)(void *, void *), void *call_data) = 0; }; class WDisplay { public: ! WDisplay(Player *p) {player = p;} virtual ~WDisplay(); void Raise() {data->Raise();} --- 28,40 ---- virtual void CreateDrawingArea(int width, int height, WDisplay *window) = 0; virtual void AddButton(char *name, void (*callback)(void *), void *call_data) = 0; virtual void AddMenu(char *name, MenuItem *list, void (*callback)(void *, void *), void *call_data) = 0; + virtual void ChangeColorMap() = 0; }; class WDisplay { public: ! WDisplay(Player *p); virtual ~WDisplay(); void Raise() {data->Raise();} *************** *** 60,65 **** --- 61,67 ---- void Rect(MapCoord c, int width, int ht, int col) {Rect(TranslateScreen(c),width,ht,col);} void ExposeNotify(int x, int y, int width, int ht) {data->ExposeNotify(x,y,width,ht);} + void ChangeColorMap() {data->ChangeColorMap();} friend void AllocColors(class Graphics *screen); protected: diff -bw -c -r civ-0.5/src/graph.h civ-0.5a/src/graph.h *** civ-0.5/src/graph.h Fri Oct 17 10:10:00 1997 --- civ-0.5a/src/graph.h Mon Nov 17 14:31:35 1997 *************** *** 51,56 **** --- 51,58 ---- // add a notify handler for data available on a fd virtual void AddReadNotify(int fd, readNotifyFunc func, int info = 0, int q = 1) = 0; + List windows; + #ifdef USE_XT friend void ReadNotify(XtPointer clt, int* fd_p, XtInputId* id); #elif defined (USE_XVIEW) diff -bw -c -r civ-0.5/src/player.cc civ-0.5a/src/player.cc *** civ-0.5/src/player.cc Tue Oct 28 17:47:15 1997 --- civ-0.5a/src/player.cc Mon Nov 17 15:13:04 1997 *************** *** 720,725 **** --- 720,726 ---- screen->DispMessageBox("Overruled by Senate", NULL, NULL); } else { + diplomacyId = playerId; List options; options.Insert("Declare War"); options.Insert("Cancel Action");