stratagus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Stratagus-CVS] stratagus/src/ui menu_proc.c


From: Jimmy Salmon
Subject: [Stratagus-CVS] stratagus/src/ui menu_proc.c
Date: Tue, 30 Sep 2003 23:28:19 -0400

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Jimmy Salmon <address@hidden>   03/09/30 23:28:18

Modified files:
        src/ui         : menu_proc.c 

Log message:
        Cleanup

Patches:
Index: stratagus/src/ui/menu_proc.c
diff -u stratagus/src/ui/menu_proc.c:1.102 stratagus/src/ui/menu_proc.c:1.103
--- stratagus/src/ui/menu_proc.c:1.102  Thu Sep 18 13:56:04 2003
+++ stratagus/src/ui/menu_proc.c        Tue Sep 30 23:28:18 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: menu_proc.c,v 1.102 2003/09/18 17:56:04 n0body Exp $
+//     $Id: menu_proc.c,v 1.103 2003/10/01 03:28:18 jsalmon3 Exp $
 
 //@{
 
@@ -86,12 +86,12 @@
 /**
 **     The currently processed menu
 */
-global Menu *CurrentMenu;
+global Menu* CurrentMenu;
 
 /**
 **     The background picture used by menus
 */
-local Graphic *Menusbgnd;
+local Graphic* Menusbgnd;
 
 /**
 **     X, Y, Width, and Height of menu are to redraw
@@ -111,7 +111,7 @@
 /** 
 **      Convert menu button style to a string for saving.
 */ 
-global char *MenuButtonStyle(int style) 
+global char* MenuButtonStyle(int style) 
 { 
    switch (style) { 
        case MBUTTON_MAIN: 
@@ -149,7 +149,7 @@
        case MBUTTON_FOLDER: 
            return "folder"; 
    } 
-   fprintf(stderr,"MenuButtonStyle not found: %d\n", style); 
+   fprintf(stderr, "MenuButtonStyle not found: %d\n", style); 
    return ""; 
 } 
 
@@ -160,11 +160,11 @@
 **
 **     @return         Pointer to the menu, NULL if menu is not found.
 */
-global Menu *FindMenu(const char *menu_id)
+global Menu* FindMenu(const char* menu_id)
 {
-    Menu **menu;
+    Menu** menu;
 
-    if (!(menu = (Menu **) hash_find(MenuHash, (char *)menu_id))) {
+    if (!(menu = (Menu**)hash_find(MenuHash, (char*)menu_id))) {
        return NULL;
     } else {
        return *menu;
@@ -176,9 +176,9 @@
 */
 global void InvalidateMenuAreas(void)
 {
-    InvalidateAreaAndCheckCursor(
-            MenuRedrawX,MenuRedrawY,MenuRedrawW,MenuRedrawH);
-    MustRedraw&=~RedrawMenu;
+    InvalidateAreaAndCheckCursor(MenuRedrawX, MenuRedrawY,
+       MenuRedrawW, MenuRedrawH);
+    MustRedraw &= ~RedrawMenu;
 }
 
 /**
@@ -189,15 +189,15 @@
     DestroyCursorBackground();
     if (!Menusbgnd) {
        Menusbgnd = LoadGraphic(MenuBackground);
-       ResizeGraphic(Menusbgnd,VideoWidth,VideoHeight);
+       ResizeGraphic(Menusbgnd, VideoWidth, VideoHeight);
 #ifdef USE_OPENGL
-       MakeTexture(Menusbgnd,Menusbgnd->Width,Menusbgnd->Height);
+       MakeTexture(Menusbgnd, Menusbgnd->Width, Menusbgnd->Height);
 #endif
     }
 
-    VideoDrawSubClip(Menusbgnd,0,0,
-       Menusbgnd->Width,Menusbgnd->Height,
-       (VideoWidth-Menusbgnd->Width)/2,(VideoHeight-Menusbgnd->Height)/2);
+    VideoDrawSubClip(Menusbgnd, 0, 0,
+       Menusbgnd->Width, Menusbgnd->Height,
+       (VideoWidth - Menusbgnd->Width) / 2, (VideoHeight - Menusbgnd->Height) 
/ 2);
 
     MenuRedrawX = 0;
     MenuRedrawY = 0;
@@ -219,8 +219,9 @@
 **     @param normalcolor
 **     @param reversecolor
 */
-global void DrawMenuButton(MenuButtonId button,unsigned flags,int w,int h,int 
x,int y,
-       const int font,const unsigned char *text,char *normalcolor,char 
*reversecolor)
+global void DrawMenuButton(MenuButtonId button, unsigned flags, int w, int h,
+    int x, int y, const int font, const unsigned char* text,
+    char* normalcolor, char* reversecolor)
 {
     MenuButtonId rb;
     int s;
@@ -233,85 +234,87 @@
     if (normalcolor || reversecolor) {
        nc = normalcolor ? normalcolor : oldnc;
        rc = reversecolor ? reversecolor : oldrc;
-       SetDefaultTextColors(nc,rc);
+       SetDefaultTextColors(nc, rc);
     } else {
        nc = oldnc;
        rc = oldrc;
     }
-    if (button == MBUTTON_SC_BUTTON || button == MBUTTON_SC_BUTTON_LEFT
-           || button == MBUTTON_SC_BUTTON_RIGHT) {
-       if (flags&MenuButtonDisabled) {
+    if (button == MBUTTON_SC_BUTTON || button == MBUTTON_SC_BUTTON_LEFT ||
+           button == MBUTTON_SC_BUTTON_RIGHT) {
+       if (flags & MenuButtonDisabled) {
            rb = button - 3;
-           SetDefaultTextColors(FontGrey,FontGrey);
-       } else if (flags&MenuButtonClicked) {
+           SetDefaultTextColors(FontGrey, FontGrey);
+       } else if (flags & MenuButtonClicked) {
            rb = button + 3;
-           SetDefaultTextColors(rc,rc);
+           SetDefaultTextColors(rc, rc);
        } else {
            rb = button;
-           if (flags&MenuButtonActive) {
-               SetDefaultTextColors(rc,rc);
+           if (flags & MenuButtonActive) {
+               SetDefaultTextColors(rc, rc);
            }
        }
-       VideoDraw(MenuButtonGfx.Sprite, rb-1, x, y);
-       for (s = x+8; s < x+w-1-8; s += 8) {
+       VideoDraw(MenuButtonGfx.Sprite, rb - 1, x, y);
+       for (s = x + 8; s < x + w - 1 - 8; s += 8) {
            VideoDraw(MenuButtonGfx.Sprite, rb, s, y);
        }
-       VideoDraw(MenuButtonGfx.Sprite, rb+1, x+w-1-8, y);
+       VideoDraw(MenuButtonGfx.Sprite, rb + 1, x + w - 1 - 8, y);
        if (text) {
-           
VideoDrawTextCentered(x+w/2,y+(h-VideoTextHeight(font))/2,font,text);
+           VideoDrawTextCentered(x + w / 2, y + (h - VideoTextHeight(font)) / 
2,
+               font, text);
        }
-       if (flags&MenuButtonSelected) {
-           if (flags&MenuButtonDisabled) {
-               VideoDrawRectangleClip(ColorGray,x,y,w-1,h);
+       if (flags & MenuButtonSelected) {
+           if (flags & MenuButtonDisabled) {
+               VideoDrawRectangleClip(ColorGray, x, y, w - 1, h);
            } else {
-               VideoDrawRectangleClip(165,x,y,w-1,h);
+               VideoDrawRectangleClip(165, x, y, w - 1, h);
            }
        }
     } else {
-       if (flags&MenuButtonDisabled) {
+       if (flags & MenuButtonDisabled) {
            rb = button - 1;
            s = 0;
-           SetDefaultTextColors(FontGrey,FontGrey);
-       } else if (flags&MenuButtonClicked) {
+           SetDefaultTextColors(FontGrey, FontGrey);
+       } else if (flags & MenuButtonClicked) {
            rb = button + 1;
            s = 2;
-           SetDefaultTextColors(rc,rc);
+           SetDefaultTextColors(rc, rc);
        } else {
            rb = button;
            s = 0;
-           if (flags&MenuButtonActive) {
-               SetDefaultTextColors(rc,rc);
+           if (flags & MenuButtonActive) {
+               SetDefaultTextColors(rc, rc);
            }
        }
        if (rb < MenuButtonGfx.Sprite->NumFrames) {
            VideoDrawClip(MenuButtonGfx.Sprite, rb, x, y);
        } else {
            if (rb < button) {
-               VideoDrawRectangleClip(ColorGray,x+1,y+1,w-2,h-2);
-               VideoDrawRectangleClip(ColorGray,x+2,y+2,w-4,h-4);
+               VideoDrawRectangleClip(ColorGray, x + 1, y + 1, w - 2, h - 2);
+               VideoDrawRectangleClip(ColorGray, x + 2, y + 2, w - 4, h - 4);
            } else {
                // FIXME: Temp-workaround for missing folder button in 
non-expansion gfx
-               VideoDrawRectangleClip(ColorYellow,x+1,y+1,w-2,h-2);
-               VideoDrawRectangleClip(ColorYellow,x+2,y+2,w-4,h-4);
+               VideoDrawRectangleClip(ColorYellow, x + 1, y + 1, w - 2, h - 2);
+               VideoDrawRectangleClip(ColorYellow, x + 2, y + 2, w - 4, h - 4);
            }
        }
        if (text) {
            if (button != MBUTTON_FOLDER) {
-               
VideoDrawTextCentered(s+x+w/2,s+y+(h-VideoTextHeight(font))/2+2,font,text);
+               VideoDrawTextCentered(s + x + w / 2,
+                   s + y + (h - VideoTextHeight(font)) / 2 + 2, font, text);
            } else {
-               SetDefaultTextColors(nc,rc);
-               VideoDrawText(x+44,y+6,font,text);
+               SetDefaultTextColors(nc, rc);
+               VideoDrawText(x + 44, y + 6, font, text);
            }
        }
-       if (flags&MenuButtonSelected) {
-           if (flags&MenuButtonDisabled) {
-               VideoDrawRectangleClip(ColorGray,x,y,w-1,h);
+       if (flags & MenuButtonSelected) {
+           if (flags & MenuButtonDisabled) {
+               VideoDrawRectangleClip(ColorGray, x, y, w - 1, h);
            } else {
-               VideoDrawRectangleClip(ColorYellow,x,y,w-1,h);
+               VideoDrawRectangleClip(ColorYellow, x, y, w - 1, h);
            }
        }
     }
-    SetDefaultTextColors(oldnc,oldrc);
+    SetDefaultTextColors(oldnc, oldrc);
 }
 
 /**
@@ -321,7 +324,7 @@
 **     @param mx       menu X display position (offset)
 **     @param my       menu Y display position (offset)
 */
-local void DrawPulldown(Menuitem *mi, int mx, int my)
+local void DrawPulldown(Menuitem* mi, int mx, int my)
 {
     int i;
     char* nc;
@@ -338,31 +341,31 @@
     int y;
     int oh;
 
-    x = mx+mi->xofs;
-    y = my+mi->yofs;
+    x = mx + mi->xofs;
+    y = my + mi->yofs;
     w = mi->d.pulldown.xsize;
     flags = mi->flags;
     rb = mi->d.pulldown.button;
 
-    GetDefaultTextColors(&oldnc,&oldrc);
+    GetDefaultTextColors(&oldnc, &oldrc);
     if (mi->d.pulldown.normalcolor || mi->d.pulldown.reversecolor) {
        nc = mi->d.pulldown.normalcolor ? mi->d.pulldown.normalcolor : oldnc;
        rc = mi->d.pulldown.reversecolor ? mi->d.pulldown.reversecolor : oldrc;
-       SetDefaultTextColors(nc,rc);
+       SetDefaultTextColors(nc, rc);
     } else {
        nc = oldnc;
        rc = oldrc;
     }
     if (rb == MBUTTON_SC_PULLDOWN) {
        h = mi->d.pulldown.ysize;
-       if (flags&MenuButtonClicked) {
+       if (flags & MenuButtonClicked) {
            int usetop;
            int option;
            int max;
 
            // Check if the pulldown goes below the bottom
-           if (mi->yofs + (h+1)*mi->d.pulldown.noptions >= mi->menu->Height) {
-               y -= h*mi->d.pulldown.noptions;
+           if (mi->yofs + (h + 1) * mi->d.pulldown.noptions >= 
mi->menu->Height) {
+               y -= h * mi->d.pulldown.noptions;
                usetop = 0;
            } else {
                usetop = 1;
@@ -374,27 +377,28 @@
            } else {
                rb = MBUTTON_SC_PULLDOWN_TOP;
            }
-           VideoDraw(MenuButtonGfx.Sprite, rb-1, x, y);
-           for (i = x+16; i < x+w-1-16; i += 16) {
+           VideoDraw(MenuButtonGfx.Sprite, rb - 1, x, y);
+           for (i = x + 16; i < x + w - 1 - 16; i += 16) {
                VideoDraw(MenuButtonGfx.Sprite, rb, i, y);
            }
-           VideoDraw(MenuButtonGfx.Sprite, rb+1, x+w-1-16, y);
+           VideoDraw(MenuButtonGfx.Sprite, rb + 1, x + w - 1 - 16, y);
            option = 0;
            if (usetop) {
-               VideoDraw(MenuButtonGfx.Sprite, MBUTTON_SC_PULLDOWN_DOWN_ARROW, 
x+w-1-16-3, y+4);
+               VideoDraw(MenuButtonGfx.Sprite, MBUTTON_SC_PULLDOWN_DOWN_ARROW,
+                   x + w - 1 - 16 - 3, y + 4);
                text = mi->d.pulldown.options[mi->d.pulldown.curopt];
                if (text) {
-                   VideoDrawText(x+4,y+2,mi->font,text);
+                   VideoDrawText(x + 4, y + 2, mi->font, text);
                }
            } else {
                if (option == mi->d.pulldown.cursel) {
-                   SetDefaultTextColors(rc,rc);
+                   SetDefaultTextColors(rc, rc);
                } else {
-                   SetDefaultTextColors(nc,rc);
+                   SetDefaultTextColors(nc, rc);
                }
                text = mi->d.pulldown.options[option];
                if (text) {
-                   VideoDrawText(x+4, y+2, mi->font, text);
+                   VideoDrawText(x + 4, y + 2, mi->font, text);
                }
                option = 1;
            }
@@ -403,88 +407,89 @@
            y += mi->d.pulldown.ysize;
            rb = MBUTTON_SC_PULLDOWN_MIDDLE;
            if (usetop) {
-               max = mi->d.pulldown.noptions-1;
+               max = mi->d.pulldown.noptions - 1;
            } else {
                max = mi->d.pulldown.noptions;
            }
-           for ( ; option < max; ++option) {
-               VideoDraw(MenuButtonGfx.Sprite, rb-1, x, y);
-               for (i = x+16; i < x+w-1-16; i += 16) {
+           for (; option < max; ++option) {
+               VideoDraw(MenuButtonGfx.Sprite, rb - 1, x, y);
+               for (i = x + 16; i < x + w - 1 - 16; i += 16) {
                    VideoDraw(MenuButtonGfx.Sprite, rb, i, y);
                }
-               VideoDraw(MenuButtonGfx.Sprite, rb+1, x+w-1-16, y);
+               VideoDraw(MenuButtonGfx.Sprite, rb + 1, x + w - 1 - 16, y);
                if (option == mi->d.pulldown.cursel) {
-                   SetDefaultTextColors(rc,rc);
+                   SetDefaultTextColors(rc, rc);
                } else {
-                   SetDefaultTextColors(nc,rc);
+                   SetDefaultTextColors(nc, rc);
                }
                text = mi->d.pulldown.options[option];
                if (text) {
-                   VideoDrawText(x+4, y+2, mi->font, text);
+                   VideoDrawText(x + 4, y + 2, mi->font, text);
                }
                y += mi->d.pulldown.ysize;
            }
 
            // Bottom
-           SetDefaultTextColors(nc,rc);
+           SetDefaultTextColors(nc, rc);
            if (usetop) {
                rb = MBUTTON_SC_PULLDOWN_BOTTOM;
            } else {
                rb = MBUTTON_SC_PULLDOWN_BOTTOM_SELECTED;
            }
-           VideoDraw(MenuButtonGfx.Sprite, rb-1, x, y);
-           for (i = x+16; i < x+w-1-16; i += 16) {
+           VideoDraw(MenuButtonGfx.Sprite, rb - 1, x, y);
+           for (i = x + 16; i < x + w - 1 - 16; i += 16) {
                VideoDraw(MenuButtonGfx.Sprite, rb, i, y);
            }
-           VideoDraw(MenuButtonGfx.Sprite, rb+1, x+w-1-16, y);
+           VideoDraw(MenuButtonGfx.Sprite, rb + 1, x + w - 1 - 16, y);
            if (usetop) {
                if (option == mi->d.pulldown.cursel) {
-                   SetDefaultTextColors(rc,rc);
+                   SetDefaultTextColors(rc, rc);
                } else {
-                   SetDefaultTextColors(nc,rc);
+                   SetDefaultTextColors(nc, rc);
                }
                text = mi->d.pulldown.options[option];
                if (text) {
-                   VideoDrawText(x+4,y+2,mi->font,text);
+                   VideoDrawText(x + 4, y + 2, mi->font, text);
                }
                option = 0;
            } else {
-               VideoDraw(MenuButtonGfx.Sprite, MBUTTON_SC_PULLDOWN_DOWN_ARROW, 
x+w-1-16-3, y+4);
+               VideoDraw(MenuButtonGfx.Sprite, MBUTTON_SC_PULLDOWN_DOWN_ARROW,
+                   x + w - 1 - 16 - 3, y + 4);
                text = mi->d.pulldown.options[mi->d.pulldown.curopt];
                if (text) {
-                   VideoDrawText(x+4, y+2, mi->font, text);
+                   VideoDrawText(x + 4, y + 2, mi->font, text);
                }
                option = 1;
            }
        } else {
            h = mi->d.pulldown.ysize;
-           y = my+mi->yofs;
+           y = my + mi->yofs;
            db = MBUTTON_SC_PULLDOWN_DOWN_ARROW;
-           if (flags&MenuButtonDisabled) {
+           if (flags & MenuButtonDisabled) {
                rb = MBUTTON_SC_PULLDOWN_DISABLED;
-               SetDefaultTextColors(FontGrey,FontGrey);
+               SetDefaultTextColors(FontGrey, FontGrey);
            } else {
-               if (flags&MenuButtonActive) {
-                   SetDefaultTextColors(rc,rc);
+               if (flags & MenuButtonActive) {
+                   SetDefaultTextColors(rc, rc);
                    ++db;
                }
            }
-           VideoDraw(MenuButtonGfx.Sprite, rb-1, x, y);
-           for (i = x+16; i < x+w-1-16; i += 16) {
+           VideoDraw(MenuButtonGfx.Sprite, rb - 1, x, y);
+           for (i = x + 16; i < x + w - 1 - 16; i += 16) {
                VideoDraw(MenuButtonGfx.Sprite, rb, i, y);
            }
-           VideoDraw(MenuButtonGfx.Sprite, rb+1, x+w-1-16, y);
+           VideoDraw(MenuButtonGfx.Sprite, rb + 1, x + w - 1 - 16, y);
            if (!(mi->d.pulldown.state & MI_PSTATE_PASSIVE)) {
-               VideoDraw(MenuButtonGfx.Sprite, db, x+w-1-16-3, y+4);
+               VideoDraw(MenuButtonGfx.Sprite, db, x + w - 1 - 16 - 3, y + 4);
            }
            text = mi->d.pulldown.options[mi->d.pulldown.curopt];
            if (text) {
-               VideoDrawText(x+4,y+2,mi->font,text);
+               VideoDrawText(x + 4, y + 2, mi->font, text);
            }
        }
     } else {
        oh = h = mi->d.pulldown.ysize - 2;
-       if (flags&MenuButtonClicked) {
+       if (flags & MenuButtonClicked) {
            // Make the menu inside of the screen (TOP)
            if (y + 1 <= mi->d.pulldown.curopt * h + CurrentMenu->Y) {
                y = 2 + CurrentMenu->Y;
@@ -492,65 +497,67 @@
                y -= mi->d.pulldown.curopt * h;
                // Make the menu inside the bottom of the screen
                // FIXME: can't assume bottom is always 480
-               if (y + h*mi->d.pulldown.noptions >= 480 + CurrentMenu->Y) {
-                   y -= y + h*mi->d.pulldown.noptions - (480 + CurrentMenu->Y);
+               if (y + h * mi->d.pulldown.noptions >= 480 + CurrentMenu->Y) {
+                   y -= y + h * mi->d.pulldown.noptions - (480 + 
CurrentMenu->Y);
                }
            }
            i = mi->d.pulldown.noptions;
            h *= i;
            while (i--) {
                PushClipping();
-               SetClipping(0,0,x+w,VideoHeight-1);
-               VideoDrawClip(MenuButtonGfx.Sprite, rb, x-1, y-1 + oh*i);
+               SetClipping(0, 0, x + w, VideoHeight - 1);
+               VideoDrawClip(MenuButtonGfx.Sprite, rb, x - 1, y - 1 + oh * i);
                PopClipping();
                text = mi->d.pulldown.options[i];
                if (text) {
-                   if (i == mi->d.pulldown.cursel)
-                       SetDefaultTextColors(rc,rc);
-                   else
-                       SetDefaultTextColors(nc,rc);
-                   VideoDrawText(x+2,y+2 + oh*i ,mi->font,text);
+                   if (i == mi->d.pulldown.cursel) {
+                       SetDefaultTextColors(rc, rc);
+                   } else {
+                       SetDefaultTextColors(nc, rc);
+                   }
+                   VideoDrawText(x + 2, y + 2 + oh * i, mi->font, text);
                }
            }
            w += 2;
            h += 2;
        } else {
            h = mi->d.pulldown.ysize;
-           y = my+mi->yofs;
-           if (flags&MenuButtonDisabled) {
+           y = my + mi->yofs;
+           if (flags & MenuButtonDisabled) {
                rb--;
-               SetDefaultTextColors(FontGrey,FontGrey);
+               SetDefaultTextColors(FontGrey, FontGrey);
            } else {
-               if (flags&MenuButtonActive) {
-                   SetDefaultTextColors(rc,rc);
+               if (flags & MenuButtonActive) {
+                   SetDefaultTextColors(rc, rc);
                }
            }
 
            PushClipping();
            if (!(mi->d.pulldown.state & MI_PSTATE_PASSIVE)) {
-               SetClipping(0,0,x+w-20,VideoHeight-1);
+               SetClipping(0, 0, x + w - 20, VideoHeight - 1);
            } else {
-               SetClipping(0,0,x+w-1,VideoHeight-1);
+               SetClipping(0, 0, x + w - 1, VideoHeight - 1);
            }
-           VideoDrawClip(MenuButtonGfx.Sprite, rb, x-1, y-1);
+           VideoDrawClip(MenuButtonGfx.Sprite, rb, x - 1, y - 1);
            PopClipping();
            if (!(mi->d.pulldown.state & MI_PSTATE_PASSIVE)) {
-               VideoDraw(MenuButtonGfx.Sprite, MBUTTON_DOWN_ARROW + rb - 
MBUTTON_PULLDOWN, x-1 + w-20, y-2);
+               VideoDraw(MenuButtonGfx.Sprite, MBUTTON_DOWN_ARROW + rb - 
MBUTTON_PULLDOWN,
+                   x - 1 + w - 20, y - 2);
            }
            text = mi->d.pulldown.options[mi->d.pulldown.curopt];
            if (text) {
-               VideoDrawText(x+2,y+2,mi->font,text);
+               VideoDrawText(x + 2, y + 2, mi->font, text);
            }
        }
-       if (flags&MenuButtonSelected) {
-           if (flags&MenuButtonDisabled) {
-               VideoDrawRectangleClip(ColorGray,x-2,y-2,w,h);
+       if (flags & MenuButtonSelected) {
+           if (flags & MenuButtonDisabled) {
+               VideoDrawRectangleClip(ColorGray, x - 2, y - 2, w, h);
            } else {
-               VideoDrawRectangleClip(ColorYellow,x-2,y-2,w,h);
+               VideoDrawRectangleClip(ColorYellow, x - 2, y - 2, w, h);
            }
        }
     }
-    SetDefaultTextColors(oldnc,oldrc);
+    SetDefaultTextColors(oldnc, oldrc);
 }
 
 /**
@@ -560,7 +567,7 @@
 **     @param mx       menu X display position (offset)
 **     @param my       menu Y display position (offset)
 */
-local void DrawListbox(Menuitem *mi, int mx, int my)
+local void DrawListbox(Menuitem* mi, int mx, int my)
 {
     int i;
     int s;
@@ -580,53 +587,53 @@
     flags = mi->flags;
     w = mi->d.listbox.xsize;
     h = mi->d.listbox.ysize;
-    x = mx+mi->xofs;
-    y = my+mi->yofs;
+    x = mx + mi->xofs;
+    y = my + mi->yofs;
 
-    GetDefaultTextColors(&oldnc,&oldrc);
+    GetDefaultTextColors(&oldnc, &oldrc);
     if (mi->d.listbox.normalcolor || mi->d.listbox.reversecolor) {
        nc = mi->d.listbox.normalcolor ? mi->d.listbox.normalcolor : oldnc;
        rc = mi->d.listbox.reversecolor ? mi->d.listbox.reversecolor : oldrc;
-       SetDefaultTextColors(nc,rc);
+       SetDefaultTextColors(nc, rc);
     } else {
        nc = oldnc;
        rc = oldrc;
     }
 
-    if (flags&MenuButtonDisabled) {
+    if (flags & MenuButtonDisabled) {
        rb--;
     }
     i = mi->d.listbox.nlines;
     s = mi->d.listbox.startline;
     while (i--) {
        PushClipping();
-       SetClipping(0,0,x+w,VideoHeight-1);
-       VideoDrawClip(MenuButtonGfx.Sprite, rb, x-1, y-1 + 18*i);
+       SetClipping(0, 0, x + w, VideoHeight - 1);
+       VideoDrawClip(MenuButtonGfx.Sprite, rb, x - 1, y - 1 + 18 * i);
        PopClipping();
-       if (!(flags&MenuButtonDisabled)) {
+       if (!(flags & MenuButtonDisabled)) {
            if (i < mi->d.listbox.noptions) {
-               SetDefaultTextColors(nc,rc);
+               SetDefaultTextColors(nc, rc);
                text = (*mi->d.listbox.retrieveopt)(mi, i + s);
                if (text) {
                    if (i == mi->d.listbox.curopt) {
-                       SetDefaultTextColors(rc,rc);
+                       SetDefaultTextColors(rc, rc);
                    } else {
-                       SetDefaultTextColors(nc,rc);
+                       SetDefaultTextColors(nc, rc);
                    }
-                   VideoDrawText(x+2,y+2 + 18*i ,mi->font,text);
+                   VideoDrawText(x + 2, y + 2 + 18 * i, mi->font,text);
                }
            }
        }
     }
 
-    if (flags&MenuButtonSelected) {
-       if (flags&MenuButtonDisabled) {
-           VideoDrawRectangleClip(ColorGray,x-2,y-2,w+1,h+2);
+    if (flags & MenuButtonSelected) {
+       if (flags & MenuButtonDisabled) {
+           VideoDrawRectangleClip(ColorGray, x - 2, y - 2, w + 1, h + 2);
        } else {
-           VideoDrawRectangleClip(ColorYellow,x-2,y-2,w+1,h+2);
+           VideoDrawRectangleClip(ColorYellow, x - 2, y - 2, w + 1, h + 2);
        }
     }
-    SetDefaultTextColors(oldnc,oldrc);
+    SetDefaultTextColors(oldnc, oldrc);
 }
 
 /**
@@ -636,7 +643,7 @@
 **     @param mx       menu X display position (offset)
 **     @param my       menu Y display position (offset)
 */
-local void DrawVSlider(Menuitem *mi, int mx, int my)
+local void DrawVSlider(Menuitem* mi, int mx, int my)
 {
     int p;
     unsigned flags;
@@ -648,17 +655,17 @@
     flags = mi->flags;
     w = mi->d.vslider.xsize;
     h = mi->d.vslider.ysize;
-    x = mx+mi->xofs;
-    y = my+mi->yofs;
+    x = mx + mi->xofs;
+    y = my + mi->yofs;
 
     if (mi->d.vslider.style == MI_STYLE_SC_VSLIDER) {
        int upb;
        int downb;
 
-       if (flags&MenuButtonDisabled) {
+       if (flags & MenuButtonDisabled) {
            upb = MBUTTON_SC_UP_ARROW - 1;
            downb = MBUTTON_SC_DOWN_ARROW - 1;
-       } else if (flags&MenuButtonClicked) {
+       } else if (flags & MenuButtonClicked) {
            if (mi->d.vslider.cflags&MI_CFLAGS_UP) {
                upb = MBUTTON_SC_UP_ARROW + 1;
                downb = MBUTTON_SC_DOWN_ARROW;
@@ -674,36 +681,36 @@
            downb = MBUTTON_SC_DOWN_ARROW;
        }
        VideoDraw(MenuButtonGfx.Sprite, upb, x, y);
-       VideoDraw(MenuButtonGfx.Sprite, downb, x, y + h-1 - 16);
+       VideoDraw(MenuButtonGfx.Sprite, downb, x, y + h - 1 - 16);
 
        VideoDraw(MenuButtonGfx.Sprite, MBUTTON_SC_S_VCONT - 1, x, y + 16 + 2);
-       for (p = y+16+2+8+1; p < y+h-1-16-2-8; p += 8) {
+       for (p = y + 16 + 2 + 8 + 1; p < y + h - 1 - 16 - 2 - 8; p += 8) {
            VideoDraw(MenuButtonGfx.Sprite, MBUTTON_SC_S_VCONT, x, p);
        }
-       VideoDraw(MenuButtonGfx.Sprite, MBUTTON_SC_S_VCONT + 1, x, y + h-1 - 16 
- 2 - 8);
+       VideoDraw(MenuButtonGfx.Sprite, MBUTTON_SC_S_VCONT + 1, x, y + h - 1 - 
16 - 2 - 8);
        p = (mi->d.vslider.percent * (h - 54)) / 100;
        VideoDraw(MenuButtonGfx.Sprite, MBUTTON_SC_S_KNOB, x, y + 16 + 2 + p);
     } else {
-       if (flags&MenuButtonDisabled) {
+       if (flags & MenuButtonDisabled) {
            PushClipping();
-           SetClipping(0,0,VideoWidth-1,y + h - 20);
+           SetClipping(0, 0, VideoWidth - 1, y + h - 20);
            VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_VCONT - 1, x, y - 2);
-           VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_VCONT - 1, x, y + 
h/2);
+           VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_VCONT - 1, x, y + h / 
2);
            PopClipping();
            VideoDraw(MenuButtonGfx.Sprite, MBUTTON_UP_ARROW - 1, x, y - 2);
            VideoDraw(MenuButtonGfx.Sprite, MBUTTON_DOWN_ARROW - 1, x, y + h - 
20);
        } else {
            PushClipping();
-           SetClipping(0,0,VideoWidth-1,y + h - 20);
+           SetClipping(0, 0, VideoWidth - 1, y + h - 20);
            VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_VCONT, x, y - 2);
-           VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_VCONT, x, y + h/2);
+           VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_VCONT, x, y + h / 2);
            PopClipping();
-           if (mi->d.vslider.cflags&MI_CFLAGS_UP) {
+           if (mi->d.vslider.cflags & MI_CFLAGS_UP) {
                VideoDraw(MenuButtonGfx.Sprite, MBUTTON_UP_ARROW + 1, x, y - 2);
            } else {
                VideoDraw(MenuButtonGfx.Sprite, MBUTTON_UP_ARROW, x, y - 2);
            }
-           if (mi->d.vslider.cflags&MI_CFLAGS_DOWN) {
+           if (mi->d.vslider.cflags & MI_CFLAGS_DOWN) {
                VideoDraw(MenuButtonGfx.Sprite, MBUTTON_DOWN_ARROW + 1, x, y + 
h - 20);
            } else {
                VideoDraw(MenuButtonGfx.Sprite, MBUTTON_DOWN_ARROW, x, y + h - 
20);
@@ -712,11 +719,11 @@
            VideoDraw(MenuButtonGfx.Sprite, MBUTTON_S_KNOB, x + 1, y + 18 + p);
        }
 
-       if (flags&MenuButtonSelected) {
-           if (flags&MenuButtonDisabled) {
-               VideoDrawRectangleClip(ColorGray,x,y-2,w,h+2);
+       if (flags & MenuButtonSelected) {
+           if (flags & MenuButtonDisabled) {
+               VideoDrawRectangleClip(ColorGray, x, y - 2, w, h + 2);
            } else {
-               VideoDrawRectangleClip(ColorYellow,x,y-2,w,h+2);
+               VideoDrawRectangleClip(ColorYellow, x, y - 2, w, h + 2);
            }
        }
     }
@@ -729,7 +736,7 @@
 **     @param mx       menu X display position (offset)
 **     @param my       menu Y display position (offset)
 */
-local void DrawHSlider(Menuitem *mi, int mx, int my)
+local void DrawHSlider(Menuitem* mi, int mx, int my)
 {
     int p;
     unsigned flags;
@@ -741,21 +748,21 @@
     flags = mi->flags;
     w = mi->d.hslider.xsize;
     h = mi->d.hslider.ysize;
-    x = mx+mi->xofs;
-    y = my+mi->yofs;
+    x = mx + mi->xofs;
+    y = my + mi->yofs;
 
     if (mi->d.hslider.style == MI_STYLE_SC_HSLIDER) {
        int leftb;
        int rightb;
 
-       if (flags&MenuButtonDisabled) {
+       if (flags & MenuButtonDisabled) {
            leftb = MBUTTON_SC_LEFT_ARROW - 1;
            rightb = MBUTTON_SC_RIGHT_ARROW - 1;
-       } else if (flags&MenuButtonClicked) {
-           if (mi->d.vslider.cflags&MI_CFLAGS_LEFT) {
+       } else if (flags & MenuButtonClicked) {
+           if (mi->d.vslider.cflags & MI_CFLAGS_LEFT) {
                leftb = MBUTTON_SC_LEFT_ARROW + 1;
                rightb = MBUTTON_SC_RIGHT_ARROW;
-           } else if (mi->d.vslider.cflags&MI_CFLAGS_RIGHT) {
+           } else if (mi->d.vslider.cflags & MI_CFLAGS_RIGHT) {
                leftb = MBUTTON_SC_LEFT_ARROW;
                rightb = MBUTTON_SC_RIGHT_ARROW + 1;
            } else {
@@ -767,36 +774,36 @@
            rightb = MBUTTON_SC_RIGHT_ARROW;
        }
        VideoDraw(MenuButtonGfx.Sprite, leftb, x, y);
-       VideoDraw(MenuButtonGfx.Sprite, rightb, x + w-1 - 16, y);
+       VideoDraw(MenuButtonGfx.Sprite, rightb, x + w - 1 - 16, y);
 
        VideoDraw(MenuButtonGfx.Sprite, MBUTTON_SC_S_HCONT - 1, x + 16 + 2, y);
-       for (p = x+16+2+8+1; p < x+w-1-16-2-8; p += 8) {
+       for (p = x + 16 + 2 + 8 + 1; p < x + w - 1 - 16 - 2 - 8; p += 8) {
            VideoDraw(MenuButtonGfx.Sprite, MBUTTON_SC_S_HCONT, p, y);
        }
-       VideoDraw(MenuButtonGfx.Sprite, MBUTTON_SC_S_HCONT + 1, x + w-1 - 16 - 
2 - 8, y);
+       VideoDraw(MenuButtonGfx.Sprite, MBUTTON_SC_S_HCONT + 1, x + w - 1 - 16 
- 2 - 8, y);
        p = (mi->d.vslider.percent * (w - 54)) / 100;
        VideoDraw(MenuButtonGfx.Sprite, MBUTTON_SC_S_KNOB, x + 16 + 2 + p, y);
     } else {
-       if (flags&MenuButtonDisabled) {
+       if (flags & MenuButtonDisabled) {
            PushClipping();
-           SetClipping(0,0,x + w - 20,VideoHeight-1);
+           SetClipping(0, 0, x + w - 20, VideoHeight - 1);
            VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_HCONT - 1, x - 2, y);
-           VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_HCONT - 1, x + w/2, 
y);
+           VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_HCONT - 1, x + w / 2, 
y);
            PopClipping();
            VideoDraw(MenuButtonGfx.Sprite, MBUTTON_LEFT_ARROW - 1, x - 2, y);
            VideoDraw(MenuButtonGfx.Sprite, MBUTTON_RIGHT_ARROW - 1, x + w - 
20, y);
        } else {
            PushClipping();
-           SetClipping(0,0,x + w - 20,VideoHeight-1);
+           SetClipping(0, 0, x + w - 20, VideoHeight - 1);
            VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_HCONT, x - 2, y);
-           VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_HCONT, x + w/2, y);
+           VideoDrawClip(MenuButtonGfx.Sprite, MBUTTON_S_HCONT, x + w / 2, y);
            PopClipping();
-           if (mi->d.hslider.cflags&MI_CFLAGS_LEFT) {
+           if (mi->d.hslider.cflags & MI_CFLAGS_LEFT) {
                VideoDraw(MenuButtonGfx.Sprite, MBUTTON_LEFT_ARROW + 1, x - 2, 
y);
            } else {
                VideoDraw(MenuButtonGfx.Sprite, MBUTTON_LEFT_ARROW, x - 2, y);
            }
-           if (mi->d.hslider.cflags&MI_CFLAGS_RIGHT) {
+           if (mi->d.hslider.cflags & MI_CFLAGS_RIGHT) {
                VideoDraw(MenuButtonGfx.Sprite, MBUTTON_RIGHT_ARROW + 1, x + w 
- 20, y);
            } else {
                VideoDraw(MenuButtonGfx.Sprite, MBUTTON_RIGHT_ARROW, x + w - 
20, y);
@@ -805,11 +812,11 @@
            VideoDraw(MenuButtonGfx.Sprite, MBUTTON_S_KNOB, x + 18 + p, y + 1);
        }
 
-       if (flags&MenuButtonSelected) {
-           if (flags&MenuButtonDisabled) {
-               VideoDrawRectangleClip(ColorGray,x-2,y,w+2,h);
+       if (flags & MenuButtonSelected) {
+           if (flags & MenuButtonDisabled) {
+               VideoDrawRectangleClip(ColorGray, x - 2, y, w + 2, h);
            } else {
-               VideoDrawRectangleClip(ColorYellow,x-2,y,w+2,h);
+               VideoDrawRectangleClip(ColorYellow, x - 2, y, w + 2, h);
            }
        }
     }
@@ -822,7 +829,7 @@
 **     @param mx       menu X display position (offset)
 **     @param my       menu Y display position (offset)
 */
-local void DrawGem(Menuitem *mi, int mx, int my)
+local void DrawGem(Menuitem* mi, int mx, int my)
 {
     unsigned flags;
     MenuButtonId rb;
@@ -840,12 +847,12 @@
     if ((mi->d.gem.state & MI_GSTATE_INVISIBLE)) {
        return;
     }
-    if (flags&MenuButtonDisabled) {
+    if (flags & MenuButtonDisabled) {
        rb--;
     }
     else {
-       if (flags&MenuButtonClicked) {
-           rb++;
+       if (flags & MenuButtonClicked) {
+           ++rb;
        }
        if ((mi->d.gem.state & MI_GSTATE_CHECKED)) {
            rb += 2;
@@ -863,13 +870,13 @@
            nc = oldnc;
            rc = oldrc;
        }
-       VideoDrawText(x+24, y+4, GameFont, mi->d.gem.text);
-       if (mi->flags&MenuButtonActive) {
-           SetDefaultTextColors(rc,rc);
-           VideoDrawRectangleClip(ColorGray,mx+mi->xofs-4,my+mi->yofs-4,
-                   VideoTextLength(GameFont, 
mi->d.gem.text)+30,VideoTextHeight(GameFont)+12);
+       VideoDrawText(x + 24, y + 4, GameFont, mi->d.gem.text);
+       if (mi->flags & MenuButtonActive) {
+           SetDefaultTextColors(rc, rc);
+           VideoDrawRectangleClip(ColorGray, mx + mi->xofs - 4, my + mi->yofs 
- 4,
+               VideoTextLength(GameFont, mi->d.gem.text) + 30, 
VideoTextHeight(GameFont) + 12);
        }
-       SetDefaultTextColors(oldnc,oldrc);
+       SetDefaultTextColors(oldnc, oldrc);
     }
 }
 
@@ -880,7 +887,7 @@
 **     @param mx       menu X display position (offset)
 **     @param my       menu Y display position (offset)
 */
-local void DrawInput(Menuitem *mi, int mx, int my)
+local void DrawInput(Menuitem* mi, int mx, int my)
 {
     char* nc;
     char* rc;
@@ -906,49 +913,49 @@
     if (mi->d.input.normalcolor || mi->d.input.reversecolor) {
        nc = mi->d.input.normalcolor ? mi->d.input.normalcolor : oldnc;
        rc = mi->d.input.reversecolor ? mi->d.input.reversecolor : oldrc;
-       SetDefaultTextColors(nc,rc);
+       SetDefaultTextColors(nc, rc);
     } else {
        nc = oldnc;
        rc = oldrc;
     }
     if (mi->d.input.button == MBUTTON_SC_PULLDOWN) {
        rb = MBUTTON_SC_INPUT;
-       if (flags&MenuButtonDisabled) {
+       if (flags & MenuButtonDisabled) {
            rb -= 3;
-           SetDefaultTextColors(FontGrey,FontGrey);
+           SetDefaultTextColors(FontGrey, FontGrey);
        }
        VideoDraw(MenuButtonGfx.Sprite, rb - 1, x, y);
-       for (p = x+16; p < x+w-1-16; p += 16) {
+       for (p = x + 16; p < x + w - 1 - 16; p += 16) {
            VideoDraw(MenuButtonGfx.Sprite, rb, p, y);
        }
-       VideoDraw(MenuButtonGfx.Sprite, rb + 1, x + w-1 - 16, y);
+       VideoDraw(MenuButtonGfx.Sprite, rb + 1, x + w - 1 - 16, y);
        text = mi->d.input.buffer;
        if (text) {
-           VideoDrawText(x+4,y+2,mi->font,text);
+           VideoDrawText(x + 4, y + 2, mi->font, text);
        }
     } else {
-       if (flags&MenuButtonDisabled) {
-           rb--;
-           SetDefaultTextColors(FontGrey,FontGrey);
+       if (flags & MenuButtonDisabled) {
+           --rb;
+           SetDefaultTextColors(FontGrey, FontGrey);
        }
 
        PushClipping();
-       SetClipping(0,0,x+w,VideoHeight-1);
-       VideoDrawClip(MenuButtonGfx.Sprite, rb, x-1, y-1);
+       SetClipping(0, 0, x + w, VideoHeight - 1);
+       VideoDrawClip(MenuButtonGfx.Sprite, rb, x - 1, y - 1);
        PopClipping();
        text = mi->d.input.buffer;
        if (text) {
-           VideoDrawText(x+2,y+2,mi->font,text);
+           VideoDrawText(x + 2, y + 2, mi->font, text);
        }
-       if (flags&MenuButtonSelected) {
-           if (flags&MenuButtonDisabled) {
-               VideoDrawRectangleClip(ColorGray,x-2,y-2,w+4,h);
+       if (flags & MenuButtonSelected) {
+           if (flags & MenuButtonDisabled) {
+               VideoDrawRectangleClip(ColorGray, x - 2, y - 2, w + 4, h);
            } else {
-               VideoDrawRectangleClip(ColorYellow,x-2,y-2,w+4,h);
+               VideoDrawRectangleClip(ColorYellow, x - 2, y - 2, w + 4, h);
            }
        }
     }
-    SetDefaultTextColors(oldnc,oldrc);
+    SetDefaultTextColors(oldnc, oldrc);
 }
 
 
@@ -957,7 +964,7 @@
 **
 **     @param menu     The menu number to display (NULL allowed)
 */
-global void DrawMenu(Menu *menu)
+global void DrawMenu(Menu* menu)
 {
     int i;
     int n;
@@ -966,8 +973,8 @@
     char* rc;
     char* oldnc;
     char* oldrc;
-    Menuitem *mi;
-    Menuitem *mip;
+    Menuitem* mi;
+    Menuitem* mip;
 
     if (menu == NULL) {
        MustRedraw &= ~RedrawMenu;
@@ -981,104 +988,104 @@
 
     if (menu->Panel && !strcmp(menu->Panel, ScPanel)) {
        // Background
-       
VideoFill50TransRectangle(ColorBlack,MenuRedrawX+1,MenuRedrawY+1,MenuRedrawW-2,MenuRedrawH-2);
-       VideoDrawHLineClip(ColorBlue,MenuRedrawX+3,MenuRedrawY,MenuRedrawW-6);
-       
VideoDrawHLineClip(ColorBlue,MenuRedrawX+3,MenuRedrawY+MenuRedrawH-1,MenuRedrawW-6);
-       VideoDrawVLineClip(ColorBlue,MenuRedrawX,MenuRedrawY+3,MenuRedrawH-6);
-       
VideoDrawVLineClip(ColorBlue,MenuRedrawX+MenuRedrawW-1,MenuRedrawY+3,MenuRedrawH-6);
+       VideoFill50TransRectangle(ColorBlack, MenuRedrawX + 1, MenuRedrawY + 1, 
MenuRedrawW - 2, MenuRedrawH - 2);
+       VideoDrawHLineClip(ColorBlue, MenuRedrawX + 3, MenuRedrawY, MenuRedrawW 
- 6);
+       VideoDrawHLineClip(ColorBlue, MenuRedrawX + 3, MenuRedrawY + 
MenuRedrawH - 1, MenuRedrawW - 6);
+       VideoDrawVLineClip(ColorBlue, MenuRedrawX, MenuRedrawY + 3, MenuRedrawH 
- 6);
+       VideoDrawVLineClip(ColorBlue, MenuRedrawX + MenuRedrawW - 1, 
MenuRedrawY + 3, MenuRedrawH - 6);
        // top left
-       VideoDrawPixelClip(ColorBlue,MenuRedrawX+1,MenuRedrawY+1);
-       VideoDrawPixelClip(ColorBlue,MenuRedrawX+2,MenuRedrawY+1);
-       VideoDrawPixelClip(ColorBlue,MenuRedrawX+1,MenuRedrawY+2);
+       VideoDrawPixelClip(ColorBlue, MenuRedrawX + 1, MenuRedrawY + 1);
+       VideoDrawPixelClip(ColorBlue, MenuRedrawX + 2, MenuRedrawY + 1);
+       VideoDrawPixelClip(ColorBlue, MenuRedrawX + 1, MenuRedrawY + 2);
        // top right
-       VideoDrawPixelClip(ColorBlue,MenuRedrawX+MenuRedrawW-3,MenuRedrawY+1);
-       VideoDrawPixelClip(ColorBlue,MenuRedrawX+MenuRedrawW-2,MenuRedrawY+1);
-       VideoDrawPixelClip(ColorBlue,MenuRedrawX+MenuRedrawW-2,MenuRedrawY+2);
+       VideoDrawPixelClip(ColorBlue, MenuRedrawX + MenuRedrawW - 3, 
MenuRedrawY + 1);
+       VideoDrawPixelClip(ColorBlue, MenuRedrawX + MenuRedrawW - 2, 
MenuRedrawY + 1);
+       VideoDrawPixelClip(ColorBlue, MenuRedrawX + MenuRedrawW - 2, 
MenuRedrawY + 2);
        // bottom left
-       VideoDrawPixelClip(ColorBlue,MenuRedrawX+1,MenuRedrawY+MenuRedrawH-3);
-       VideoDrawPixelClip(ColorBlue,MenuRedrawX+1,MenuRedrawY+MenuRedrawH-2);
-       VideoDrawPixelClip(ColorBlue,MenuRedrawX+2,MenuRedrawY+MenuRedrawH-2);
+       VideoDrawPixelClip(ColorBlue, MenuRedrawX + 1, MenuRedrawY + 
MenuRedrawH - 3);
+       VideoDrawPixelClip(ColorBlue, MenuRedrawX + 1, MenuRedrawY + 
MenuRedrawH - 2);
+       VideoDrawPixelClip(ColorBlue, MenuRedrawX + 2, MenuRedrawY + 
MenuRedrawH - 2);
        // bottom right
-       
VideoDrawPixelClip(ColorBlue,MenuRedrawX+MenuRedrawW-3,MenuRedrawY+MenuRedrawH-2);
-       
VideoDrawPixelClip(ColorBlue,MenuRedrawX+MenuRedrawW-2,MenuRedrawY+MenuRedrawH-2);
-       
VideoDrawPixelClip(ColorBlue,MenuRedrawX+MenuRedrawW-2,MenuRedrawY+MenuRedrawH-3);
+       VideoDrawPixelClip(ColorBlue, MenuRedrawX + MenuRedrawW - 3, 
MenuRedrawY + MenuRedrawH - 2);
+       VideoDrawPixelClip(ColorBlue, MenuRedrawX + MenuRedrawW - 2, 
MenuRedrawY + MenuRedrawH - 2);
+       VideoDrawPixelClip(ColorBlue, MenuRedrawX + MenuRedrawW - 2, 
MenuRedrawY + MenuRedrawH - 3);
     } else if (menu->Panel) {
-       MenuPanel *menupanel;
+       MenuPanel* menupanel;
 
        menupanel = TheUI.MenuPanels;
        while (menupanel) {
            if (!strcmp(menupanel->Ident, menu->Panel)) {
                break;
            }
-           menupanel=menupanel->Next;
+           menupanel = menupanel->Next;
        }
        if (menupanel) {
-           VideoDrawSub(menupanel->Panel.Graphic,0,0,
-                   VideoGraphicWidth(menupanel->Panel.Graphic),
-                   VideoGraphicHeight(menupanel->Panel.Graphic),
-                   menu->X,menu->Y);
+           VideoDrawSub(menupanel->Panel.Graphic, 0, 0,
+               VideoGraphicWidth(menupanel->Panel.Graphic),
+               VideoGraphicHeight(menupanel->Panel.Graphic),
+               menu->X, menu->Y);
        }
     }
 
     n = menu->NumItems;
     mi = menu->Items;
     mip = NULL;
-    for (i = 0; i < n; i++) {
+    for (i = 0; i < n; ++i) {
        switch (mi->mitype) {
            case MI_TYPE_TEXT:
                if (!mi->d.text.text) {
                    break;
                }
-               GetDefaultTextColors(&oldnc,&oldrc);
+               GetDefaultTextColors(&oldnc, &oldrc);
                if (mi->d.text.normalcolor || mi->d.text.reversecolor) {
                    nc = mi->d.text.normalcolor ? mi->d.text.normalcolor : 
oldnc;
                    rc = mi->d.text.reversecolor ? mi->d.text.reversecolor : 
oldrc;
-                   SetDefaultTextColors(nc,rc);
+                   SetDefaultTextColors(nc, rc);
                } else {
                    nc = oldnc;
                    rc = oldrc;
                }
-               if (mi->flags&MenuButtonActive && mi->d.text.action) {
-                   
VideoDrawRectangleClip(ColorGray,menu->X+mi->xofs-4,menu->Y+mi->yofs-4,
-                                           VideoTextLength(mi->font, 
mi->d.text.text)+5,
-                                           VideoTextHeight(mi->font)+5);
-                   SetDefaultTextColors(rc,rc);
-               }
-               if (mi->d.text.align&MI_TFLAGS_CENTERED) {
-                   VideoDrawTextCentered(menu->X+mi->xofs,menu->Y+mi->yofs,
-                           mi->font,mi->d.text.text);
-               } else if (mi->d.text.align&MI_TFLAGS_RALIGN) {
-                   l = VideoTextLength(mi->font,mi->d.text.text);
-                   VideoDrawText(menu->X+mi->xofs-l,menu->Y+mi->yofs,
-                           mi->font,mi->d.text.text);
+               if (mi->flags & MenuButtonActive && mi->d.text.action) {
+                   VideoDrawRectangleClip(ColorGray, menu->X + mi->xofs - 4, 
menu->Y + mi->yofs - 4,
+                                           VideoTextLength(mi->font, 
mi->d.text.text) + 5,
+                                           VideoTextHeight(mi->font) + 5);
+                   SetDefaultTextColors(rc, rc);
+               }
+               if (mi->d.text.align & MI_TFLAGS_CENTERED) {
+                   VideoDrawTextCentered(menu->X + mi->xofs, menu->Y + 
mi->yofs,
+                           mi->font, mi->d.text.text);
+               } else if (mi->d.text.align & MI_TFLAGS_RALIGN) {
+                   l = VideoTextLength(mi->font, mi->d.text.text);
+                   VideoDrawText(menu->X + mi->xofs-l,menu->Y + mi->yofs,
+                           mi->font, mi->d.text.text);
                } else {
-                   VideoDrawText(menu->X+mi->xofs,menu->Y+mi->yofs,
-                           mi->font,mi->d.text.text);
+                   VideoDrawText(menu->X + mi->xofs, menu->Y + mi->yofs,
+                           mi->font, mi->d.text.text);
                }
-               SetDefaultTextColors(oldnc,oldrc);
+               SetDefaultTextColors(oldnc, oldrc);
                break;
            case MI_TYPE_BUTTON:
-               DrawMenuButton(mi->d.button.button,mi->flags,
-                       mi->d.button.xsize,mi->d.button.ysize,
-                       menu->X+mi->xofs,menu->Y+mi->yofs,
-                       mi->font,mi->d.button.text,
-                       mi->d.button.normalcolor,mi->d.button.reversecolor);
+               DrawMenuButton(mi->d.button.button, mi->flags,
+                   mi->d.button.xsize, mi->d.button.ysize,
+                   menu->X + mi->xofs, menu->Y + mi->yofs,
+                   mi->font, mi->d.button.text,
+                   mi->d.button.normalcolor, mi->d.button.reversecolor);
                break;
            case MI_TYPE_PULLDOWN:
-               if (mi->flags&MenuButtonClicked) {
+               if (mi->flags & MenuButtonClicked) {
                    mip = mi;   // Delay, due to possible overlaying!
                } else {
-                   DrawPulldown(mi,menu->X,menu->Y);
+                   DrawPulldown(mi, menu->X, menu->Y);
                }
                break;
            case MI_TYPE_LISTBOX:
-               DrawListbox(mi,menu->X,menu->Y);
+               DrawListbox(mi, menu->X, menu->Y);
                break;
            case MI_TYPE_VSLIDER:
-               DrawVSlider(mi,menu->X,menu->Y);
+               DrawVSlider(mi, menu->X, menu->Y);
                break;
            case MI_TYPE_HSLIDER:
-               DrawHSlider(mi,menu->X,menu->Y);
+               DrawHSlider(mi, menu->X, menu->Y);
                break;
            case MI_TYPE_DRAWFUNC:
                if (mi->d.drawfunc.draw) {
@@ -1086,33 +1093,33 @@
                }
                break;
            case MI_TYPE_INPUT:
-               DrawInput(mi,menu->X,menu->Y);
+               DrawInput(mi, menu->X, menu->Y);
                break;
            case MI_TYPE_GEM:
-               DrawGem(mi,menu->X,menu->Y);
+               DrawGem(mi, menu->X, menu->Y);
                break;
            default:
                break;
        }
-       mi++;
+       ++mi;
     }
     if (mip) {
-       DrawPulldown(mip,menu->X,menu->Y);
+       DrawPulldown(mip, menu->X, menu->Y);
     }
 }
 
 /**
 **     Paste text from the clipboard
 */
-local void PasteFromClipboard(Menuitem *mi)
+local void PasteFromClipboard(Menuitem* mi)
 {
 #if defined(USE_WIN32) || defined(_XLIB_H_)
     int i;
-    char *clipboard;
+    char* clipboard;
 #ifdef USE_WIN32
     HGLOBAL handle;
 #elif defined(_XLIB_H_)
-    Display *display;
+    Display* display;
     Window window;
     Atom rettype;
     unsigned long nitem;
@@ -1159,7 +1166,7 @@
 
     XGetWindowProperty(display, window, XA_STRING, 0, 1024, False, 
        XA_STRING, &rettype, &retform, &nitem, &dummy, 
-       (unsigned char **)&clipboard);
+       (unsigned char**)&clipboard);
 
     XDestroyWindow(display, window);
     XCloseDisplay(display);
@@ -1204,12 +1211,12 @@
 **     @todo FIXME: Should be MenuKeyDown(), and act on _new_ MenuKeyUp() !!!
 **      to implement button animation (depress before action)
 */
-local void MenuHandleKeyDown(unsigned key,unsigned keychar)
+local void MenuHandleKeyDown(unsigned key, unsigned keychar)
 {
     int i;
     int n;
-    Menuitem *mi;
-    Menu *menu;
+    Menuitem* mi;
+    Menu* menu;
 
     HandleKeyModifiersDown(key, keychar);
 
@@ -1217,10 +1224,10 @@
        return;
     }
 
-    if( KeyCodeKP0 <= key && key <= KeyCodeKP9 ) {
-       key=keychar = '0' + key-KeyCodeKP0;
-    } else if( key==KeyCodeKPPeriod ) {
-       key=keychar = '.';
+    if (KeyCodeKP0 <= key && key <= KeyCodeKP9) {
+       key = keychar = '0' + key - KeyCodeKP0;
+    } else if (key == KeyCodeKPPeriod) {
+       key = keychar = '.';
     }
 
     menu = CurrentMenu;
@@ -1279,7 +1286,7 @@
     }
 
 normkey:
-    if( !(KeyModifiers&ModifierAlt) ) {
+    if (!(KeyModifiers & ModifierAlt)) {
        mi = menu->Items;
        i = menu->NumItems;
        while (i--) {
@@ -1294,7 +1301,7 @@
                default:
                    break;
            }
-           mi++;
+           ++mi;
        }
     }
     switch (key) {
@@ -1330,19 +1337,21 @@
        case KeyCodeUp: case KeyCodeDown:
            if (MenuButtonCurSel != -1) {
                mi = menu->Items + MenuButtonCurSel;
-               if (!(mi->flags&MenuButtonClicked)) {
+               if (!(mi->flags & MenuButtonClicked)) {
                    switch (mi->mitype) {
                        case MI_TYPE_PULLDOWN:
                            if (key == KeyCodeDown) {
-                               if (mi->d.pulldown.curopt + 1 < 
mi->d.pulldown.noptions)
+                               if (mi->d.pulldown.curopt + 1 < 
mi->d.pulldown.noptions) {
                                    mi->d.pulldown.curopt++;
-                               else
+                               } else {
                                    break;
+                               }
                            } else {
-                               if (mi->d.pulldown.curopt > 0)
+                               if (mi->d.pulldown.curopt > 0) {
                                    mi->d.pulldown.curopt--;
-                               else
+                               } else {
                                    break;
+                               }
                            }
                            MustRedraw |= RedrawMenu;
                            if (mi->d.pulldown.action) {
@@ -1396,7 +1405,7 @@
        case KeyCodeLeft: case KeyCodeRight:
            if (MenuButtonCurSel != -1) {
                mi = menu->Items + MenuButtonCurSel;
-               if (!(mi->flags&MenuButtonClicked)) {
+               if (!(mi->flags & MenuButtonClicked)) {
                    switch (mi->mitype) {
                        case MI_TYPE_HSLIDER:
                            if (key == KeyCodeLeft) {
@@ -1419,7 +1428,7 @@
            if (KeyModifiers&ModifierAlt) {
                break;
            }
-           if (MenuButtonCurSel != -1 && 
!(menu->Items[MenuButtonCurSel].flags&MenuButtonClicked)) {
+           if (MenuButtonCurSel != -1 && !(menu->Items[MenuButtonCurSel].flags 
& MenuButtonClicked)) {
                n = menu->NumItems;
                for (i = 0; i < n; ++i) {
                    mi = menu->Items + ((MenuButtonCurSel + i + 1) % n);
@@ -1450,7 +1459,7 @@
            break;
        case 'x':
        case 'X':
-           if( (KeyModifiers&ModifierAlt) ) {
+           if ((KeyModifiers & ModifierAlt)) {
                Exit(0);
            }
        default:
@@ -1461,8 +1470,8 @@
                    case MI_TYPE_INPUT:
                        if (!(mi->flags & MenuButtonDisabled)) {
                            if (MenuButtonCurSel != -1) {
-                               menu->Items[MenuButtonCurSel].flags
-                                       &= ~MenuButtonSelected;
+                               menu->Items[MenuButtonCurSel].flags &=
+                                   ~MenuButtonSelected;
                            }
                            mi->flags |= MenuButtonSelected;
                            MenuButtonCurSel = mi - menu->Items;
@@ -1472,7 +1481,7 @@
                    default:
                        break;
                }
-               mi++;
+               ++mi;
            }
            DebugLevel3("Key %d\n" _C_ key);
            return;
@@ -1486,9 +1495,9 @@
 **     @param key      Key scancode.
 **     @param keychar  ASCII character code of key.
 */
-local void MenuHandleKeyUp(unsigned key,unsigned keychar)
+local void MenuHandleKeyUp(unsigned key, unsigned keychar)
 {
-    HandleKeyModifiersUp(key,keychar);
+    HandleKeyModifiersUp(key, keychar);
 }
 
 /**
@@ -1497,16 +1506,16 @@
 **     @param key      Key scancode.
 **     @param keychar  ASCII character code of key.
 */
-local void MenuHandleKeyRepeat(unsigned key,unsigned keychar)
+local void MenuHandleKeyRepeat(unsigned key, unsigned keychar)
 {
-    HandleKeyModifiersDown(key,keychar);
+    HandleKeyModifiersDown(key, keychar);
 
     if (CurrentMenu == NULL) {
        return;
     }
 
     if (MenuButtonCurSel != -1 && CurrentMenu->Items[MenuButtonCurSel].mitype 
== MI_TYPE_INPUT) {
-       MenuHandleKeyDown(key,keychar);
+       MenuHandleKeyDown(key, keychar);
     }
 }
 
@@ -1516,7 +1525,7 @@
 **     @param x        Screen X position.
 **     @param y        Screen Y position.
 */
-local void MenuHandleMouseMove(int x,int y)
+local void MenuHandleMouseMove(int x, int y)
 {
     int h;
     int w;
@@ -1525,15 +1534,15 @@
     int n;
     int xs;
     int ys;
-    Menuitem *mi;
-    Menu *menu;
+    Menuitem* mi;
+    Menu* menu;
     int ox;
     int oy;
     int redraw_flag;
 
     ox = CursorX;
     oy = CursorY;                      // Old position for rel movement.
-    HandleCursorMove(&x,&y);
+    HandleCursorMove(&x, &y);
 
     if (CurrentMenu == NULL) {
        return;
@@ -1548,21 +1557,22 @@
     // check active (popped-up) pulldown first, as it may overlay other menus!
     mi = menu->Items;
     for (i = 0; i < n; ++i) {
-       if (!(mi->flags&MenuButtonDisabled)) {
-           if (mi->mitype == MI_TYPE_PULLDOWN && 
(mi->flags&MenuButtonClicked)) {
+       if (!(mi->flags & MenuButtonDisabled)) {
+           if (mi->mitype == MI_TYPE_PULLDOWN && (mi->flags & 
MenuButtonClicked)) {
                xs = menu->X + mi->xofs;
                ys = menu->Y + mi->yofs;
                if (mi->d.pulldown.button == MBUTTON_SC_PULLDOWN) {
                    int usetop;
 
                    h = mi->d.pulldown.ysize;
-                   if (mi->yofs + (h+1)*mi->d.pulldown.noptions >= 
mi->menu->Height) {
-                       ys -= h*mi->d.pulldown.noptions;
+                   if (mi->yofs + (h + 1) * mi->d.pulldown.noptions >= 
mi->menu->Height) {
+                       ys -= h * mi->d.pulldown.noptions;
                        usetop = 0;
                    } else {
                        usetop = 1;
                    }
-                   if (!(x<xs || x>xs + mi->d.pulldown.xsize || y<ys || y>ys + 
(h+1)*mi->d.pulldown.noptions)) {
+                   if (!(x < xs || x > xs + mi->d.pulldown.xsize || y < ys ||
+                           y > ys + (h + 1) * mi->d.pulldown.noptions)) {
                        j = (y - ys) / h;
                        if (usetop) {
                            --j;
@@ -1586,11 +1596,12 @@
                        ys = 2 + CurrentMenu->Y;
                    } else {
                        ys -= mi->d.pulldown.curopt * h;
-                       if (ys + h*mi->d.pulldown.noptions >= 480 + 
CurrentMenu->Y) {
-                           ys -= ys + h*mi->d.pulldown.noptions - (480 + 
CurrentMenu->Y);
+                       if (ys + h * mi->d.pulldown.noptions >= 480 + 
CurrentMenu->Y) {
+                           ys -= ys + h * mi->d.pulldown.noptions - (480 + 
CurrentMenu->Y);
                        }
                    }
-                   if (!(x<xs || x>xs + mi->d.pulldown.xsize || y<ys || y>ys + 
h*mi->d.pulldown.noptions)) {
+                   if (!(x < xs || x > xs + mi->d.pulldown.xsize || y < ys ||
+                           y > ys + h * mi->d.pulldown.noptions)) {
                        j = (y - ys) / h;
                        if (j >= 0 && j < mi->d.pulldown.noptions && j != 
mi->d.pulldown.cursel) {
                            mi->d.pulldown.cursel = j;
@@ -1605,22 +1616,22 @@
                break;
            }
        }
-       mi++;
+       ++mi;
     }
     if (MenuButtonUnderCursor == -1) {
        for (i = 0; i < n; ++i) {
            mi = menu->Items + i;
-           if (!(mi->flags&MenuButtonDisabled)) {
+           if (!(mi->flags & MenuButtonDisabled)) {
                switch (mi->mitype) {
                    case MI_TYPE_TEXT:
                        if (!mi->d.text.text || !mi->d.text.action)
                            continue;
                        xs = menu->X + mi->xofs;
                        ys = menu->Y + mi->yofs;
-                       if (x < xs - 4 || x > xs + VideoTextLength(mi->font, 
mi->d.text.text)+5
-                           || y < ys - 4 || y > ys + 
VideoTextHeight(mi->font)+5) {
-                           if (!(mi->flags&MenuButtonClicked)) {
-                               if (mi->flags&MenuButtonActive) {
+                       if (x < xs - 4 || x > xs + VideoTextLength(mi->font, 
mi->d.text.text) + 5 ||
+                               y < ys - 4 || y > ys + 
VideoTextHeight(mi->font) + 5) {
+                           if (!(mi->flags & MenuButtonClicked)) {
+                               if (mi->flags & MenuButtonActive) {
                                    redraw_flag = 1;
                                    mi->flags &= ~MenuButtonActive;
                                }
@@ -1632,11 +1643,12 @@
                        xs = menu->X + mi->xofs;
                        ys = menu->Y + mi->yofs;
                        if ((!mi->d.gem.text || x < xs - 1 || x > xs + 
-                               VideoTextLength(GameFont, mi->d.gem.text)+28 || 
y < ys - 2 || 
-                               y > ys + VideoTextHeight(GameFont)+9) && (x < 
xs || 
-                               x > xs + mi->d.gem.xsize || y < ys || y > ys + 
mi->d.gem.ysize)) {
-                           if (!(mi->flags&MenuButtonClicked)) {
-                               if (mi->flags&MenuButtonActive) {
+                               VideoTextLength(GameFont, mi->d.gem.text) + 28 
||
+                               y < ys - 2 ||  y > ys + 
VideoTextHeight(GameFont) + 9) &&
+                               (x < xs ||  x > xs + mi->d.gem.xsize || y < ys 
||
+                               y > ys + mi->d.gem.ysize)) {
+                           if (!(mi->flags & MenuButtonClicked)) {
+                               if (mi->flags & MenuButtonActive) {
                                    redraw_flag = 1;
                                    mi->flags &= ~MenuButtonActive;
                                }
@@ -1647,9 +1659,10 @@
                    case MI_TYPE_BUTTON:
                        xs = menu->X + mi->xofs;
                        ys = menu->Y + mi->yofs;
-                       if (x < xs || x > xs + mi->d.button.xsize || y < ys || 
y > ys + mi->d.button.ysize) {
-                           if (!(mi->flags&MenuButtonClicked)) {
-                               if (mi->flags&MenuButtonActive) {
+                       if (x < xs || x > xs + mi->d.button.xsize || y < ys ||
+                               y > ys + mi->d.button.ysize) {
+                           if (!(mi->flags & MenuButtonClicked)) {
+                               if (mi->flags & MenuButtonActive) {
                                    redraw_flag = 1;
                                    mi->flags &= ~MenuButtonActive;
                                }
@@ -1660,10 +1673,10 @@
                    case MI_TYPE_INPUT:
                        xs = menu->X + mi->xofs;
                        ys = menu->Y + mi->yofs;
-                       if (x<xs || x>xs + mi->d.input.xsize
-                               || y<ys || y>ys + mi->d.input.ysize) {
-                           if (!(mi->flags&MenuButtonClicked)) {
-                               if (mi->flags&MenuButtonActive) {
+                       if (x < xs || x > xs + mi->d.input.xsize
+                               || y < ys || y > ys + mi->d.input.ysize) {
+                           if (!(mi->flags & MenuButtonClicked)) {
+                               if (mi->flags & MenuButtonActive) {
                                    redraw_flag = 1;
                                    mi->flags &= ~MenuButtonActive;
                                }
@@ -1678,9 +1691,10 @@
                        // Clicked-state already checked above - there can only 
be one!
                        xs = menu->X + mi->xofs;
                        ys = menu->Y + mi->yofs;
-                       if (x<xs || x>xs + mi->d.pulldown.xsize || y<ys || y>ys 
+ mi->d.pulldown.ysize) {
-                           if (!(mi->flags&MenuButtonClicked)) {
-                               if (mi->flags&MenuButtonActive) {
+                       if (x < xs || x > xs + mi->d.pulldown.xsize || y<ys ||
+                               y > ys + mi->d.pulldown.ysize) {
+                           if (!(mi->flags & MenuButtonClicked)) {
+                               if (mi->flags & MenuButtonActive) {
                                    redraw_flag = 1;
                                    mi->flags &= ~MenuButtonActive;
                                }
@@ -1691,9 +1705,10 @@
                    case MI_TYPE_LISTBOX:
                        xs = menu->X + mi->xofs;
                        ys = menu->Y + mi->yofs;
-                       if (x < xs || x > xs + mi->d.listbox.xsize || y < ys || 
y > ys + mi->d.listbox.ysize) {
-                           if (!(mi->flags&MenuButtonClicked)) {
-                               if (mi->flags&MenuButtonActive) {
+                       if (x < xs || x > xs + mi->d.listbox.xsize || y < ys ||
+                               y > ys + mi->d.listbox.ysize) {
+                           if (!(mi->flags & MenuButtonClicked)) {
+                               if (mi->flags & MenuButtonActive) {
                                    redraw_flag = 1;
                                    mi->flags &= ~MenuButtonActive;
                                }
@@ -1704,7 +1719,7 @@
                        if (j != mi->d.listbox.cursel) {
                            mi->d.listbox.cursel = j;   // just store for click
                        }
-                       if (mi->flags&MenuButtonClicked && 
mi->flags&MenuButtonActive) {
+                       if (mi->flags & MenuButtonClicked && mi->flags & 
MenuButtonActive) {
                            if (mi->d.listbox.cursel != mi->d.listbox.curopt) {
                                mi->d.listbox.dohandler = 0;
                                mi->d.listbox.curopt = mi->d.listbox.cursel;
@@ -1721,14 +1736,16 @@
 
                        xs = menu->X + mi->xofs;
                        ys = menu->Y + mi->yofs;
-                       if (x < xs || x > xs + mi->d.vslider.xsize || y < ys || 
y > ys + mi->d.vslider.ysize) {
-                           if (!(mi->flags&MenuButtonClicked)) {
-                               if (mi->flags&MenuButtonActive) {
+                       if (x < xs || x > xs + mi->d.vslider.xsize || y < ys ||
+                               y > ys + mi->d.vslider.ysize) {
+                           if (!(mi->flags & MenuButtonClicked)) {
+                               if (mi->flags & MenuButtonActive) {
                                    redraw_flag = 1;
                                    mi->flags &= ~MenuButtonActive;
                                }
                            }
-                           if (y < ys || y > ys + mi->d.vslider.ysize || 
!(mi->flags&MenuButtonClicked)) {
+                           if (y < ys || y > ys + mi->d.vslider.ysize ||
+                                   !(mi->flags & MenuButtonClicked)) {
                                mi->d.vslider.cursel = 0;
                                continue;
                            }
@@ -1744,10 +1761,10 @@
 
                        if (j < arrowsize) {
                            mi->d.vslider.cursel |= MI_CFLAGS_UP;
-                       } else if (j >= mi->d.vslider.ysize - arrowsize-1) {
+                       } else if (j >= mi->d.vslider.ysize - arrowsize - 1) {
                            mi->d.vslider.cursel |= MI_CFLAGS_DOWN;
                        } else {
-                           mi->d.vslider.cursel &= 
~(MI_CFLAGS_UP|MI_CFLAGS_DOWN);
+                           mi->d.vslider.cursel &= ~(MI_CFLAGS_UP | 
MI_CFLAGS_DOWN);
                            h = (mi->d.vslider.percent * (mi->d.vslider.ysize - 
54)) / 100 + 18;
                            if (j > h && j < h + 16) {
                                mi->d.vslider.cursel |= MI_CFLAGS_KNOB;
@@ -1780,14 +1797,15 @@
 
                        xs = menu->X + mi->xofs;
                        ys = menu->Y + mi->yofs;
-                       if (x < xs || x > xs + mi->d.hslider.xsize || y < ys || 
y > ys + mi->d.hslider.ysize) {
-                           if (!(mi->flags&MenuButtonClicked)) {
-                               if (mi->flags&MenuButtonActive) {
+                       if (x < xs || x > xs + mi->d.hslider.xsize || y < ys ||
+                               y > ys + mi->d.hslider.ysize) {
+                           if (!(mi->flags & MenuButtonClicked)) {
+                               if (mi->flags & MenuButtonActive) {
                                    redraw_flag = 1;
                                    mi->flags &= ~MenuButtonActive;
                                }
                            }
-                           if (x < xs || x > xs + mi->d.hslider.xsize || 
!(mi->flags&MenuButtonClicked)) {
+                           if (x < xs || x > xs + mi->d.hslider.xsize || 
!(mi->flags & MenuButtonClicked)) {
                                mi->d.hslider.cursel = 0;
                                continue;
                            }
@@ -1806,7 +1824,7 @@
                        } else if (j >= mi->d.hslider.xsize - arrowsize-1) {
                            mi->d.hslider.cursel |= MI_CFLAGS_RIGHT;
                        } else {
-                           mi->d.hslider.cursel &= 
~(MI_CFLAGS_LEFT|MI_CFLAGS_RIGHT);
+                           mi->d.hslider.cursel &= ~(MI_CFLAGS_LEFT | 
MI_CFLAGS_RIGHT);
                            w = (mi->d.hslider.percent * (mi->d.hslider.xsize - 
54)) / 100 + 18;
                            if (j > w && j < w + 16) {
                                mi->d.hslider.cursel |= MI_CFLAGS_KNOB;
@@ -1839,7 +1857,7 @@
                }
                switch (mi->mitype) {
                    case MI_TYPE_GEM:
-                       if ((mi->d.gem.state & 
(MI_GSTATE_PASSIVE|MI_GSTATE_INVISIBLE))) {
+                       if ((mi->d.gem.state & (MI_GSTATE_PASSIVE | 
MI_GSTATE_INVISIBLE))) {
                            break;
                        }
                        /* FALL THROUGH */
@@ -1849,7 +1867,7 @@
                    case MI_TYPE_VSLIDER:
                    case MI_TYPE_HSLIDER:
                    case MI_TYPE_TEXT:
-                       if (!(mi->flags&MenuButtonActive)) {
+                       if (!(mi->flags & MenuButtonActive)) {
                            redraw_flag = 1;
                            mi->flags |= MenuButtonActive;
                        }
@@ -1857,7 +1875,7 @@
                    default:
                        break;
                    case MI_TYPE_INPUT:
-                       if (!(mi->flags&MenuButtonActive)) {
+                       if (!(mi->flags & MenuButtonActive)) {
                            redraw_flag = 1;
                            mi->flags |= MenuButtonActive;
                        }
@@ -1867,9 +1885,9 @@
                                char* s;
 
                                j = strtol(mi->d.input.buffer, &s, 0);
-                               if ((!*s || s[0]=='~') && (j!=0 || 
*mi->d.input.buffer=='0') ) {
+                               if ((!*s || s[0] == '~') && (j != 0 || 
*mi->d.input.buffer == '0')) {
                                    int num;
-                                   num = j + x - ox + (y - oy)*1000;
+                                   num = j + x - ox + (y - oy) * 1000;
                                    if (num < 0) {
                                        num = 0;
                                    }
@@ -1903,8 +1921,8 @@
 */
 local void MenuHandleButtonDown(unsigned b __attribute__((unused)))
 {
-    Menuitem *mi;
-    Menu *menu;
+    Menuitem* mi;
+    Menu* menu;
 
     if (CurrentMenu == NULL) {
        return;
@@ -1912,13 +1930,14 @@
 
     menu = CurrentMenu;
 
-    if (MouseButtons&(LeftButton<<MouseHoldShift))
+    if (MouseButtons & (LeftButton << MouseHoldShift)) {
        return;
+    }
 
-    if (MouseButtons&LeftButton) {
+    if (MouseButtons & LeftButton) {
        if (MenuButtonUnderCursor != -1) {
            mi = menu->Items + MenuButtonUnderCursor;
-           if (!(mi->flags&MenuButtonClicked)) {
+           if (!(mi->flags & MenuButtonClicked)) {
                switch (mi->mitype) {
                    case MI_TYPE_GEM:
                    case MI_TYPE_BUTTON:
@@ -1932,13 +1951,13 @@
                            menu->Items[MenuButtonCurSel].flags &= 
~MenuButtonSelected;
                        }
                        MenuButtonCurSel = MenuButtonUnderCursor;
-                       mi->flags |= MenuButtonClicked|MenuButtonSelected;
+                       mi->flags |= MenuButtonClicked | MenuButtonSelected;
                        MustRedraw |= RedrawMenu;
                    default:
                        break;
                }
            }
-           PlayGameSound(GameSounds.Click.Sound,MaxSampleVolume);
+           PlayGameSound(GameSounds.Click.Sound, MaxSampleVolume);
            switch (mi->mitype) {
                case MI_TYPE_VSLIDER:
                    mi->d.vslider.cflags = mi->d.vslider.cursel;
@@ -1954,7 +1973,7 @@
                    break;
                case MI_TYPE_PULLDOWN:
                    if (mi->d.pulldown.curopt >= 0 &&
-                                           mi->d.pulldown.curopt < 
mi->d.pulldown.noptions) {
+                           mi->d.pulldown.curopt < mi->d.pulldown.noptions) {
                        mi->d.pulldown.cursel = mi->d.pulldown.curopt;
                    }
                    break;
@@ -1979,7 +1998,7 @@
     if (MouseButtons&MiddleButton) {
        if (MenuButtonUnderCursor != -1) {
            mi = menu->Items + MenuButtonUnderCursor;
-           if (!(mi->flags&MenuButtonClicked)) {
+           if (!(mi->flags & MenuButtonClicked)) {
                switch (mi->mitype) {
                    case MI_TYPE_INPUT:
                        PasteFromClipboard(mi);
@@ -2005,11 +2024,13 @@
                    }
                    if (mi->d.listbox.startline > 0) {
                        mi->d.listbox.startline--;
-                       if (mi->d.listbox.curopt != mi->d.listbox.nlines - 1)
+                       if (mi->d.listbox.curopt != mi->d.listbox.nlines - 1) {
                            mi->d.listbox.curopt++;
+                       }
                    } else {
                        if (mi->d.listbox.curopt != 0) {
-                           mi->d.listbox.curopt--; }
+                           mi->d.listbox.curopt--;
+                       }
                    }
                    if (mi->d.listbox.action) {
                        (*mi->d.listbox.action)(mi, mi->d.listbox.curopt + 
mi->d.listbox.startline);
@@ -2110,8 +2131,8 @@
 {
     int i;
     int n;
-    Menuitem *mi;
-    Menu *menu;
+    Menuitem* mi;
+    Menu* menu;
     int redraw_flag;
     
     if (CurrentMenu == NULL) {
@@ -2121,13 +2142,13 @@
     redraw_flag = 0;
     menu = CurrentMenu;
 
-    if ((1<<b) == LeftButton) {
+    if ((1 << b) == LeftButton) {
        n = menu->NumItems;
        for (i = 0; i < n; ++i) {
            mi = menu->Items + i;
            switch (mi->mitype) {
                case MI_TYPE_GEM:
-                   if (mi->flags&MenuButtonClicked) {
+                   if (mi->flags & MenuButtonClicked) {
                        redraw_flag = 1;
                        mi->flags &= ~MenuButtonClicked;
                        if (MenuButtonUnderCursor == i) {
@@ -2144,7 +2165,7 @@
                    }
                    break;
                case MI_TYPE_TEXT:
-                   if (mi->flags&MenuButtonClicked) {
+                   if (mi->flags & MenuButtonClicked) {
                        redraw_flag = 1;
                        mi->flags &= ~MenuButtonClicked;
                        if (MenuButtonUnderCursor == i) {
@@ -2156,7 +2177,7 @@
                    }
                    break;
                case MI_TYPE_BUTTON:
-                   if (mi->flags&MenuButtonClicked) {
+                   if (mi->flags & MenuButtonClicked) {
                        redraw_flag = 1;
                        mi->flags &= ~MenuButtonClicked;
                        if (MenuButtonUnderCursor == i) {
@@ -2168,14 +2189,14 @@
                    }
                    break;
                case MI_TYPE_PULLDOWN:
-                   if (mi->flags&MenuButtonClicked) {
+                   if (mi->flags & MenuButtonClicked) {
                        redraw_flag = 1;
                        mi->flags &= ~MenuButtonClicked;
                        if (MenuButtonUnderCursor == i) {
                            MenuButtonUnderCursor = -1;
                            if (mi->d.pulldown.cursel != mi->d.pulldown.curopt 
&&
-                                           mi->d.pulldown.cursel >= 0 &&
-                                           mi->d.pulldown.cursel < 
mi->d.pulldown.noptions) {
+                                   mi->d.pulldown.cursel >= 0 &&
+                                   mi->d.pulldown.cursel < 
mi->d.pulldown.noptions) {
                                mi->d.pulldown.curopt = mi->d.pulldown.cursel;
                                if (mi->d.pulldown.action) {
                                    (*mi->d.pulldown.action)(mi, 
mi->d.pulldown.curopt);
@@ -2186,7 +2207,7 @@
                    }
                    break;
                case MI_TYPE_LISTBOX:
-                   if (mi->flags&MenuButtonClicked) {
+                   if (mi->flags & MenuButtonClicked) {
                        redraw_flag = 1;
                        mi->flags &= ~MenuButtonClicked;
                        if (MenuButtonUnderCursor == i) {
@@ -2198,21 +2219,21 @@
                    }
                    break;
                case MI_TYPE_INPUT:
-                   if (mi->flags&MenuButtonClicked) {
+                   if (mi->flags & MenuButtonClicked) {
                        redraw_flag = 1;
                        mi->flags &= ~MenuButtonClicked;
                        // MAYBE ADD HERE
                    }
                    break;
                case MI_TYPE_VSLIDER:
-                   if (mi->flags&MenuButtonClicked) {
+                   if (mi->flags & MenuButtonClicked) {
                        redraw_flag = 1;
                        mi->flags &= ~MenuButtonClicked;
                        mi->d.vslider.cflags = 0;
                    }
                    break;
                case MI_TYPE_HSLIDER:
-                   if (mi->flags&MenuButtonClicked) {
+                   if (mi->flags & MenuButtonClicked) {
                        redraw_flag = 1;
                        mi->flags &= ~MenuButtonClicked;
                        mi->d.hslider.cflags = 0;
@@ -2310,13 +2331,13 @@
 **
 **     @todo FIXME: This function is called from the event handler!!
 */
-global void ProcessMenu(const char *menu_id, int loop)
+global void ProcessMenu(const char* menu_id, int loop)
 {
     int i;
     int oldncr;
-    Menuitem *mi;
-    Menu *menu;
-    Menu *CurrentMenuSave;
+    Menuitem* mi;
+    Menu* menu;
+    Menu* CurrentMenuSave;
     int MenuButtonUnderCursorSave;
     int MenuButtonCurSelSave;
 
@@ -2367,8 +2388,7 @@
            case MI_TYPE_VSLIDER:
            case MI_TYPE_HSLIDER:
            case MI_TYPE_INPUT:
-               mi->flags &= ~(MenuButtonClicked|MenuButtonActive
-                               |MenuButtonSelected);
+               mi->flags &= ~(MenuButtonClicked | MenuButtonActive | 
MenuButtonSelected);
                if (i == menu->DefSel) {
                    mi->flags |= MenuButtonSelected;
                    MenuButtonCurSel = i;
@@ -2414,7 +2434,7 @@
     MustRedraw = RedrawEverything;
     if (loop) {
        while (CurrentMenu != NULL) {
-           if (!(FrameCounter % ((VideoSyncSpeed * CYCLES_PER_SECOND)/50))) {
+           if (!(FrameCounter % ((VideoSyncSpeed * CYCLES_PER_SECOND) / 50))) {
                PlaySectionMusic(PlaySectionUnknown);
            }
            DebugLevel3("MustRedraw: 0x%08x\n" _C_ MustRedraw);
@@ -2449,7 +2469,7 @@
            }
        }
     } else {
-       
InvalidateAreaAndCheckCursor(MenuRedrawX,MenuRedrawY,MenuRedrawW,MenuRedrawH);
+       InvalidateAreaAndCheckCursor(MenuRedrawX, MenuRedrawY, MenuRedrawW, 
MenuRedrawH);
     }
 
     if (loop) {
@@ -2479,8 +2499,8 @@
 global void InitMenus(int race)
 {
     static int last_race = -1;
-    const char *file;
-    char *buf;
+    const char* file;
+    char* buf;
     int width;
     int height;
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]