Author: cazfi
Date: Wed Mar 26 23:11:58 2014
New Revision: 24735

URL: http://svn.gna.org/viewcvs/freeciv?rev=24735&view=rev
Log:
Fixed sdl2-client theme surface loading

See patch #4631

Modified:
    trunk/client/gui-sdl2/graphics.c
    trunk/client/gui-sdl2/graphics.h
    trunk/client/gui-sdl2/gui_tilespec.c
    trunk/client/gui-sdl2/mapview.c
    trunk/client/gui-sdl2/widget.c
    trunk/client/gui-sdl2/widget_button.c

Modified: trunk/client/gui-sdl2/graphics.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/graphics.c?rev=24735&r1=24734&r2=24735&view=diff
==============================================================================
--- trunk/client/gui-sdl2/graphics.c    (original)
+++ trunk/client/gui-sdl2/graphics.c    Wed Mar 26 23:11:58 2014
@@ -447,6 +447,7 @@
   /* SDL_FillRect might change the rectangle, so we create a copy */
   if (dstrect) {
     SDL_Rect _dstrect = *dstrect;
+
     return SDL_FillRect(pSurf, &_dstrect, SDL_MapRGBA(pSurf->format, 0, 0, 0, 
0));
   } else {
     return SDL_FillRect(pSurf, NULL, SDL_MapRGBA(pSurf->format, 0, 0, 0, 0));

Modified: trunk/client/gui-sdl2/graphics.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/graphics.h?rev=24735&r1=24734&r2=24735&view=diff
==============================================================================
--- trunk/client/gui-sdl2/graphics.h    (original)
+++ trunk/client/gui-sdl2/graphics.h    Wed Mar 26 23:11:58 2014
@@ -292,9 +292,9 @@
 
 int SDL_FillRectAlpha(SDL_Surface *pSurface, SDL_Rect *pRect,
                      SDL_Color *pColor);
-                      
+
 int clear_surface(SDL_Surface *pSurf, SDL_Rect *dstrect);
-  
+
 /* ================================================================= */
 
 SDL_Surface *ResizeSurface(const SDL_Surface * pSrc, Uint16 new_width,

Modified: trunk/client/gui-sdl2/gui_tilespec.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/gui_tilespec.c?rev=24735&r1=24734&r2=24735&view=diff
==============================================================================
--- trunk/client/gui-sdl2/gui_tilespec.c        (original)
+++ trunk/client/gui-sdl2/gui_tilespec.c        Wed Mar 26 23:11:58 2014
@@ -55,8 +55,7 @@
 do {                                                             \
   pSpr = theme_lookup_sprite_tag_alt(theme, LOG_FATAL, tag, "", "", ""); \
   fc_assert_action(pSpr != NULL, break);                          \
-  pStruct->pSurf = adj_surf(GET_SURF_REAL(pSpr));                 \
-  FREESURFACE(GET_SURF_REAL(pSpr));                               \
+  pStruct->pSurf = GET_SURF_REAL(pSpr);                           \
 } while(0)
 
 #define load_theme_surface(pSpr, pSurf, tag)           \
@@ -282,7 +281,7 @@
 #endif
   load_theme_surface(pBuf, Vertic, "theme.vertic_scrollbar");
   load_theme_surface(pBuf, Horiz, "theme.horiz_scrollbar");
-  
+
   /* ------------------- */
   load_theme_surface(pBuf, OK_PACT_Icon, "theme.pact_ok");
   load_theme_surface(pBuf, CANCEL_PACT_Icon, "theme.pact_cancel");

Modified: trunk/client/gui-sdl2/mapview.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/mapview.c?rev=24735&r1=24734&r2=24735&view=diff
==============================================================================
--- trunk/client/gui-sdl2/mapview.c     (original)
+++ trunk/client/gui-sdl2/mapview.c     Wed Mar 26 23:11:58 2014
@@ -116,7 +116,7 @@
       }
       alphablit(Main.map, &rect, Main.mainsurf, &dst, 255);
       if (Main.guis) {
-        while((i < Main.guis_count) && Main.guis[i]) {
+        while ((i < Main.guis_count) && Main.guis[i]) {
           src = rect;
           screen_rect_to_layer_rect(Main.guis[i], &src);
           dst = rect;

Modified: trunk/client/gui-sdl2/widget.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/widget.c?rev=24735&r1=24734&r2=24735&view=diff
==============================================================================
--- trunk/client/gui-sdl2/widget.c      (original)
+++ trunk/client/gui-sdl2/widget.c      Wed Mar 26 23:11:58 2014
@@ -79,12 +79,12 @@
     state = 2 - pressed
     state = 3 - disabled
 **************************************************************************/
-SDL_Surface *create_bcgnd_surf(SDL_Surface * pTheme, Uint8 state,
-                               Uint16 Width, Uint16 High)
+SDL_Surface *create_bcgnd_surf(SDL_Surface *pTheme, Uint8 state,
+                               Uint16 width, Uint16 height)
 {
   bool zoom;
   int iTile_width_len_end, iTile_width_len_mid, iTile_count_len_mid;
-  int iTile_width_high_end, iTile_width_high_mid, iTile_count_high_mid;
+  int iTile_width_height_end, iTile_width_height_mid, iTile_count_height_mid;
   int i, j;
 
   SDL_Rect src, des;
@@ -96,60 +96,60 @@
   iTile_width_len_mid = pTheme->w - (iTile_width_len_end * 2);
 
   iTile_count_len_mid =
-      (Width - (iTile_width_len_end * 2)) / iTile_width_len_mid;
+      (width - (iTile_width_len_end * 2)) / iTile_width_len_mid;
 
   /* corrections I */
   if (((iTile_count_len_mid *
-       iTile_width_len_mid) + (iTile_width_len_end * 2)) < Width) {
+        iTile_width_len_mid) + (iTile_width_len_end * 2)) < width) {
     iTile_count_len_mid++;
   }
 
-  iTile_width_high_end = pTheme->h / 16;
-  iTile_width_high_mid = (pTheme->h / 4) - (iTile_width_high_end * 2);
-  iTile_count_high_mid =
-      (High - (iTile_width_high_end * 2)) / iTile_width_high_mid;
+  iTile_width_height_end = pTheme->h / 16;
+  iTile_width_height_mid = (pTheme->h / 4) - (iTile_width_height_end * 2);
+  iTile_count_height_mid =
+      (height - (iTile_width_height_end * 2)) / iTile_width_height_mid;
 
   /* corrections II */
-  if (((iTile_count_high_mid *
-       iTile_width_high_mid) + (iTile_width_high_end * 2)) < High) {
-    iTile_count_high_mid++;
-  }
-
-  i = MAX(iTile_width_len_end * 2, Width);
-  j = MAX(iTile_width_high_end * 2, High);
-  zoom = ((i != Width) ||  (j != High));
-  
+  if (((iTile_count_height_mid *
+       iTile_width_height_mid) + (iTile_width_height_end * 2)) < height) {
+    iTile_count_height_mid++;
+  }
+
+  i = MAX(iTile_width_len_end * 2, width);
+  j = MAX(iTile_width_height_end * 2, height);
+  zoom = ((i != width) ||  (j != height));
+
   /* now allocate memory */
   pBackground = create_surf_alpha(i, j, SDL_SWSURFACE);
 
   /* copy left end */
 
-  /* copy left top end */
+  /* left top */
   src.x = 0;
   src.y = iStart_y;
   src.w = iTile_width_len_end;
-  src.h = iTile_width_high_end;
+  src.h = iTile_width_height_end;
 
   des.x = 0;
   des.y = 0;
   alphablit(pTheme, &src, pBackground, &des, 255);
 
-  /* copy left middels parts */
-  src.y = iStart_y + iTile_width_high_end;
-  src.h = iTile_width_high_mid;
-  for (i = 0; i < iTile_count_high_mid; i++) {
-    des.y = iTile_width_high_end + i * iTile_width_high_mid;
+  /* left middle */
+  src.y = iStart_y + iTile_width_height_end;
+  src.h = iTile_width_height_mid;
+  for (i = 0; i < iTile_count_height_mid; i++) {
+    des.y = iTile_width_height_end + i * iTile_width_height_mid;
     alphablit(pTheme, &src, pBackground, &des, 255);
   }
 
-  /* copy left boton end */
-  src.y = iStart_y + ((pTheme->h / 4) - iTile_width_high_end);
-  src.h = iTile_width_high_end;
-  des.y = pBackground->h - iTile_width_high_end;
+  /* left bottom */
+  src.y = iStart_y + ((pTheme->h / 4) - iTile_width_height_end);
+  src.h = iTile_width_height_end;
+  des.y = pBackground->h - iTile_width_height_end;
   clear_surface(pBackground, &des);
   alphablit(pTheme, &src, pBackground, &des, 255);
 
-  /* copy middle parts without right end part */
+  /* copy middle parts */
 
   src.x = iTile_width_len_end;
   src.y = iStart_y;
@@ -157,29 +157,31 @@
 
   for (i = 0; i < iTile_count_len_mid; i++) {
 
-    /* top */
+    /* middle top */
     des.x = iTile_width_len_end + i * iTile_width_len_mid;
     des.y = 0;
     src.y = iStart_y;
     alphablit(pTheme, &src, pBackground, &des, 255);
 
-    /*  middels */
-    src.y = iStart_y + iTile_width_high_end;
-    src.h = iTile_width_high_mid;
-    for (j = 0; j < iTile_count_high_mid; j++) {
-      des.y = iTile_width_high_end + j * iTile_width_high_mid;
+    /* middle middle */
+    src.y = iStart_y + iTile_width_height_end;
+    src.h = iTile_width_height_mid;
+    for (j = 0; j < iTile_count_height_mid; j++) {
+      des.y = iTile_width_height_end + j * iTile_width_height_mid;
       alphablit(pTheme, &src, pBackground, &des, 255);
     }
 
-    /* bottom */
-    src.y = iStart_y + ((pTheme->h / 4) - iTile_width_high_end);
-    src.h = iTile_width_high_end;
-    des.y = pBackground->h - iTile_width_high_end;
-    clear_surface(pBackground, &des);    
+    /* middle bottom */
+    src.y = iStart_y + ((pTheme->h / 4) - iTile_width_height_end);
+    src.h = iTile_width_height_end;
+    des.y = pBackground->h - iTile_width_height_end;
+    clear_surface(pBackground, &des);
     alphablit(pTheme, &src, pBackground, &des, 255);
   }
 
   /* copy right end */
+
+  /* right top */
   src.x = pTheme->w - iTile_width_len_end;
   src.y = iStart_y;
   src.w = iTile_width_len_end;
@@ -189,28 +191,28 @@
 
   alphablit(pTheme, &src, pBackground, &des, 255);
 
-  /*  middels */
-  src.y = iStart_y + iTile_width_high_end;
-  src.h = iTile_width_high_mid;
-  for (i = 0; i < iTile_count_high_mid; i++) {
-    des.y = iTile_width_high_end + i * iTile_width_high_mid;
+  /* right middle */
+  src.y = iStart_y + iTile_width_height_end;
+  src.h = iTile_width_height_mid;
+  for (i = 0; i < iTile_count_height_mid; i++) {
+    des.y = iTile_width_height_end + i * iTile_width_height_mid;
     alphablit(pTheme, &src, pBackground, &des, 255);
   }
 
-  /*boton */
-  src.y = iStart_y + ((pTheme->h / 4) - iTile_width_high_end);
-  src.h = iTile_width_high_end;
-  des.y = pBackground->h - iTile_width_high_end;
-  clear_surface(pBackground, &des);  
+  /* right bottom */
+  src.y = iStart_y + ((pTheme->h / 4) - iTile_width_height_end);
+  src.h = iTile_width_height_end;
+  des.y = pBackground->h - iTile_width_height_end;
+  clear_surface(pBackground, &des);
   alphablit(pTheme, &src, pBackground, &des, 255);
 
-  if (zoom)
-  {
-    SDL_Surface *pZoom = ResizeSurface(pBackground, Width, High, 1);
+  if (zoom) {
+    SDL_Surface *pZoom = ResizeSurface(pBackground, width, height, 1);
+
     FREESURFACE(pBackground);
     pBackground = pZoom;
   }
-  
+
   return pBackground;
 }
 

Modified: trunk/client/gui-sdl2/widget_button.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/widget_button.c?rev=24735&r1=24734&r2=24735&view=diff
==============================================================================
--- trunk/client/gui-sdl2/widget_button.c       (original)
+++ trunk/client/gui-sdl2/widget_button.c       Wed Mar 26 23:11:58 2014
@@ -34,9 +34,9 @@
 /**************************************************************************
   Create Icon Button image with text and Icon then blit to Dest(ination)
   on positon pIButton->size.x , pIButton->size.y.
-  WARRING: pDest must exist.
-
-  Text with atributes is taken from pIButton->string16 parameter.
+  WARNING: pDest must exist.
+
+  Text with attributes is taken from pIButton->string16 parameter.
 
   Graphic for button is taken from pIButton->theme surface 
   and blit to new created image.
@@ -44,7 +44,7 @@
   Graphic for Icon is taken from pIButton->theme2 surface and blit to new
   created image.
 
-  function return (-1) if there are no Icon and Text.
+  function return (-1) if there are no Icon nor Text.
   Else return 0.
 **************************************************************************/
 static int redraw_ibutton(struct widget *pIButton)
@@ -86,7 +86,7 @@
 
   /* create Button graphic */
   pButton = create_bcgnd_surf(pIButton->theme, get_wstate(pIButton),
-                             pIButton->size.w, pIButton->size.h);
+                              pIButton->size.w, pIButton->size.h);
 
   clear_surface(pIButton->dst->surface, &pIButton->size);
   alphablit(pButton, NULL, pIButton->dst->surface, &pIButton->size, 255);
@@ -235,7 +235,7 @@
   if (iRet != 0) {
     return iRet;
   }
-  
+
   pIcon = create_icon_from_theme(pTIButton->theme2, get_wstate(pTIButton));
   pCopy_Of_Icon_Theme = pTIButton->theme2;
 
@@ -261,8 +261,8 @@
 
   function return pointer to allocated Button Widget.
 **************************************************************************/
-struct widget * create_icon_button(SDL_Surface *pIcon, struct gui_layer *pDest,
-                         SDL_String16 *pStr, Uint32 flags)
+struct widget *create_icon_button(SDL_Surface *pIcon, struct gui_layer *pDest,
+                                  SDL_String16 *pStr, Uint32 flags)
 {
   SDL_Rect buf = {0, 0, 0, 0};
   int w = 0, h = 0;
@@ -339,8 +339,9 @@
 
   function return pointer to allocated Button Widget.
 **************************************************************************/
-struct widget * create_themeicon_button(SDL_Surface *pIcon_theme,
-               struct gui_layer *pDest, SDL_String16 *pString16, Uint32 flags)
+struct widget *create_themeicon_button(SDL_Surface *pIcon_theme,
+                                       struct gui_layer *pDest, SDL_String16 
*pString16,
+                                       Uint32 flags)
 {
   /* extract a single icon */
   SDL_Surface *pIcon = create_icon_from_theme(pIcon_theme, 1);
@@ -374,6 +375,7 @@
 {
   pButton->size.x = start_x;
   pButton->size.y = start_y;
+
   return redraw_tibutton(pButton);
 }
 


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to