<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 the area is not known yet (depends on
+     * maximum label width) */ 
+    add_to_gui_list(ID_LABEL, pFilenameLabel);
+
+    if (count == 1) {
+      pFirstLabel = pFilenameLabel;
+    }
+
+    max_label_width = MAX(max_label_width, pFilenameLabel->size.w);
+        
+    free(pfile->name);
+    free(pfile->fullname);
+    free(pfile);
+  } datafile_list_iterate_end;
+
+  datafile_list_unlink_all(files);
+  datafile_list_free(files);
+
+  files = datafilelist_infix(NULL, ".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 the area is not known yet (depends on
+     * maximum label width) */ 
+    add_to_gui_list(ID_LABEL, pFilenameLabel);
+
+    if (count == 1) {
+      pFirstLabel = pFilenameLabel;
+    }
+
+    max_label_width = MAX(max_label_width, pFilenameLabel->size.w);
+        
+    free(pfile->name);
+    free(pfile->fullname);
+    free(pfile);
+  } datafile_list_iterate_end;
+
+  datafile_list_unlink_all(files);
+  datafile_list_free(files);
+
+  pLastLabel = pFilenameLabel;
+
+  area.w = MAX(area.w, max_label_width + scrollbar_width + 1);
+  area.h = (pLoadDialog->pScroll->active * pFilenameLabel->size.h) + adj_size(5);
+
+  resize_window(pWindow, theme_get_background(theme, BACKGROUND_LOADGAMEDLG),
+                NULL,
+                (pWindow->size.w - pWindow->area.w) + area.w,
+                (pWindow->size.h - pWindow->area.h) + area.h);
+      
+  area = pWindow->area;
+      
+  setup_vertical_scrollbar_area(pLoadDialog->pScroll,
+    area.x + area.w - 1,
+    area.y + 1,
+    area.h - adj_size(2), TRUE);
+
+  /* add filename labels to list */
+  pFilenameLabel = pFirstLabel;
+  while (pFilenameLabel) {
+    pFilenameLabel->size.w = area.w - scrollbar_width - 3;
+
+    pNextLabel = pFilenameLabel->prev;
+
+    del_widget_pointer_from_gui_list(pFilenameLabel);
+    if (pFilenameLabel == pFirstLabel) {
+      add_widget_to_vertical_scroll_widget_list(pLoadDialog,
+          pFilenameLabel, pCloseButton,
+          FALSE,
+          area.x + 1,
+          area.y + adj_size(2));
+    } else {
+      add_widget_to_vertical_scroll_widget_list(pLoadDialog,
+          pFilenameLabel,
+          pLoadDialog->pBeginActiveWidgetList,
+          FALSE,
+          area.x + 1,
+          area.y + adj_size(2));
+    }
+    
+    if (pFilenameLabel == pLastLabel) {
+      break;
+    }
+         
+    pFilenameLabel = pNextLabel;
+  }
+
+  widget_set_position(pWindow,
+                      (Main.screen->w - pWindow->size.w) / 2,
+                      (Main.screen->h - pWindow->size.h) / 2);
+
+  widget_set_position(pCloseButton,
+                      area.x + area.w - pCloseButton->size.w - 1,
+                      pWindow->size.y + adj_size(2));
+
+  /* FIXME: the scrollbar already got a background saved in
+   * add_widget_to_vertical_scroll_widget_list(), but the window
+   * is not drawn yet, so this saved background is wrong.
+   * Deleting it here as a workaround. */
+  FREESURFACE(pLoadDialog->pScroll->pScrollBar->gfx);
+
+  redraw_group(pLoadDialog->pBeginWidgetList, pWindow, 0);
+  widget_flush(pWindow);
+}
+
+/**************************************************************************
                                   MAIN PAGE
 **************************************************************************/
 static struct SMALL_DLG *pStartMenu = NULL;
@@ -72,6 +307,17 @@
 /**************************************************************************
   ...
 **************************************************************************/
+static int load_game_callback(struct widget *pWidget)
+{
+  if (Main.event.button.button == SDL_BUTTON_LEFT) {
+    set_client_page(PAGE_LOAD);
+  }
+  return -1;
+}
+
+/**************************************************************************
+  ...
+**************************************************************************/
 static int join_game_callback(struct widget *pWidget)
 {
   if (Main.event.button.button == SDL_BUTTON_LEFT) {
@@ -173,9 +419,9 @@
   pWidget = create_iconlabel_from_chars(NULL, pWindow->dst, _("Load Game"),
             adj_font(14),
 	    (WF_SELLECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND));
-  /*pWidget->action = popup_load_game_callback;*/
+  pWidget->action = load_game_callback;
   pWidget->string16->style |= SF_CENTER;
-  pWidget->string16->fgcol = *get_game_colorRGB(COLOR_THEME_WIDGET_DISABLED_TEXT);
+  set_wstate(pWidget, FC_WS_NORMAL);
   
   add_to_gui_list(ID_LOAD_GAME, pWidget);
   
@@ -312,6 +558,7 @@
     popdown_window_group_dialog(pStartMenu->pBeginWidgetList,
                                 pStartMenu->pEndWidgetList);
     FC_FREE(pStartMenu);
+    flush_dirty();
   }
 }
 
@@ -329,6 +576,9 @@
     case PAGE_MAIN:
       popdown_start_menu();
       break;
+    case PAGE_LOAD:
+      close_load_page();
+      break;
     case PAGE_NETWORK:
       close_connection_dialog();
       break;
@@ -341,11 +591,14 @@
     default: 
       break;
   }
-  
+
   switch (page) {
     case PAGE_MAIN:
       show_main_page();
       break;
+    case PAGE_LOAD:
+      show_load_page();
+      break;
     case PAGE_NETWORK:
       popup_join_game_dialog();
       break;
Index: client/gui-sdl/themebackgrounds.c
===================================================================
--- client/gui-sdl/themebackgrounds.c	(revision 13783)
+++ client/gui-sdl/themebackgrounds.c	(working copy)
@@ -41,6 +41,7 @@
   "economydlg",
   "hlpdlg",
   "joingamedlg",
+  "loadgamedlg",
   "mainpage",
   "messagewin",
   "nationdlg",
Index: client/gui-sdl/themebackgrounds.h
===================================================================
--- client/gui-sdl/themebackgrounds.h	(revision 13783)
+++ client/gui-sdl/themebackgrounds.h	(working copy)
@@ -29,6 +29,7 @@
   BACKGROUND_ECONOMYDLG,
   BACKGROUND_HELPDLG,
   BACKGROUND_JOINGAMEDLG,
+  BACKGROUND_LOADGAMEDLG,
   BACKGROUND_MAINPAGE,
   BACKGROUND_MESSAGEWIN,
   BACKGROUND_NATIONDLG,
Index: data/themes/gui-sdl/human/backgrounds.themespec
===================================================================
--- data/themes/gui-sdl/human/backgrounds.themespec	(revision 13783)
+++ data/themes/gui-sdl/human/backgrounds.themespec	(working copy)
@@ -23,6 +23,7 @@
 economydlg          = "themes/gui-sdl/human/bg"
 hlpdlg              = "themes/gui-sdl/human/bg"
 joingamedlg         = "themes/gui-sdl/human/bg"
+loadgamedlg         = "themes/gui-sdl/human/bg"
 mainpage            = "themes/gui-sdl/human/intro"
 messagewin	    = "themes/gui-sdl/human/bg2"
 nationdlg           = "themes/gui-sdl/human/bg"
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"
@@ -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 13780)
+++ 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 the area is not known yet (depends on
+     * maximum label width) */ 
+    add_to_gui_list(ID_LABEL, pFilenameLabel);
+
+    if (count == 1) {
+      pFirstLabel = pFilenameLabel;
+    }
+
+    max_label_width = MAX(max_label_width, pFilenameLabel->size.w);
+        
+    free(pfile->name);
+    free(pfile->fullname);
+    free(pfile);
+  } datafile_list_iterate_end;
+
+  datafile_list_unlink_all(files);
+  datafile_list_free(files);
+
+  files = datafilelist_infix(NULL, ".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 the area is not known yet (depends on
+     * maximum label width) */ 
+    add_to_gui_list(ID_LABEL, pFilenameLabel);
+
+    if (count == 1) {
+      pFirstLabel = pFilenameLabel;
+    }
+
+    max_label_width = MAX(max_label_width, pFilenameLabel->size.w);
+        
+    free(pfile->name);
+    free(pfile->fullname);
+    free(pfile);
+  } datafile_list_iterate_end;
+
+  datafile_list_unlink_all(files);
+  datafile_list_free(files);
+
+  pLastLabel = pFilenameLabel;
+
+  area.w = MAX(area.w, max_label_width + scrollbar_width + 1);
+  area.h = (pLoadDialog->pScroll->active * pFilenameLabel->size.h) + adj_size(5);
+
+  resize_window(pWindow, theme_get_background(theme, BACKGROUND_LOADGAMEDLG),
+                NULL,
+                (pWindow->size.w - pWindow->area.w) + area.w,
+                (pWindow->size.h - pWindow->area.h) + area.h);
+      
+  area = pWindow->area;
+      
+  setup_vertical_scrollbar_area(pLoadDialog->pScroll,
+    area.x + area.w - 1,
+    area.y + 1,
+    area.h - adj_size(2), TRUE);
+
+  /* add filename labels to list */
+  pFilenameLabel = pFirstLabel;
+  while (pFilenameLabel) {
+    pFilenameLabel->size.w = area.w - scrollbar_width - 3;
+
+    pNextLabel = pFilenameLabel->prev;
+
+    del_widget_pointer_from_gui_list(pFilenameLabel);
+    if (pFilenameLabel == pFirstLabel) {
+      add_widget_to_vertical_scroll_widget_list(pLoadDialog,
+          pFilenameLabel, pCloseButton,
+          FALSE,
+          area.x + 1,
+          area.y + adj_size(2));
+    } else {
+      add_widget_to_vertical_scroll_widget_list(pLoadDialog,
+          pFilenameLabel,
+          pLoadDialog->pBeginActiveWidgetList,
+          FALSE,
+          area.x + 1,
+          area.y + adj_size(2));
+    }
+    
+    if (pFilenameLabel == pLastLabel) {
+      break;
+    }
+         
+    pFilenameLabel = pNextLabel;
+  }
+
+  widget_set_position(pWindow,
+                      (Main.screen->w - pWindow->size.w) / 2,
+                      (Main.screen->h - pWindow->size.h) / 2);
+
+  widget_set_position(pCloseButton,
+                      area.x + area.w - pCloseButton->size.w - 1,
+                      pWindow->size.y + adj_size(2));
+
+  /* FIXME: the scrollbar already got a background saved in
+   * add_widget_to_vertical_scroll_widget_list(), but the window
+   * is not drawn yet, so this saved background is wrong.
+   * Deleting it here as a workaround. */
+  FREESURFACE(pLoadDialog->pScroll->pScrollBar->gfx);
+
+  redraw_group(pLoadDialog->pBeginWidgetList, pWindow, 0);
+  widget_flush(pWindow);
+}
+
+/**************************************************************************
                                   MAIN PAGE
 **************************************************************************/
 static struct SMALL_DLG *pStartMenu = NULL;
@@ -72,6 +307,17 @@
 /**************************************************************************
   ...
 **************************************************************************/
+static int load_game_callback(struct widget *pWidget)
+{
+  if (Main.event.button.button == SDL_BUTTON_LEFT) {
+    set_client_page(PAGE_LOAD);
+  }
+  return -1;
+}
+
+/**************************************************************************
+  ...
+**************************************************************************/
 static int join_game_callback(struct widget *pWidget)
 {
   if (Main.event.button.button == SDL_BUTTON_LEFT) {
@@ -173,9 +419,9 @@
   pWidget = create_iconlabel_from_chars(NULL, pWindow->dst, _("Load Game"),
             adj_font(14),
 	    (WF_SELLECT_WITHOUT_BAR|WF_RESTORE_BACKGROUND));
-  /*pWidget->action = popup_load_game_callback;*/
+  pWidget->action = load_game_callback;
   pWidget->string16->style |= SF_CENTER;
-  pWidget->string16->fgcol = *get_game_colorRGB(COLOR_THEME_WIDGET_DISABLED_TEXT);
+  set_wstate(pWidget, FC_WS_NORMAL);
   
   add_to_gui_list(ID_LOAD_GAME, pWidget);
   
@@ -312,6 +558,7 @@
     popdown_window_group_dialog(pStartMenu->pBeginWidgetList,
                                 pStartMenu->pEndWidgetList);
     FC_FREE(pStartMenu);
+    flush_dirty();
   }
 }
 
@@ -329,6 +576,9 @@
     case PAGE_MAIN:
       popdown_start_menu();
       break;
+    case PAGE_LOAD:
+      close_load_page();
+      break;
     case PAGE_NETWORK:
       close_connection_dialog();
       break;
@@ -341,11 +591,14 @@
     default: 
       break;
   }
-  
+
   switch (page) {
     case PAGE_MAIN:
       show_main_page();
       break;
+    case PAGE_LOAD:
+      show_load_page();
+      break;
     case PAGE_NETWORK:
       popup_join_game_dialog();
       break;
Index: client/gui-sdl/themebackgrounds.c
===================================================================
--- client/gui-sdl/themebackgrounds.c	(revision 13780)
+++ client/gui-sdl/themebackgrounds.c	(working copy)
@@ -41,6 +41,7 @@
   "economydlg",
   "hlpdlg",
   "joingamedlg",
+  "loadgamedlg",
   "mainpage",
   "messagewin",
   "nationdlg",
Index: client/gui-sdl/themebackgrounds.h
===================================================================
--- client/gui-sdl/themebackgrounds.h	(revision 13780)
+++ client/gui-sdl/themebackgrounds.h	(working copy)
@@ -29,6 +29,7 @@
   BACKGROUND_ECONOMYDLG,
   BACKGROUND_HELPDLG,
   BACKGROUND_JOINGAMEDLG,
+  BACKGROUND_LOADGAMEDLG,
   BACKGROUND_MAINPAGE,
   BACKGROUND_MESSAGEWIN,
   BACKGROUND_NATIONDLG,
Index: data/themes/gui-sdl/human/backgrounds.themespec
===================================================================
--- data/themes/gui-sdl/human/backgrounds.themespec	(revision 13780)
+++ data/themes/gui-sdl/human/backgrounds.themespec	(working copy)
@@ -22,6 +22,7 @@
 economydlg          = "themes/gui-sdl/human/bg"
 hlpdlg              = "themes/gui-sdl/human/bg"
 joingamedlg         = "themes/gui-sdl/human/bg"
+loadgamedlg         = "themes/gui-sdl/human/bg"
 mainpage            = "misc/intro"
 messagewin	    = "themes/gui-sdl/human/bg2"
 nationdlg           = "themes/gui-sdl/human/bg"
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to