[Freeciv-Dev] (PR#39667) SDL Client Usability Issues

2007-10-21 Thread Christian Prochaska

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39667 

 [dmarks - Mi 05. Sep 2007, 09:03:16]:
 
  [EMAIL PROTECTED] - Tue Sep 04 13:09:46 2007]:
  
  SDL interface has some very annoying usability issues to address.
  
  (...)
  
  Auto-scrolling is annoying. It is especially annoying when playing in
  windowed mode when you are often moving the mouse cursor in and out of
  the game window. It would be better to scroll when pressing the
  right-mouse-button since the RMB is already used for manual movement.
  
  
 
 Could an option be made to turn this off in the Game Options dialog?
 

The attached patch disables auto-scrolling in windowed mode and reduces
the sensible area in fullscreen mode to make accidental scrolling less
likely. If that's still too problematic, an option can be added in a
later release (would add a new translatable string). Pressing the right
mouse button for a longer time already counts as middle-click in the
current design (for two-button mice).

Index: client/gui-sdl/gui_main.c
===
--- client/gui-sdl/gui_main.c	(revision 13803)
+++ client/gui-sdl/gui_main.c	(working copy)
@@ -359,14 +359,16 @@
   button_behavior.counting = FALSE;
   button_behavior.button_down_ticks = 0;  
   
-#ifdef UNDER_CE
   is_map_scrolling = FALSE;
-#endif
   
   return ID_ERROR;
 }
 
-#define SCROLL_MAP_AREA		8
+#ifdef UNDER_CE
+  #define SCROLL_MAP_AREA   8
+#else
+  #define SCROLL_MAP_AREA   1 
+#endif
 
 /**
 ...
@@ -389,7 +391,13 @@
   if(draw_goto_patrol_lines) {
 update_line(pMotionEvent-x, pMotionEvent-y);
   }
-  
+
+#ifndef UNDER_CE
+  if (gui_sdl_fullscreen) {
+check_scroll_area(pMotionEvent-x, pMotionEvent-y);
+  }
+#endif  
+
   if ((pWidget = MainWidgetListScaner(pMotionEvent-x, pMotionEvent-y)) != NULL) {
 update_mouse_cursor(CURSOR_DEFAULT);
 widget_sellected_action(pWidget);
@@ -402,10 +410,6 @@
 
 handle_mouse_cursor(ptile);
 hover_tile = ptile;
-
-#ifndef UNDER_CE
-check_scroll_area(pMotionEvent-x, pMotionEvent-y);
-#endif  
   }
 }
   }
@@ -446,45 +450,38 @@
 }
 
 static int check_scroll_area(int x, int y) {
-  static SDL_Rect rect;
-  
-  rect.x = rect.y = 0;
-  rect.w = SCROLL_MAP_AREA;
-  rect.h = Main.map-h;
-
-  if (is_in_rect_area(x, y, rect)) {
+  
+  SDL_Rect rect_north = {0, 0, Main.map-w, SCROLL_MAP_AREA};
+  SDL_Rect rect_east = {Main.map-w - SCROLL_MAP_AREA, 0, SCROLL_MAP_AREA, Main.map-h};
+  SDL_Rect rect_south = {0, Main.map-h - SCROLL_MAP_AREA, Main.map-w, SCROLL_MAP_AREA};
+  SDL_Rect rect_west = {0, 0, SCROLL_MAP_AREA, Main.map-h};
+  
+  if (is_in_rect_area(x, y, rect_north)) {
 is_map_scrolling = TRUE;
-if (scroll_dir != DIR8_WEST) {
-  scroll_dir = DIR8_WEST;
+if (is_in_rect_area(x, y, rect_west)) {
+  scroll_dir = DIR8_NORTHWEST;
+} else if (is_in_rect_area(x, y, rect_east)) {
+  scroll_dir = DIR8_NORTHEAST;
+} else {
+  scroll_dir = DIR8_NORTH;
 }
-  } else {
-rect.x = Main.map-w - SCROLL_MAP_AREA;
-if (is_in_rect_area(x, y, rect)) {
-  is_map_scrolling = TRUE;
-  if (scroll_dir != DIR8_EAST) {
-scroll_dir = DIR8_EAST;
-  }
+  } else if (is_in_rect_area(x, y, rect_south)) {
+is_map_scrolling = TRUE;
+if (is_in_rect_area(x, y, rect_west)) {
+  scroll_dir = DIR8_SOUTHWEST;
+} else if (is_in_rect_area(x, y, rect_east)) {
+  scroll_dir = DIR8_SOUTHEAST;
 } else {
-  rect.x = rect.y = 0;
-  rect.w = Main.map-w;
-  rect.h = SCROLL_MAP_AREA;
-  if (is_in_rect_area(x, y, rect)) {
-is_map_scrolling = TRUE;
-if (scroll_dir != DIR8_NORTH) {
-  scroll_dir = DIR8_NORTH;
-}
-  } else {
-rect.y = Main.map-h - SCROLL_MAP_AREA;
-if (is_in_rect_area(x, y, rect)) {
-  is_map_scrolling = TRUE;
-   	  if (scroll_dir != DIR8_SOUTH) {
-scroll_dir = DIR8_SOUTH;
-  	  }
-} else {
-	  is_map_scrolling = FALSE;
-	}
-  } 
+  scroll_dir = DIR8_SOUTH;
 }
+  } else if (is_in_rect_area(x, y, rect_east)) {
+is_map_scrolling = TRUE;
+scroll_dir = DIR8_EAST;
+  } else if (is_in_rect_area(x, y, rect_west)) {
+is_map_scrolling = TRUE;
+scroll_dir = DIR8_WEST;
+  } else {
+is_map_scrolling = FALSE;
   }
   
   return is_map_scrolling;
@@ -539,13 +536,13 @@
   Uint16 ID;
   static struct timeval tv;
   static fd_set civfdset;
-  Uint32 t1, t2, t3;
+  Uint32 t_current, t_last_unit_anim, t_last_map_scrolling;
   Uint32 real_timer_next_call;
   static int result, schot_nr = 0;
   static char schot[32];
 
   ID = ID_ERROR;
-  t3 = t1 = real_timer_next_call = SDL_GetTicks();
+  t_last_map_scrolling = t_last_unit_anim = real_timer_next_call = SDL_GetTicks();
   while (ID == ID_ERROR) {
 /* = */
 /* net check with 10ms delay 

[Freeciv-Dev] (PR#39667) SDL Client Usability Issues

2007-10-18 Thread Christian Prochaska

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39667 

 [cproc - Do 18. Okt 2007, 13:08:16]:
 
  [dmarks - Do 18. Okt 2007, 01:05:45]:
  
  This is good news!
  
  Found some issues testing it:
  
  -The client crashes when there are no savegames in any datapath.
 
 fixed in the attached patch.
 
  -I doesn't seem to be able to load saves from .freeciv/saves/ (which
  is the standard save dir on this system) - they show up in the dialog
  fine, but you try to load them the server says that it cannot find the
  file. If I move the file to my home dir, it works fine.
 
 okay, found out that the full path needs to be given to the /load
 command for savegames in this directory. But now with the full path
 sent, all load requests are disallowed for security reasons. For some
 reason the SDL client seems to be recognized only as restricted
 caller. Will investigate further.
 

Now it should work.

Index: client/gui-sdl/chatline.c
===
--- client/gui-sdl/chatline.c	(revision 13780)
+++ client/gui-sdl/chatline.c	(working copy)
@@ -27,6 +27,7 @@
 
 /* utility */
 #include fcintl.h
+#include log.h
 
 /* common */
 #include game.h
@@ -35,6 +36,7 @@
 /* client */
 #include civclient.h
 #include clinet.h
+#include connectdlg_common.h
 
 /* gui-sdl */
 #include colors.h
@@ -46,6 +48,7 @@
 #include gui_tilespec.h
 #include mapview.h
 #include messagewin.h
+#include pages.h
 #include themespec.h
 #include unistring.h
 #include widget.h
@@ -59,8 +62,11 @@
   struct ADVANCED_DLG *pChat_Dlg;
   struct widget *pBeginWidgetList;
   struct widget *pEndWidgetList;
-  struct widget *pStart;
+  struct widget *pStartButton;
+  struct widget *pSelectNationButton;
+  struct widget *pLoadGameButton;
   struct widget *pConfigure;
+  struct widget *pBackButton;
   struct widget *pEdit;
   int text_width;
   int active;
@@ -70,6 +76,285 @@
 static void add_to_chat_list(Uint16 *pUniStr, size_t n_alloc);
 
 /**
+  LOAD GAME
+**/
+
+struct ADVANCED_DLG *pLoadDialog;
+
+static int move_load_game_dlg_callback(struct widget *pWindow)
+{
+  if (Main.event.button.button == SDL_BUTTON_LEFT) {
+move_window_group(pLoadDialog-pBeginWidgetList, pWindow);
+  }
+  return -1;
+}
+
+void popdown_load_game_dialog(void)
+{
+  if (pLoadDialog) {
+popdown_window_group_dialog(pLoadDialog-pBeginWidgetList, pLoadDialog-pEndWidgetList);
+FC_FREE(pLoadDialog-pScroll);
+FC_FREE(pLoadDialog);
+
+/* enable buttons */  
+set_wstate(pConnDlg-pBackButton, FC_WS_NORMAL);
+widget_redraw(pConnDlg-pBackButton);
+widget_mark_dirty(pConnDlg-pBackButton);
+set_wstate(pConnDlg-pLoadGameButton, FC_WS_NORMAL);
+widget_redraw(pConnDlg-pLoadGameButton);
+widget_mark_dirty(pConnDlg-pLoadGameButton);
+set_wstate(pConnDlg-pStartButton, FC_WS_NORMAL);
+widget_redraw(pConnDlg-pStartButton);
+widget_mark_dirty(pConnDlg-pStartButton);
+
+flush_dirty();
+  }
+}
+
+static int exit_load_dlg_callback(struct widget *pWidget)
+{
+  if (Main.event.button.button == SDL_BUTTON_LEFT) {
+popdown_load_game_dialog();
+  }
+  return -1;
+}
+
+static int load_selected_game_callback(struct widget *pWidget)
+{
+  if (Main.event.button.button == SDL_BUTTON_LEFT) {
+char *filename = (char*)pWidget-data.ptr;
+
+if (is_server_running()) {
+  char message[MAX_LEN_MSG];
+
+  my_snprintf(message, sizeof(message), /load %s, filename);
+  send_chat(message);
+  
+  if (get_client_page() == PAGE_LOAD) {
+set_client_page(PAGE_START);
+  } else if (get_client_page() == PAGE_START) {
+popdown_load_game_dialog();
+  }
+} else {
+  set_client_page(PAGE_MAIN);
+}
+  }
+  return -1;
+}
+
+static void popup_load_game_dialog(void)
+{
+  struct widget *pWindow;
+  struct widget *pCloseButton;
+  struct widget *pFilenameLabel = NULL;
+  struct widget *pFirstLabel = NULL;
+  struct widget *pLastLabel = NULL;
+  struct widget *pNextLabel = NULL; 
+  SDL_String16 *pTitle, *pFilename;
+  SDL_Rect area;
+  struct datafile_list *files;
+  int count = 0;
+  int scrollbar_width = 0;
+  int max_label_width = 0;
+  
+  if (pLoadDialog) {
+return;
+  }
+
+  /* disable buttons */  
+  set_wstate(pConnDlg-pBackButton, FC_WS_DISABLED);
+  widget_redraw(pConnDlg-pBackButton);
+  widget_mark_dirty(pConnDlg-pBackButton);
+  set_wstate(pConnDlg-pLoadGameButton, FC_WS_DISABLED);
+  widget_redraw(pConnDlg-pLoadGameButton);
+  widget_mark_dirty(pConnDlg-pLoadGameButton);
+  set_wstate(pConnDlg-pSelectNationButton, FC_WS_DISABLED);
+  widget_redraw(pConnDlg-pSelectNationButton);
+  widget_mark_dirty(pConnDlg-pSelectNationButton);
+  set_wstate(pConnDlg-pStartButton, FC_WS_DISABLED);
+  widget_redraw(pConnDlg-pStartButton);
+  widget_mark_dirty(pConnDlg-pStartButton);
+  
+  

[Freeciv-Dev] (PR#39667) SDL Client Usability Issues

2007-10-17 Thread Christian Prochaska

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39667 

 [EMAIL PROTECTED] - Di 04. Sep 2007, 13:09:46]:
 
 There is no UI to save/load games in the SDL client. A work around is
 to open a chat dialog and use the /save and /load commands.
 

The attached patch implements a simple Load Game dialog.
Index: client/gui-sdl/chatline.c
===
--- client/gui-sdl/chatline.c	(revision 13783)
+++ client/gui-sdl/chatline.c	(working copy)
@@ -27,6 +27,7 @@
 
 /* utility */
 #include fcintl.h
+#include log.h
 
 /* common */
 #include game.h
@@ -46,6 +47,7 @@
 #include gui_tilespec.h
 #include mapview.h
 #include messagewin.h
+#include pages.h
 #include themespec.h
 #include unistring.h
 #include widget.h
@@ -545,7 +547,9 @@
   pBuf-size.y = pStartGameButton-size.y;
 
   pBuf-action = select_nation_callback;
-  set_wstate(pBuf, FC_WS_NORMAL);
+  if (get_client_page() != PAGE_LOAD) {
+set_wstate(pBuf, FC_WS_NORMAL);
+  }
   add_to_gui_list(ID_BUTTON, pBuf);
   pSelectNationButton = pBuf;
   
Index: client/gui-sdl/pages.c
===
--- client/gui-sdl/pages.c	(revision 13783)
+++ client/gui-sdl/pages.c	(working copy)
@@ -44,6 +44,241 @@
 static enum client_pages old_page = PAGE_MAIN;
 
 /**
+  LOAD PAGE
+**/
+
+struct ADVANCED_DLG *pLoadDialog;
+
+static int move_load_dialog_callback(struct widget *pWindow)
+{
+  if (Main.event.button.button == SDL_BUTTON_LEFT) {
+move_window_group(pLoadDialog-pBeginWidgetList, pWindow);
+  }
+  return -1;
+}
+
+static void close_load_page(void)
+{
+popdown_window_group_dialog(pLoadDialog-pBeginWidgetList, pLoadDialog-pEndWidgetList);
+flush_dirty();
+}
+
+static int exit_load_dlg_callback(struct widget *pWidget)
+{
+  if (Main.event.button.button == SDL_BUTTON_LEFT) {
+set_client_page(PAGE_MAIN);
+  }
+  return -1;
+}
+
+static int load_selected_game_callback(struct widget *pWidget)
+{
+  if (Main.event.button.button == SDL_BUTTON_LEFT) {
+char *filename = (char*)pWidget-data.ptr;
+
+if (is_server_running() || client_start_server()) {
+  char message[MAX_LEN_MSG];
+
+  my_snprintf(message, sizeof(message), /load %s, filename);
+  send_chat(message);
+} else {
+  set_client_page(PAGE_MAIN);
+}
+  }
+  return -1;
+}
+
+static void show_load_page(void)
+{
+  struct widget *pWindow;
+  struct widget *pCloseButton;
+  struct widget *pFilenameLabel = NULL;
+  struct widget *pFirstLabel = NULL;
+  struct widget *pLastLabel = NULL;
+  struct widget *pNextLabel = NULL; 
+  SDL_String16 *pTitle, *pFilename;
+  SDL_Rect area;
+  struct datafile_list *files;
+  int count = 0;
+  int scrollbar_width = 0;
+  int max_label_width = 0;
+  
+  pLoadDialog = fc_calloc(1, sizeof(struct ADVANCED_DLG));
+
+  pTitle = create_str16_from_char(_(Choose Saved Game to Load), adj_font(12));
+  pTitle-style |= TTF_STYLE_BOLD;
+  
+  pWindow = create_window_skeleton(NULL, pTitle, 0);
+  pWindow-action = move_load_dialog_callback; 
+  set_wstate(pWindow, FC_WS_NORMAL);
+  
+  add_to_gui_list(ID_WINDOW, pWindow);
+
+  pLoadDialog-pEndWidgetList = pWindow;
+
+  area = pWindow-area;
+  
+  /* close button */
+  pCloseButton = create_themeicon(pTheme-Small_CANCEL_Icon, pWindow-dst,
+  WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
+  pCloseButton-string16 = create_str16_from_char(_(Close Dialog (Esc)), adj_font(12));
+  pCloseButton-action = exit_load_dlg_callback;
+  set_wstate(pCloseButton, FC_WS_NORMAL);
+  pCloseButton-key = SDLK_ESCAPE;
+  
+  add_to_gui_list(ID_BUTTON, pCloseButton);
+
+  area.w += pCloseButton-size.w;
+
+  pLoadDialog-pBeginWidgetList = pCloseButton;
+
+  /* create scrollbar */
+  scrollbar_width = create_vertical_scrollbar(pLoadDialog, 1, 20, TRUE, TRUE);
+  hide_scrollbar(pLoadDialog-pScroll);
+
+  /* search for user saved games. */
+  files = datafilelist_infix(saves, .sav, FALSE);
+  datafile_list_iterate(files, pfile) {
+
+count++;
+
+pFilename = create_str16_from_char(pfile-name, adj_font(13));
+pFilename-style |= SF_CENTER;
+pFilenameLabel = create_iconlabel(NULL, pWindow-dst, pFilename,
+  (WF_FREE_DATA | WF_SELLECT_WITHOUT_BAR | WF_RESTORE_BACKGROUND));
+ 
+/* store filename */
+pFilenameLabel-data.ptr = fc_calloc(1, strlen(pfile-name) + 1);
+mystrlcpy((char*)pFilenameLabel-data.ptr, pfile-name, strlen(pfile-name) + 1);
+
+pFilenameLabel-action = load_selected_game_callback;
+ 
+set_wstate(pFilenameLabel, FC_WS_NORMAL);
+
+/* FIXME: this was supposed to be add_widget_to_vertical_scroll_widget_list(), but
+ * add_widget_to_vertical_scroll_widget_list() needs the scrollbar area to be defined
+ * for updating the scrollbar position, but 

Re: [Freeciv-Dev] (PR#39667) SDL Client Usability Issues

2007-10-17 Thread Daniel Markstedt

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39667 

On 10/18/07, Christian Prochaska [EMAIL PROTECTED] wrote:

 URL: http://bugs.freeciv.org/Ticket/Display.html?id=39667 

  [EMAIL PROTECTED] - Di 04. Sep 2007, 13:09:46]:
 
  There is no UI to save/load games in the SDL client. A work around is
  to open a chat dialog and use the /save and /load commands.
 

 The attached patch implements a simple Load Game dialog.


This is good news!

Found some issues testing it:

-The client crashes when there are no savegames in any datapath.
-I doesn't seem to be able to load saves from .freeciv/saves/ (which
is the standard save dir on this system) - they show up in the dialog
fine, but you try to load them the server says that it cannot find the
file. If I move the file to my home dir, it works fine.

Daniel



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#39667) SDL Client Usability Issues

2007-09-05 Thread Daniel Markstedt

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39667 

 [EMAIL PROTECTED] - Tue Sep 04 13:09:46 2007]:
 
 SDL interface has some very annoying usability issues to address.
 
 (...)
 
 Auto-scrolling is annoying. It is especially annoying when playing in
 windowed mode when you are often moving the mouse cursor in and out of
 the game window. It would be better to scroll when pressing the
 right-mouse-button since the RMB is already used for manual movement.
 
 

Could an option be made to turn this off in the Game Options dialog?

 
 I could see no obvious way to end the turn with the mouse - annoying
 for a mouse-driven game. After being told there is, I looked a bit
 harder. It's an icon on the minimap panel, alongside various
 information icons. Hardly obvious - in a heavily iconified UI like
 Freeciv SDL is aspiring to be, placing is important. They need to
 think a bit harder about this one. I would have placed it somewhere at
 the top near where the year is displayed since the turn and the game
 year are strongly associated and importantly you won't be clicking on
 it by accident if it is up there (something easy to do currently as a
 small icon placed amongst a bunch of other small icons).
 
 Source:
 http://freegamer.blogspot.com/2007/08/freeciv-21beta6-grips.html
 
 
 

Maybe the larger part of the right sidebar (where the text 'End of Turn'
appear at the end of a turn) could be turned into one large end turn
button when all units have finished moving?

The place currently held by the end turn button (the little cogwheel)
could for example be given to a (yet-to-be implemented) civilopedia button.

Anyways, the two patches so far are huge improvements. Keep up the good
work. =)

 ~Daniel

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#39667) SDL Client Usability Issues

2007-09-04 Thread Christian Prochaska

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39667 

 [EMAIL PROTECTED] - Di 04. Sep 2007, 13:09:46]:
 
 If you run it in windowed mode, you can't resize the game by resizing
 the window. The game display logic should be independent of the
 resolution, an absraction that many games fail to make.
 

I believe the SDL client was targeted at fullscreen mode in the first
place (inspired by Civ3) with windowed mode only as an optional feature.
Changing the code to support on-the-fly resizing seems almost impossible
to me now. If I had the time I would port the SDL GUI to GTK+ and make
use of its automatic layout management, but for now I can only mark the
window as unresizable to at least avoid the black areas when attemting
to resize the window frame. Patch attached.
Index: client/gui-sdl/gui_main.c
===
--- client/gui-sdl/gui_main.c	(revision 13502)
+++ client/gui-sdl/gui_main.c	(working copy)
@@ -800,7 +800,7 @@
 #endif
   
   if(pBgd  SDL_GetVideoInfo()-wm_available) {
-set_video_mode(pBgd-w, pBgd-h, SDL_SWSURFACE | SDL_ANYFORMAT | SDL_RESIZABLE);
+set_video_mode(pBgd-w, pBgd-h, SDL_SWSURFACE | SDL_ANYFORMAT);
 #if 0
 /*
  * call this for other that X enviroments - currently not supported.
@@ -954,7 +954,7 @@
   #else
 /* small screen on desktop - don't set 320x240 fullscreen mode */
 set_video_mode(gui_sdl_screen_width, gui_sdl_screen_height,
-   SDL_SWSURFACE | SDL_ANYFORMAT | SDL_RESIZABLE);
+   SDL_SWSURFACE | SDL_ANYFORMAT);
   #endif
 #else
   set_video_mode(gui_sdl_screen_width, gui_sdl_screen_height,
@@ -969,11 +969,11 @@
  SDL_SWSURFACE | SDL_ANYFORMAT);
   #else
   set_video_mode(gui_sdl_screen_width, gui_sdl_screen_height,
- SDL_SWSURFACE | SDL_ANYFORMAT | SDL_RESIZABLE);
+ SDL_SWSURFACE | SDL_ANYFORMAT);
   #endif
 #else
 set_video_mode(gui_sdl_screen_width, gui_sdl_screen_height,
-  SDL_SWSURFACE | SDL_ANYFORMAT | SDL_RESIZABLE);
+  SDL_SWSURFACE | SDL_ANYFORMAT);
 #endif
 
 #if 0
Index: client/gui-sdl/optiondlg.c
===
--- client/gui-sdl/optiondlg.c	(revision 13502)
+++ client/gui-sdl/optiondlg.c	(working copy)
@@ -427,7 +427,6 @@
   
 if (gui_sdl_fullscreen != BOOL_VAL(Main.screen-flags  SDL_FULLSCREEN)) {
   tmp_flags ^= SDL_FULLSCREEN;
-  tmp_flags ^= SDL_RESIZABLE;
 }
   
 mode = MAX_ID - pWidget-ID;
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev