[Freeciv-Dev] (PR#4601) use put_unit in gui-win32
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
The attached patch tries to use put_unit from within gui-win32. I can't
compile this right now and am still not very comfortable with this GUI
library, so the odds are it doesn't work.
Andi, can you fix and commit it?
jason
Index: client/gui-win32/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/citydlg.c,v
retrieving revision 1.52
diff -u -r1.52 citydlg.c
--- client/gui-win32/citydlg.c 2003/04/08 08:47:31 1.52
+++ client/gui-win32/citydlg.c 2003/07/18 01:39:05
@@ -294,6 +294,8 @@
struct unit_list *plist;
struct genlist_iterator myiter;
struct unit *punit;
+ struct canvas_store store = {hdc, NULL};
+
if(unitid) {
for(i=0; i<NUM_UNITS_SHOWN; i++)
if(pdialog->present_unit_ids[i]==unitid)
@@ -322,9 +324,9 @@
rc.right=rc.left+NORMAL_TILE_WIDTH;
rc.bottom=rc.top+SMALL_TILE_HEIGHT+NORMAL_TILE_HEIGHT;
FillRect(hdc,&rc,(HBRUSH)GetClassLong(pdialog->mainwindow,GCL_HBRBACKGROUND));
- put_unit_pixmap(punit,hdc,
- pdialog->pop_x+i*(SMALL_TILE_WIDTH+NORMAL_TILE_WIDTH),
- pdialog->present_y);
+ put_unit(punit, &store,
+ pdialog->pop_x + i * (SMALL_TILE_WIDTH + NORMAL_TILE_WIDTH),
+ pdialog->present_y);
pdialog->present_unit_ids[i]=punit->id;
}
@@ -350,6 +352,8 @@
struct unit_list *plist;
struct genlist_iterator myiter;
struct unit *punit;
+ struct canvas_store store = {hdc, NULL};
+
if(unitid) {
for(i=0; i<NUM_UNITS_SHOWN; i++)
if(pdialog->support_unit_ids[i]==unitid)
@@ -375,9 +379,9 @@
rc.right=rc.left+NORMAL_TILE_WIDTH;
rc.bottom=rc.top+SMALL_TILE_HEIGHT+NORMAL_TILE_HEIGHT;
FillRect(hdc,&rc,(HBRUSH)GetClassLong(pdialog->mainwindow,GCL_HBRBACKGROUND));
- put_unit_pixmap(punit,hdc,
- pdialog->pop_x+i*(SMALL_TILE_WIDTH+NORMAL_TILE_WIDTH),
- pdialog->supported_y);
+ put_unit(punit, &store,
+ pdialog->pop_x + i * (SMALL_TILE_WIDTH + NORMAL_TILE_WIDTH),
+ pdialog->supported_y);
put_unit_city_overlays(punit,hdc,
pdialog->pop_x+i*(SMALL_TILE_WIDTH+NORMAL_TILE_WIDTH),
pdialog->supported_y);
Index: client/gui-win32/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/dialogs.c,v
retrieving revision 1.34
diff -u -r1.34 dialogs.c
--- client/gui-win32/dialogs.c 2003/07/10 03:50:56 1.34
+++ client/gui-win32/dialogs.c 2003/07/18 01:39:05
@@ -775,6 +775,8 @@
struct unit *punit=unit_list_get(&ptile->units, i);
struct unit_type *punittemp=unit_type(punit);
struct city *pcity;
+ struct canvas_store store = {unitsel_dc, NULL};
+
pcity=player_find_city_by_id(game.player_ptr, punit->homecity);
my_snprintf(buffer, sizeof(buffer), "%s(%s)\n%s",
punittemp->name,
@@ -793,7 +795,7 @@
SelectObject(unitsel_dc,unit_select_bitmaps[i]);
BitBlt(unitsel_dc,0,0,UNIT_TILE_WIDTH,UNIT_TILE_HEIGHT,NULL,
0,0,WHITENESS);
- put_unit_pixmap(punit,unitsel_dc,0,0);
+ put_unit(punit, &store, 0, 0);
SelectObject(unitsel_dc,old);
unit_select_but[i]=CreateWindow("BUTTON",NULL,
WS_CHILD | WS_VISIBLE | BS_BITMAP,
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.72
diff -u -r1.72 mapview.c
--- client/gui-win32/mapview.c 2003/07/17 01:37:07 1.72
+++ client/gui-win32/mapview.c 2003/07/18 01:39:05
@@ -173,49 +173,6 @@
/**************************************************************************
**************************************************************************/
-void put_unit_pixmap(struct unit *punit, HDC hdc,int canvas_x,int canvas_y)
-{
- int solid_bg;
- if (is_isometric) {
- struct Sprite *sprites[40];
- int count = fill_unit_sprite_array(sprites, punit,&solid_bg);
- int i;
-
- assert(!solid_bg);
- for (i=0; i<count; i++) {
- if (sprites[i]) {
- draw_sprite(sprites[i],hdc,canvas_x,canvas_y);
- }
- }
-
- } else {
- struct Sprite *sprites[40];
- int count = fill_unit_sprite_array(sprites, punit, &solid_bg);
- if (count) {
- int i=0;
- if (solid_bg) {
- RECT rc;
- rc.left=canvas_x;
- rc.top=canvas_y;
- rc.right=rc.left+UNIT_TILE_WIDTH;
- rc.bottom=rc.top+UNIT_TILE_HEIGHT;
- FillRect(hdc,&rc,brush_std[player_color(unit_owner(punit))]);
- } else {
-
- draw_sprite(sprites[0],hdc,canvas_x,canvas_y);
-
- i++;
- }
- for(;i<count;i++) {
- if (sprites[i])
- draw_sprite(sprites[i],hdc,canvas_x,canvas_y);
- }
- }
- }
-}
-/**************************************************************************
-
-**************************************************************************/
void put_unit_city_overlays(struct unit *punit, HDC hdc, int x, int y)
{
int upkeep_food = CLIP(0, punit->upkeep_food, 2);
@@ -718,15 +675,14 @@
int old_canvas_x, int old_canvas_y,
int new_canvas_x, int new_canvas_y)
{
- static HDC mapstoredc, hdc, hdcwin;
- static HBITMAP old, oldbmp;
+ static HDC mapstoredc, hdcwin;
+ static HBITMAP old;
+ struct canvas_store store = {MULL, single_tile_pixmap}
/* Create extra backing store. This should be done statically. */
if (first_frame) {
mapstoredc = CreateCompatibleDC(NULL);
old = SelectObject(mapstoredc, mapstorebitmap);
- hdc = CreateCompatibleDC(NULL);
- oldbmp = SelectObject(hdc, single_tile_pixmap);
hdcwin = GetDC(map_window);
}
@@ -737,7 +693,7 @@
/* Draw the new sprite. */
BitBlt(hdc, 0, 0, UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT, mapstoredc,
new_canvas_x, new_canvas_y, SRCCOPY);
- put_unit_pixmap(punit, hdc, 0, 0);
+ put_unit_full(punit, &store, 0, 0);
/* Write to screen. */
BitBlt(hdcwin, new_canvas_x, new_canvas_y, UNIT_TILE_WIDTH,
@@ -747,8 +703,6 @@
GdiFlush();
if (last_frame) {
- SelectObject(hdc, oldbmp);
- DeleteDC(hdc);
ReleaseDC(map_window, hdcwin);
SelectObject(mapstoredc, old);
DeleteDC(mapstoredc);
@@ -813,7 +767,7 @@
struct canvas_store store = {NULL, single_tile_pixmap};
put_one_tile(&store, losing_unit->x, losing_unit->y, 0, 0, FALSE);
- put_unit_pixmap(losing_unit, hdc, 0, 0);
+ put_unit(losing_unit, &store, 0, 0);
draw_sprite(sprites.explode.unit[i],hdc,NORMAL_TILE_WIDTH/4,0);
BitBlt(hdcwin,canvas_x,canvas_y,
NORMAL_TILE_WIDTH,NORMAL_TILE_HEIGHT,
@@ -1331,29 +1285,6 @@
/**************************************************************************
Only used for isometric view.
**************************************************************************/
-static void put_unit_pixmap_draw(struct unit *punit, HDC hdc,
- int canvas_x, int canvas_y,
- int offset_x, int offset_y_unit,
- int width, int height_unit)
-{
- struct Sprite *sprites[40];
- int dummy;
- int count = fill_unit_sprite_array(sprites, punit, &dummy);
- int i;
-
- for (i=0; i<count; i++) {
- if (sprites[i]) {
- pixmap_put_overlay_tile_draw(hdc, canvas_x, canvas_y, sprites[i],
- offset_x, offset_y_unit,
- width, height_unit, 0);
- }
- }
-}
-
-
-/**************************************************************************
-Only used for isometric view.
-**************************************************************************/
static void put_city_pixmap_draw(struct city *pcity,HDC hdc,
int canvas_x, int canvas_y,
int offset_x, int offset_y_unit,
@@ -1587,10 +1518,8 @@
/*** Unit ***/
if (punit && (draw_units || (punit == pfocus && draw_focus_unit))) {
- put_unit_pixmap_draw(punit, hdc,
- canvas_x, canvas_y - NORMAL_TILE_HEIGHT/2,
- offset_x, offset_y_unit,
- width, height_unit);
+ put_unit(punit, &canvas_store, canvas_x, canvas_y,
+ offset_x, offset_y_unit, width, height_unit);
if (!pcity && unit_list_size(&map_get_tile(x, y)->units) > 1)
pixmap_put_overlay_tile_draw(hdc,
canvas_x, canvas_y-NORMAL_TILE_HEIGHT/2,
Index: client/gui-win32/mapview.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.h,v
retrieving revision 1.10
diff -u -r1.10 mapview.h
--- client/gui-win32/mapview.h 2003/04/03 04:13:49 1.10
+++ client/gui-win32/mapview.h 2003/07/18 01:39:05
@@ -17,7 +17,6 @@
void put_city_tile_output(HDC hdc, int x, int y,
int food, int shield, int trade);
-void put_unit_pixmap(struct unit *punit, HDC hdc,int x,int y);
void pixmap_frame_tile_red(HDC hdc, int x, int y);
void put_unit_city_overlays(struct unit *punit, HDC hdc, int x, int y);
void put_one_tile_full(HDC hdc, int x, int y,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#4601) use put_unit in gui-win32,
Jason Short <=
|
|