From: Holger Schemel Date: Fri, 4 Aug 2006 17:28:32 +0000 (+0200) Subject: rnd-20060804-1-src X-Git-Tag: 3.2.1^2~24 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=24101bdeee0ac963cfd48b5220f6d9b0188a6f69;p=rocksndiamonds.git rnd-20060804-1-src * fixed bug with scrollbars inside editor when using the Windows mouse enhancement tool "True X-Mouse" (which injects key events to the event queue to insert selected stuff into the Windows clipboard, which gets confused with the "Insert" key for jumping to the last editor cascade block in the element list) --- diff --git a/ChangeLog b/ChangeLog index 2145075d..9602a817 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-08-04 + * fixed bug with scrollbars inside editor when using the Windows mouse + enhancement tool "True X-Mouse" (which injects key events to the event + queue to insert selected stuff into the Windows clipboard, which gets + confused with the "Insert" key for jumping to the last editor cascade + block in the element list) + 2006-08-01 * added selection of preferred fullscreen mode to setup / graphics menu (useful if default mode 800 x 600 does not match screen aspect ratio) @@ -11,9 +18,9 @@ setup menu (input devices section) by using standard button gadgets * added support for mouse scroll wheel (caused buggy behaviour before) * added support for scrolling horizontal scrollbars with mouse wheel by - holding "Ctrl" key pressed while scrolling the wheel + holding "Shift" key pressed while scrolling the wheel * added support for single step mouse wheel scrolling by holding "Alt" - key pressed while scrolling the wheel + key pressed while scrolling the wheel (can be combined with "Shift") * changed output file "stderr.txt" on Windows platform now always to be created in the R'n'D sub-directory of the personal documents directory * added Windows message box to direct to "stderr.txt" after error aborts diff --git a/src/conftime.h b/src/conftime.h index c05088a0..c3718d63 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2006-08-02 21:42]" +#define COMPILE_DATE_STRING "[2006-08-04 19:20]" diff --git a/src/editor.c b/src/editor.c index cee0cd43..561508dc 100644 --- a/src/editor.c +++ b/src/editor.c @@ -10467,8 +10467,12 @@ void HandleLevelEditorKeyInput(Key key) case KSYM_Insert: case KSYM_Delete: -#if 1 - /* IS_EDITOR_CASCADE */ + + /* this is needed to prevent interference with running "True X-Mouse" */ + if (GetKeyModStateFromEvents() & KMOD_Control) + break; + + /* check for last or next editor cascade block in element list */ for (i = 0; i < num_editor_elements; i++) { if ((key == KSYM_Insert && i == element_shift) || @@ -10492,36 +10496,6 @@ void HandleLevelEditorKeyInput(Key key) ModifyEditorElementList(); -#else - - for (i = 0; i < num_editor_elements; i++) - { - int e = editor_elements[i]; - - if ((key == KSYM_Insert && - (e == EL_INTERNAL_CASCADE_CE || - e == EL_INTERNAL_CASCADE_CE_ACTIVE)) || - (key == KSYM_Delete && - (e == EL_INTERNAL_CASCADE_GE || - e == EL_INTERNAL_CASCADE_GE_ACTIVE))) - break; - } - - if (i < num_editor_elements) - { - element_shift = i; - - if (element_shift > num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS) - element_shift = num_editor_elements - ED_NUM_ELEMENTLIST_BUTTONS; - - ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL], - GDI_SCROLLBAR_ITEM_POSITION, - element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END); - - ModifyEditorElementList(); - } -#endif - break; case KSYM_Escape: @@ -10542,6 +10516,7 @@ void HandleLevelEditorKeyInput(Key key) DrawDrawingWindow(); edit_mode = ED_MODE_DRAWING; } + break; default: diff --git a/src/events.c b/src/events.c index 10166129..6b501408 100644 --- a/src/events.c +++ b/src/events.c @@ -315,6 +315,11 @@ void HandleExposeEvent(ExposeEvent *event) void HandleButtonEvent(ButtonEvent *event) { +#if 0 + printf("::: BUTTON EVENT: button %d %s\n", event->button, + event->type == EVENT_BUTTONPRESS ? "pressed" : "released"); +#endif + motion_status = FALSE; if (event->type == EVENT_BUTTONPRESS) @@ -345,6 +350,11 @@ void HandleKeyEvent(KeyEvent *event) Key key = GetEventKey(event, with_modifiers); Key keymod = (with_modifiers ? GetEventKey(event, FALSE) : key); +#if 0 + printf("::: KEY EVENT: %d %s\n", GetEventKey(event, TRUE), + event->type == EVENT_KEYPRESS ? "pressed" : "released"); +#endif + HandleKeyModState(keymod, key_status); HandleKey(key, key_status); } diff --git a/src/game.c b/src/game.c index 2b4c7c0d..54ae41a2 100644 --- a/src/game.c +++ b/src/game.c @@ -10401,7 +10401,7 @@ static void CheckGravityMovement(struct PlayerInfo *player) { int move_dir_horizontal = player->effective_action & MV_HORIZONTAL; int move_dir_vertical = player->effective_action & MV_VERTICAL; - boolean player_is_snapping = player->effective_action & JOY_BUTTON_1; + boolean player_is_snapping = (player->effective_action & JOY_BUTTON_1); int jx = player->jx, jy = player->jy; boolean player_is_moving_to_valid_field = (!player_is_snapping && diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index afe5c3a7..b3166c4d 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -768,20 +768,14 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) break; case GDI_ACTIVE: - /* take care here: "boolean" is typedef'ed as "unsigned char", - which gets promoted to "int" */ gi->active = (boolean)va_arg(ap, int); break; case GDI_DIRECT_DRAW: - /* take care here: "boolean" is typedef'ed as "unsigned char", - which gets promoted to "int" */ gi->direct_draw = (boolean)va_arg(ap, int); break; case GDI_CHECKED: - /* take care here: "boolean" is typedef'ed as "unsigned char", - which gets promoted to "int" */ gi->checked = (boolean)va_arg(ap, int); break; @@ -1501,7 +1495,7 @@ boolean HandleGadgets(int mx, int my, int button) (gadget_pressed_inside_select_line && !mouse_inside_select_area))) { struct GadgetInfo *gi = last_gi; - boolean gadget_changed = (gi->event_mask & GD_EVENT_TEXT_LEAVING); + boolean gadget_changed = ((gi->event_mask & GD_EVENT_TEXT_LEAVING) != 0); /* check if text gadget has changed its value */ if (gi->type & GD_TYPE_TEXT_INPUT) @@ -1742,7 +1736,7 @@ boolean HandleGadgets(int mx, int my, int button) if (IS_WHEEL_BUTTON(button)) { - boolean scroll_single_step = (GetKeyModState() & KMOD_Alt); + boolean scroll_single_step = ((GetKeyModState() & KMOD_Alt) != 0); item_steps = (scroll_single_step ? 1 : DEFAULT_WHEEL_STEPS); item_direction = (button == MB_WHEEL_UP || @@ -2016,7 +2010,7 @@ boolean HandleGadgetsKeyInput(Key key) if (key == KSYM_Return) /* valid for both text input and selectbox */ { - boolean gadget_changed = (gi->event_mask & GD_EVENT_TEXT_RETURN); + boolean gadget_changed = ((gi->event_mask & GD_EVENT_TEXT_RETURN) != 0); if (gi->type & GD_TYPE_TEXT_INPUT) { diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 0d19ff9c..cd28493f 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1932,14 +1932,14 @@ void get_aspect_ratio_from_screen_mode(struct ScreenModeInfo *screen_mode, do { - *x = i * aspect_ratio; + *x = i * aspect_ratio + 0.000001; *y = i; aspect_ratio_new = (float)*x / (float)*y; i++; } - while (aspect_ratio_new != aspect_ratio && *x < screen_mode->width); + while (aspect_ratio_new != aspect_ratio && *y < screen_mode->height); } static void FreeCustomArtworkList(struct ArtworkListInfo *, diff --git a/src/libgame/system.c b/src/libgame/system.c index 632dd451..709a3511 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -1229,7 +1229,6 @@ KeyMod HandleKeyModState(Key key, int key_status) { static KeyMod current_modifiers = KMOD_None; -#if !defined(TARGET_SDL) if (key != KSYM_UNDEFINED) /* new key => check for modifier key change */ { KeyMod new_modifier = KMOD_None; @@ -1269,7 +1268,6 @@ KeyMod HandleKeyModState(Key key, int key_status) else current_modifiers &= ~new_modifier; } -#endif return current_modifiers; } @@ -1283,6 +1281,17 @@ KeyMod GetKeyModState() #endif } +KeyMod GetKeyModStateFromEvents() +{ + /* always use key modifier state as tracked from key events (this is needed + if the modifier key event was injected into the event queue, but the key + was not really pressed on keyboard -- SDL_GetModState() seems to directly + query the keys as held pressed on the keyboard) -- this case is currently + only used to filter out clipboard insert events from "True X-Mouse" tool */ + + return HandleKeyModState(KSYM_UNDEFINED, 0); +} + boolean CheckCloseWindowEvent(ClientMessageEvent *event) { if (event->type != EVENT_CLIENTMESSAGE) diff --git a/src/libgame/system.h b/src/libgame/system.h index 4fde8ea6..132e441e 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -1086,6 +1086,7 @@ void PeekEvent(Event *event); Key GetEventKey(KeyEvent *, boolean); KeyMod HandleKeyModState(Key, int); KeyMod GetKeyModState(); +KeyMod GetKeyModStateFromEvents(); boolean CheckCloseWindowEvent(ClientMessageEvent *); void InitJoysticks(); diff --git a/src/libgame/types.h b/src/libgame/types.h index 22790dc8..9970c9ea 100644 --- a/src/libgame/types.h +++ b/src/libgame/types.h @@ -20,7 +20,7 @@ #include #include -typedef unsigned char boolean; +typedef int boolean; #if !defined(PLATFORM_WIN32) typedef unsigned char byte; diff --git a/src/screens.c b/src/screens.c index dde11308..8a44a96c 100644 --- a/src/screens.c +++ b/src/screens.c @@ -2568,7 +2568,7 @@ static void execSetupGraphics() for (i = 0; video.fullscreen_modes[i].width != -1; i++) { TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED); - char identifier[20], name[20]; + char identifier[32], name[32]; int x = video.fullscreen_modes[i].width; int y = video.fullscreen_modes[i].height; int xx, yy; diff --git a/src/tools.c b/src/tools.c index f1fd599e..c1a8cf0b 100644 --- a/src/tools.c +++ b/src/tools.c @@ -44,7 +44,7 @@ static int el_act2crm(int, int); static struct GadgetInfo *tool_gadget[NUM_TOOL_BUTTONS]; static int request_gadget_id = -1; -static int preview_tilesize = 4; +static int preview_tilesize = TILEX / 8; static char *print_if_not_empty(int element) { @@ -1584,8 +1584,13 @@ static void DrawMicroLevelExt(int xpos, int ypos, int from_x, int from_y, if (lev_fieldy < preview_size_y) ypos += (preview_size_y - lev_fieldy) / 2 * preview_tilesize; +#if 1 + xpos += MICRO_TILEX; + ypos += MICRO_TILEY; +#else xpos += preview_tilesize; ypos += preview_tilesize; +#endif for (x = -1; x <= preview_size_x; x++) {