Re: [Freeciv-Dev] Civ1-like patch
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
> Hi !
>
> As I've told, I made a patch that will allow moving the map with
> Shift+<KeypadKey>. As this is my first patch, I'd like to hear
> your comments about it (what should I change, what should I take
> care of, etc.)
Your patch works fine with me.
I rewrite it using get_center_tile_mapcanvas and
center_tile_mapcanvas
The result is
/**************************************************************************
...
**************************************************************************/
void manual_scroll(int dx, int dy)
{
int tmp_map_view_x0;
int tmp_map_view_y0;
if(get_client_state()!=CLIENT_GAME_RUNNING_STATE) return;
get_center_tile_mapcanvas(&tmp_map_view_x0,
&tmp_map_view_y0);
center_tile_mapcanvas(tmp_map_view_x0+dx*5,
tmp_map_view_y0+dy*5);
}
I prefer the name of the function to become map_scroll.
Use dx instead of dx*5 and dy instead of dy*5 and you will have a general
function to scroll the map. You only have to call it with 5 or -5 instead
of -1 and 1.
Notes : As the new functions you introduce don't depend directly on Xaw
and as center_tile_mapcanvas and get_center_tile_mapcanvas are in
mapview_g.h, you can declare yours new functions in mapview_g.h instead
of mapview.h .They will have the same declaration for the gtk client.
I have a look in gdkkeysyms.h
Here are the two shifts
#define GDK_Shift_L 0xFFE1
#define GDK_Shift_R 0xFFE2
int gui_main.c
static gint keyboard_handler(GtkWidget *widget, GdkEventKey *event)
Good luck for the gtk part of the patch !
|
|