From: Holger Schemel Date: Sat, 9 Jan 1999 21:24:16 +0000 (+0100) Subject: rnd-19990109-2 X-Git-Tag: 1.3.0^2~31 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=05c80e257e74b9f48c5d4b5cc807db0a4fb82fd2;p=rocksndiamonds.git rnd-19990109-2 --- diff --git a/src/buttons.c b/src/buttons.c index bdac8670..c5d998a3 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -1985,8 +1985,6 @@ void AdjustScrollbar(struct GadgetInfo *gi, int items_max, int item_pos) if (gs->item_position == gs->items_max - gs->items_visible) gs->position = gs->position_max; - printf("gs->item_position == %d\n", gs->item_position); - if (gi->mapped) DrawGadget(gi, DG_UNPRESSED, DG_DIRECT); } @@ -2014,8 +2012,8 @@ static struct GadgetInfo *last_gi = NULL; void HandleGadgets(int mx, int my, int button) { static unsigned long pressed_delay = 0; - static last_button = 0; - static last_mx = 0, last_my = 0; + static int last_button = 0; + static int last_mx = 0, last_my = 0; int scrollbar_mouse_pos; struct GadgetInfo *new_gi, *gi; boolean press_event; @@ -2166,8 +2164,6 @@ void HandleGadgets(int mx, int my, int button) { gi->event.item_position = gs->item_position; changed_position = TRUE; - - printf("gs->item_position == %d\n", gs->item_position); } AdjustScrollbar(gi, gs->items_max, gs->item_position); @@ -2238,8 +2234,6 @@ void HandleGadgets(int mx, int my, int button) { gi->event.item_position = gs->item_position; changed_position = TRUE; - - printf("gs->item_position == %d\n", gs->item_position); } DrawGadget(gi, DG_PRESSED, DG_DIRECT); diff --git a/src/buttons.h b/src/buttons.h index aca41e10..b5ca564b 100644 --- a/src/buttons.h +++ b/src/buttons.h @@ -151,8 +151,8 @@ #define ED_BUTTON_EDOWN_Y2POS 165 #define ED_BUTTON_ELEM_Y2POS 190 -#define ED_SCROLLBUTTON_XSIZE 30 -#define ED_SCROLLBUTTON_YSIZE 20 +#define ED_CURSORBUTTON_XSIZE 30 +#define ED_CURSORBUTTON_YSIZE 20 #define ED_BUTTON_CTRL_XPOS 5 #define ED_BUTTON_CTRL_YPOS 5 @@ -164,20 +164,20 @@ #define ED_BUTTON_FILL_YSIZE 20 #define ED_BUTTON_LEFT_XPOS 5 #define ED_BUTTON_LEFT_YPOS 65 -#define ED_BUTTON_LEFT_XSIZE ED_SCROLLBUTTON_XSIZE -#define ED_BUTTON_LEFT_YSIZE ED_SCROLLBUTTON_YSIZE +#define ED_BUTTON_LEFT_XSIZE ED_CURSORBUTTON_XSIZE +#define ED_BUTTON_LEFT_YSIZE ED_CURSORBUTTON_YSIZE #define ED_BUTTON_UP_XPOS 35 #define ED_BUTTON_UP_YPOS 55 -#define ED_BUTTON_UP_XSIZE ED_SCROLLBUTTON_XSIZE -#define ED_BUTTON_UP_YSIZE ED_SCROLLBUTTON_YSIZE +#define ED_BUTTON_UP_XSIZE ED_CURSORBUTTON_XSIZE +#define ED_BUTTON_UP_YSIZE ED_CURSORBUTTON_YSIZE #define ED_BUTTON_DOWN_XPOS 35 #define ED_BUTTON_DOWN_YPOS 75 -#define ED_BUTTON_DOWN_XSIZE ED_SCROLLBUTTON_XSIZE -#define ED_BUTTON_DOWN_YSIZE ED_SCROLLBUTTON_YSIZE +#define ED_BUTTON_DOWN_XSIZE ED_CURSORBUTTON_XSIZE +#define ED_BUTTON_DOWN_YSIZE ED_CURSORBUTTON_YSIZE #define ED_BUTTON_RIGHT_XPOS 65 #define ED_BUTTON_RIGHT_YPOS 65 -#define ED_BUTTON_RIGHT_XSIZE ED_SCROLLBUTTON_XSIZE -#define ED_BUTTON_RIGHT_YSIZE ED_SCROLLBUTTON_YSIZE +#define ED_BUTTON_RIGHT_XSIZE ED_CURSORBUTTON_XSIZE +#define ED_BUTTON_RIGHT_YSIZE ED_CURSORBUTTON_YSIZE #define ED_BUTTON_EDIT_XPOS 5 #define ED_BUTTON_EDIT_YPOS 5 diff --git a/src/editor.c b/src/editor.c index 7d885e14..b38e5aa9 100644 --- a/src/editor.c +++ b/src/editor.c @@ -87,6 +87,24 @@ #define ED_AREA_ELEMCONT_YPOS (10 * TILEY) /* values for scrolling gadgets */ +#if 1 +#define ED_SCROLLBUTTON_XSIZE 16 +#define ED_SCROLLBUTTON_YSIZE 16 + +#define ED_SCROLLBUTTON_XPOS 24 +#define ED_SCROLLBUTTON_YPOS 0 +#define ED_SCROLLBAR_XPOS 24 +#define ED_SCROLLBAR_YPOS 64 +#else +#define ED_SCROLLBUTTON_XSIZE 30 +#define ED_SCROLLBUTTON_YSIZE 30 + +#define ED_SCROLLBUTTON_XPOS 70 +#define ED_SCROLLBUTTON_YPOS 0 +#define ED_SCROLLBAR_XPOS 10 +#define ED_SCROLLBAR_YPOS 110 +#endif + #define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE) #define ED_SCROLL_UP_YPOS (0) #define ED_SCROLL_DOWN_XPOS ED_SCROLL_UP_XPOS @@ -95,14 +113,14 @@ #define ED_SCROLL_LEFT_YPOS (SYSIZE - ED_SCROLLBUTTON_YSIZE) #define ED_SCROLL_RIGHT_XPOS (SXSIZE - TILEX - ED_SCROLLBUTTON_XSIZE) #define ED_SCROLL_RIGHT_YPOS ED_SCROLL_LEFT_YPOS -#define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS -#define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + 20) -#define ED_SCROLL_VERTICAL_XSIZE 30 -#define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - TILEY - 2 * 20) -#define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + 30) -#define ED_SCROLL_HORIZONTAL_YPOS (SYSIZE - 30) -#define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - TILEX - 2*30) -#define ED_SCROLL_HORIZONTAL_YSIZE 30 +#define ED_SCROLL_VERTICAL_XPOS ED_SCROLL_UP_XPOS +#define ED_SCROLL_VERTICAL_YPOS (ED_SCROLL_UP_YPOS + ED_SCROLLBUTTON_YSIZE) +#define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE +#define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - TILEY - 2 * ED_SCROLLBUTTON_YSIZE) +#define ED_SCROLL_HORIZONTAL_XPOS (ED_SCROLL_LEFT_XPOS + ED_SCROLLBUTTON_XSIZE) +#define ED_SCROLL_HORIZONTAL_YPOS (SYSIZE - ED_SCROLLBUTTON_YSIZE) +#define ED_SCROLL_HORIZONTAL_XSIZE (SXSIZE - TILEX - 2 * ED_SCROLLBUTTON_XSIZE) +#define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE /* control button identifiers */ #define ED_CTRL_ID_SINGLE_ITEMS 0 @@ -182,13 +200,13 @@ static struct int gadget_id; } scrollbutton_info[ED_NUM_SCROLLBUTTONS] = { - { ED_BUTTON_UP_XPOS, ED_BUTTON_UP_YPOS, + { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 0 * ED_SCROLLBUTTON_YSIZE, ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS, ED_CTRL_ID_SCROLL_UP }, - { ED_BUTTON_DOWN_XPOS, ED_BUTTON_DOWN_YPOS, + { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 1 * ED_SCROLLBUTTON_YSIZE, ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS, ED_CTRL_ID_SCROLL_DOWN }, - { ED_BUTTON_LEFT_XPOS, ED_BUTTON_LEFT_YPOS, + { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 2 * ED_SCROLLBUTTON_YSIZE, ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS, ED_CTRL_ID_SCROLL_LEFT }, - { ED_BUTTON_RIGHT_XPOS, ED_BUTTON_RIGHT_YPOS, + { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 3 * ED_SCROLLBUTTON_YSIZE, ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS, ED_CTRL_ID_SCROLL_RIGHT } }; @@ -201,12 +219,12 @@ static struct int gadget_id; } scrollbar_info[ED_NUM_SCROLLBARS] = { - { GAME_CONTROL_XPOS, GAME_CONTROL_YPOS - GAME_BUTTON_YSIZE, + { ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS, ED_SCROLL_VERTICAL_XPOS, ED_SCROLL_VERTICAL_YPOS, ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE, GD_TYPE_SCROLLBAR_VERTICAL, ED_CTRL_ID_SCROLL_VERTICAL }, - { GAME_CONTROL_XPOS, GAME_CONTROL_YPOS - GAME_BUTTON_YSIZE, + { ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS, ED_SCROLL_HORIZONTAL_XPOS, ED_SCROLL_HORIZONTAL_YPOS, ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE, GD_TYPE_SCROLLBAR_HORIZONTAL, @@ -766,9 +784,9 @@ static void CreateControlButtons() event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED; - gd_x1 = DOOR_GFX_PAGEX6 + scrollbutton_info[i].xpos; - gd_x2 = DOOR_GFX_PAGEX5 + scrollbutton_info[i].xpos; - gd_y = DOOR_GFX_PAGEY2 + scrollbutton_info[i].ypos; + gd_y = DOOR_GFX_PAGEY1 + scrollbutton_info[i].ypos; + gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].xpos; + gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE; gi = CreateGadget(GDI_CUSTOM_ID, id, GDI_X, SX + scrollbutton_info[i].x, @@ -951,7 +969,7 @@ static void CreateScrollbarGadgets() { int id = scrollbar_info[i].gadget_id; Pixmap gd_pixmap = pix[PIX_DOOR]; - int gd_x1, gd_x2, gd_y; + int gd_x1, gd_x2, gd_y1, gd_y2; struct GadgetInfo *gi; int items_max, items_visible, item_position; unsigned long event_mask; @@ -971,9 +989,17 @@ static void CreateScrollbarGadgets() event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS; - gd_x1 = DOOR_GFX_PAGEX4 + scrollbar_info[i].xpos; - gd_x2 = DOOR_GFX_PAGEX3 + scrollbar_info[i].xpos; - gd_y = DOOR_GFX_PAGEY1 + scrollbar_info[i].ypos; +#if 1 + gd_x1 = DOOR_GFX_PAGEX8 + scrollbar_info[i].xpos; + gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE; + gd_y1 = DOOR_GFX_PAGEY1 + scrollbar_info[i].ypos; + gd_y2 = DOOR_GFX_PAGEY1 + scrollbar_info[i].ypos; +#else + gd_x1 = DOOR_GFX_PAGEX8 + scrollbar_info[i].xpos; + gd_y1 = DOOR_GFX_PAGEY1 + scrollbar_info[i].ypos; + gd_x2 = gd_x1; + gd_y2 = gd_y1 - ED_SCROLLBUTTON_YSIZE; +#endif gi = CreateGadget(GDI_CUSTOM_ID, id, GDI_X, SX + scrollbar_info[i].x, @@ -985,8 +1011,8 @@ static void CreateScrollbarGadgets() GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible, GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_STATE, GD_BUTTON_UNPRESSED, - GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y, - GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y, + GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y1, + GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y2, GDI_DESIGN_BORDER, 3, GDI_EVENT_MASK, event_mask, GDI_CALLBACK, HandleControlButtons, @@ -2482,8 +2508,8 @@ static void SelectArea(int from_x, int from_y, int to_x, int to_y, static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y, int mode) { static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; - static brush_from_x, brush_from_y; - static brush_to_x, brush_to_y; + static int brush_from_x, brush_from_y; + static int brush_to_x, brush_to_y; int x, y; if (from_x > to_x) @@ -2572,6 +2598,20 @@ static void DrawLevelText(int sx, int sy, char letter, int mode) int letter_element = EL_CHAR_ASCII0 + letter; int lx, ly; + /* map lower case letters to upper case and convert special characters */ + if (letter >= 'a' && letter <= 'z') + letter_element = EL_CHAR_ASCII0 + letter + (int)('A' - 'a'); + else if (letter == 'ä' || letter == 'Ä') + letter_element = EL_CHAR_AE; + else if (letter == 'ö' || letter == 'Ö') + letter_element = EL_CHAR_OE; + else if (letter == 'ü' || letter == 'Ü') + letter_element = EL_CHAR_UE; + else if (letter == '^') + letter_element = EL_CHAR_COPY; + else + letter_element = EL_CHAR_ASCII0 + letter; + if (mode != TEXT_INIT) { if (!typing) @@ -3339,16 +3379,6 @@ void HandleLevelEditorKeyInput(KeySym key) { char letter = getCharFromKeySym(key); - /* map lower case letters to upper case */ - if (letter >= 'a' && letter <= 'z') - letter += (int)('A' - 'a'); - else if (letter == 'ä') - letter = 'Ä'; - else if (letter == 'ä') - letter = 'Ö'; - else if (letter == 'ä') - letter = 'Ü'; - if (letter) DrawLevelText(0, 0, letter, TEXT_WRITECHAR); else if (key == XK_Delete || key == XK_BackSpace) diff --git a/src/events.c b/src/events.c index d29cfcfc..b9e4e9a2 100644 --- a/src/events.c +++ b/src/events.c @@ -234,8 +234,24 @@ void HandleMotionEvent(XMotionEvent *event) void HandleKeyEvent(XKeyEvent *event) { int key_status = (event->type == KeyPress ? KEY_PRESSED : KEY_RELEASED); - unsigned int event_state = (game_status != PLAYING ? event->state : 0); - KeySym key = XLookupKeysym(event, event_state); + KeySym key; + + if (game_status == PLAYING) + { + /* use '0' instead of 'event->state' to get the key without modifiers */ + key = XLookupKeysym(event, 0); + } + else + { + /* get the key with all modifiers */ + char buffer[10]; + int buffer_size = 10; + XComposeStatus compose; + int char_count; + + char_count = XLookupString(event, buffer, buffer_size, &key, &compose); + buffer[char_count] = '\0'; + } HandleKey(key, key_status); } diff --git a/src/misc.c b/src/misc.c index 63ca326e..e917e13b 100644 --- a/src/misc.c +++ b/src/misc.c @@ -853,6 +853,8 @@ char getCharFromKeySym(KeySym keysym) letter = '='; else if (strcmp(keyname, "greater") == 0) letter = '>'; + else if (strcmp(keyname, "circumflex") == 0) + letter = '^'; return letter; } diff --git a/src/msdos.c b/src/msdos.c index 7c60e751..b64b9fab 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -768,6 +768,50 @@ KeySym XLookupKeysym(XKeyEvent *key_event, int index) return key_event->state; } +int XLookupString(XKeyEvent *key_event, char *buffer, int buffer_size, + KeySym *key, XComposeStatus *compose) +{ + *key = key_event->state; + return 0; +} + +void XSetForeground(Display *display, GC gc, unsigned long pixel) +{ + XGCValues *gcv = (XGCValues *)gc; + + gcv->foreground = pixel; +} + +void XDrawLine(Display *display, Drawable d, GC gc, + int x1, int y1, int x2, int y2) +{ + XGCValues *gcv = (XGCValues *)gc; + boolean mouse_off = FALSE; + + if ((BITMAP *)d == video_bitmap) + { + x1 += display->screens[display->default_screen].x; + y1 += display->screens[display->default_screen].y; + x2 += display->screens[display->default_screen].x; + y2 += display->screens[display->default_screen].y; + freeze_mouse_flag = TRUE; + mouse_off = hide_mouse(display, MIN(x1, x2), MIN(y1, y2), + MAX(x1, x2) - MIN(x1, x2), + MAX(y1, y2) - MIN(y1, y2)); + } + + line((BITMAP *)d, x1, y1, x2, y2, gcv->foreground); + + if (mouse_off) + unhide_mouse(display); + + freeze_mouse_flag = FALSE; +} + +void XDestroyImage(XImage *ximage) +{ +} + void NetworkServer(int port, int serveronly) { Error(ERR_WARN, "networking not supported in DOS version"); diff --git a/src/msdos.h b/src/msdos.h index c344414e..32d6a4c2 100644 --- a/src/msdos.h +++ b/src/msdos.h @@ -550,6 +550,7 @@ typedef long XVisualInfo; typedef long Atom; typedef int Status; typedef int Bool; +typedef int XComposeStatus; /* we don't need the real type */ typedef struct _XGC { @@ -706,4 +707,8 @@ void XCloseDisplay(Display *); void XNextEvent(Display *, XEvent *); int XPending(Display *); KeySym XLookupKeysym(XKeyEvent *, int); +int XLookupString(XKeyEvent *, char *, int, KeySym *, XComposeStatus *); +void XSetForeground(Display *, GC, unsigned long); +void XDrawLine(Display *, Drawable, GC, int, int, int, int); +void XDestroyImage(XImage *); void NetworkServer(int, int); diff --git a/src/sound.c b/src/sound.c index d39a9861..c9e13525 100644 --- a/src/sound.c +++ b/src/sound.c @@ -39,9 +39,11 @@ static unsigned char playing_buffer[SND_BLOCKSIZE]; static void SoundServer_InsertNewSound(struct SoundControl); #endif #ifndef VOXWARE +#ifndef MSDOS static unsigned char linear_to_ulaw(int); static int ulaw_to_linear(unsigned char); #endif +#endif #ifdef HPUX_AUDIO static void HPUX_Audio_Control(); #endif @@ -567,6 +569,7 @@ static void HPUX_Audio_Control() #endif /* HPUX_AUDIO */ #ifndef VOXWARE +#ifndef MSDOS /* these two are stolen from "sox"... :) */ /* @@ -670,6 +673,7 @@ static int ulaw_to_linear(unsigned char ulawbyte) return(sample); } +#endif /* !MSDOS */ #endif /* !VOXWARE */ /*** THE STUFF ABOVE IS ONLY USED BY THE SOUND SERVER CHILD PROCESS ***/