[Freeciv-Dev] (PR#14639) Patch for SDL client
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=14639 >
This patch makes the SDL client compile again. I've also started to do
some modifications that allow playing at 320x240 resolution, so you
could play Freeciv on small screen devices, like Pocket PC, too. To
avoid the overhead of recalculating every size parameter at runtime,
most of the resizing is done at compile time using macros. To build a
client for 320x240 resolution just enable the SMALL_SCREEN define in
gui-main.h.
There are some additional files needed that are not in current svn tree.
You can get them from
http://web.inf.tu-dresden.de/~s3564543/freeciv-sdl/missing_files.tar.bz2
The SDL client uses some own sprites that it previously handled on its
own with calls to load_sprite() and unload_sprite(). Because these
functions are now declared static in tilespec.c and none of the public
get_*_sprite() functions do the job, I decided to make
lookup_sprite_tag_alt() public, so the sprites can be accessed this way.
Also the .tilespec-files need to be patched to include the additional
sprites. Patches for the 4 default tilesets are attached to this mail.
If you have a better idea how to load client-specific sprites (ideally
without changing the existing .tilespec files), please let me know :-)
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/chatline.c
devel/client/gui-sdl/chatline.c
--- devel_distclean/client/gui-sdl/chatline.c 2005-10-15 23:27:27.000000000
+0200
+++ devel/client/gui-sdl/chatline.c 2005-11-15 06:52:44.000000000 +0100
@@ -52,10 +52,12 @@
#include "mapview.h"
#include "messagewin.h"
#include "chatline.h"
+#include "log.h"
+#include "dialogs.h"
#include "connectdlg.h"
-#define PTSIZE_LOG_FONT 10
+#define PTSIZE_LOG_FONT adj_font(10)
struct CONNLIST {
struct ADVANCED_DLG *pUsers_Dlg;
@@ -89,7 +91,7 @@
if (theinput && *theinput) {
send_chat(theinput);
- real_append_output_window(theinput);
+ append_output_window(theinput);
FREE(theinput);
}
@@ -101,11 +103,11 @@
**************************************************************************/
void popup_input_line(void)
{
- int w = 400;
- int h = 30;
+ int w = adj_size(400);
+ int h = adj_size(30);
struct GUI *pInput_Edit;
- pInput_Edit = create_edit_from_unichars(NULL, NULL, NULL, 0, 18, w, 0);
+ pInput_Edit = create_edit_from_unichars(NULL, NULL, NULL, 0, adj_font(18),
w, 0);
lock_buffer(pInput_Edit->dst);/* always on top */
pInput_Edit->size.x = (Main.screen->w - w) / 2;
@@ -148,7 +150,7 @@
char message[MAX_LEN_MSG];
my_snprintf(message , MAX_LEN_MSG, "%s" , astring);
- add_notify_window(message, -1, -1, E_NOEVENT);
+ add_notify_window(message, NULL, E_CHAT_MSG);
}
}
@@ -202,16 +204,16 @@
assert(pUniStr != NULL);
assert(n_alloc != 0);
- pStr = create_string16(pUniStr, n_alloc, 12);
+ pStr = create_string16(pUniStr, n_alloc, adj_font(12));
- if (convert_string_to_const_surface_width(pStr, pConnDlg->text_width - 5)) {
+ if (convert_string_to_const_surface_width(pStr, pConnDlg->text_width -
adj_size(5))) {
SDL_String16 *pStr2;
int count = 0;
Uint16 **UniTexts = create_new_line_unistrings(pStr->text);
while (UniTexts[count]) {
pStr2 = create_string16(UniTexts[count],
- unistrlen(UniTexts[count]) + 1, 12);
+ unistrlen(UniTexts[count]) + 1,
adj_font(12));
pStr2->render = 3;
pStr2->bgcol = bg;
pBuf = create_themelabel2(NULL, pWindow->dst,
@@ -221,8 +223,8 @@
pBuf->size.w = pConnDlg->text_width;
add_widget_to_vertical_scroll_widget_list(pConnDlg->pChat_Dlg, pBuf,
pConnDlg->pChat_Dlg->pBeginActiveWidgetList, FALSE,
- pWindow->size.x + 10 + 60 + 10,
- pWindow->size.y + 14);
+ pWindow->size.x + adj_size(10 + 60 + 10),
+ pWindow->size.y + adj_size(14));
count++;
}
redraw_group(pConnDlg->pChat_Dlg->pBeginWidgetList,
@@ -239,8 +241,8 @@
if (add_widget_to_vertical_scroll_widget_list(pConnDlg->pChat_Dlg, pBuf,
pConnDlg->pChat_Dlg->pBeginActiveWidgetList, FALSE,
- pWindow->size.x + 10 + 60 + 10,
- pWindow->size.y + 14)) {
+ pWindow->size.x + adj_size(10 + 60 + 10),
+ pWindow->size.y + adj_size(14))) {
redraw_group(pConnDlg->pChat_Dlg->pBeginWidgetList,
pConnDlg->pChat_Dlg->pEndWidgetList, TRUE);
} else {
@@ -295,16 +297,26 @@
}
/**************************************************************************
+...
+**************************************************************************/
+static int select_nation_callback(struct GUI *pWidget)
+{
+ popup_races_dialog(game.player_ptr);
+
+ return -1;
+}
+
+
+/**************************************************************************
Update the connected users list at pregame state.
**************************************************************************/
void update_conn_list_dialog(void)
{
-
if (get_client_state() == CLIENT_PRE_GAME_STATE) {
if (pConnDlg) {
SDL_Color bg = {0, 0, 0, 0};
struct GUI *pBuf = NULL, *pWindow = pConnDlg->pEndWidgetList;
- SDL_String16 *pStr = create_string16(NULL, 0, 12);
+ SDL_String16 *pStr = create_string16(NULL, 0, adj_font(12));
bool create;
pStr->render = 3;
@@ -329,8 +341,8 @@
pConnDlg->pUsers_Dlg->pEndWidgetList =
pConnDlg->pUsers_Dlg->pEndWidgetList->prev;
setup_vertical_scrollbar_area(pConnDlg->pUsers_Dlg->pScroll,
- pWindow->size.x + pWindow->size.w - 29 - FRAME_WH,
- pWindow->size.y + 14, pWindow->size.h - 44, FALSE);
+ pWindow->size.x + pWindow->size.w - adj_size(29) -
FRAME_WH,
+ pWindow->size.y + adj_size(14), pWindow->size.h -
adj_size(44), FALSE);
}
hide_scrollbar(pConnDlg->pUsers_Dlg->pScroll);
@@ -339,7 +351,7 @@
copy_chars_to_string16(pStr, pconn->username);
- pBuf = create_themelabel2(NULL, pWindow->dst, pStr, 100, 0,
+ pBuf = create_themelabel2(NULL, pWindow->dst, pStr, adj_size(100), 0,
(WF_DRAW_THEME_TRANSPARENT|WF_DRAW_TEXT_LABEL_WITH_SPACE));
clear_wflag(pBuf, WF_FREE_STRING);
@@ -349,14 +361,14 @@
if(create) {
add_widget_to_vertical_scroll_widget_list(pConnDlg->pUsers_Dlg,
pBuf, pConnDlg->pUsers_Dlg->pBeginWidgetList, FALSE,
- pWindow->size.x + pWindow->size.w - 130 - FRAME_WH,
- pWindow->size.y + 14);
+ pWindow->size.x + pWindow->size.w - adj_size(130) -
FRAME_WH,
+ pWindow->size.y + adj_size(14));
create = FALSE;
} else {
add_widget_to_vertical_scroll_widget_list(pConnDlg->pUsers_Dlg,
pBuf, pConnDlg->pUsers_Dlg->pBeginActiveWidgetList, FALSE,
- pWindow->size.x + pWindow->size.w - 130 - FRAME_WH,
- pWindow->size.y + 14);
+ pWindow->size.x + pWindow->size.w - adj_size(130) - FRAME_WH,
+ pWindow->size.y + adj_size(14));
}
} conn_list_iterate_end;
@@ -366,10 +378,8 @@
if (aconnection.access_level == ALLOW_CTRL
|| aconnection.access_level == ALLOW_HACK) {
- set_wstate(pConnDlg->pStart, FC_WS_NORMAL);
set_wstate(pConnDlg->pConfigure, FC_WS_NORMAL);
} else {
- set_wstate(pConnDlg->pStart, FC_WS_DISABLED);
set_wstate(pConnDlg->pConfigure, FC_WS_DISABLED);
}
@@ -419,28 +429,32 @@
{
SDL_Rect area;
SDL_Color color = {255, 255, 255, 96};
- SDL_Surface *pSurf = get_logo_gfx();
+ SDL_Surface *pSurf = adj_surf(get_logo_gfx());
if (resize_window(pWindow, pSurf, NULL, Main.screen->w, Main.screen->h)) {
FREESURFACE(pSurf);
}
- n = pWindow->size.w - 130 - FRAME_WH - (10 + 60 + 10 + 30);
+ #ifdef SMALL_SCREEN
+ n = 263;
+ #else
+ n = pWindow->size.w - adj_size(130) - FRAME_WH - adj_size(10 + 60 + 10 +
30);
+ #endif
pConnDlg->text_width = n;
/* draw lists backgrounds */
- area.x = 10 + 60 + 10;
- area.y = 14;
- area.w = n + 20;
- area.h = pWindow->size.h - 44;
+ area.x = adj_size(10 + 60 + 10);
+ area.y = adj_size(14);
+ area.w = n + adj_size(20);
+ area.h = pWindow->size.h - adj_size(44);
SDL_FillRectAlpha(pWindow->theme, &area, &color);
putframe(pWindow->theme, area.x - 1, area.y - 1, area.x + area.w,
area.y + area.h, 0xFFFFFFFF);
- area.x = pWindow->size.w - 130 - FRAME_WH;
- area.y = 14;
- area.w = 120;
- area.h = pWindow->size.h - 44;
+ area.x = pWindow->size.w - adj_size(130) - FRAME_WH;
+ area.y = adj_size(14);
+ area.w = adj_size(120);
+ area.h = pWindow->size.h - adj_size(44);
SDL_FillRectAlpha(pWindow->theme, &area, &color);
putframe(pWindow->theme, area.x - 1, area.y - 1, area.x + area.w,
area.y + area.h, 0xFFFFFFFF);
@@ -452,12 +466,12 @@
pConnDlg->pChat_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
- n = conn_list_size(&game.est_connections);
+ n = conn_list_size(game.est_connections);
{
char cBuf[256];
my_snprintf(cBuf, sizeof(cBuf), _("Total users logged in : %d"), n);
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
}
pStr->render = 3;
@@ -470,8 +484,8 @@
pStr, pConnDlg->text_width, 0,
(WF_DRAW_THEME_TRANSPARENT|WF_DRAW_TEXT_LABEL_WITH_SPACE));
- pBuf->size.x = pWindow->size.x + 10 + 60 + 10;
- pBuf->size.y = pWindow->size.y + 14;
+ pBuf->size.x = pWindow->size.x + adj_size(10 + 60 + 10);
+ pBuf->size.y = pWindow->size.y + adj_size(14);
pBuf->size.w = pConnDlg->text_width;
add_to_gui_list(ID_LABEL, pBuf);
@@ -484,78 +498,84 @@
pConnDlg->pChat_Dlg->pScroll = MALLOC(sizeof(struct ScrollBar));
pConnDlg->pChat_Dlg->pScroll->count = 1;
- n = (pWindow->size.h - 44) / pBuf->size.h;
+ n = (pWindow->size.h - adj_size(44)) / pBuf->size.h;
pConnDlg->active = n;
create_vertical_scrollbar(pConnDlg->pChat_Dlg, 1,
pConnDlg->active, TRUE, TRUE);
setup_vertical_scrollbar_area(pConnDlg->pChat_Dlg->pScroll,
- pWindow->size.x + 10 + 60 + 10 + pConnDlg->text_width + 1,
- pWindow->size.y + 14, pWindow->size.h - 44, FALSE);
+ pWindow->size.x + adj_size(10 + 60 + 10) + pConnDlg->text_width
+ 1,
+ pWindow->size.y + adj_size(14), pWindow->size.h - adj_size(44),
FALSE);
hide_scrollbar(pConnDlg->pChat_Dlg->pScroll);
/* -------------------------------- */
pBuf = create_themeicon_button_from_chars(NULL, pWindow->dst,
- _("Start\nGame"), 12, 0);
- pBuf->size.w = 60;
- pBuf->size.h = 60;
- pBuf->size.x = pWindow->size.x + 10;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - 4 * (pBuf->size.h + 10);
+ _("Start\nGame"), adj_font(12), 0);
+ pBuf->size.w = adj_size(60);
+ pBuf->size.h = adj_size(60);
+ pBuf->size.x = pWindow->size.x + adj_size(10);
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - 4 * (pBuf->size.h +
adj_size(10));
pConnDlg->pStart = pBuf;
pBuf->action = start_game_callback;
+ set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(ID_BUTTON, pBuf);
pBuf = create_themeicon_button_from_chars(NULL, pWindow->dst,
- _("Server\nSettings"), 12, 0);
- pBuf->size.w = 60;
- pBuf->size.h = 60;
- pBuf->size.x = pWindow->size.x + 10;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - 3 * (pBuf->size.h + 10);
- pConnDlg->pConfigure = pBuf;
- pBuf->action = server_config_callback;
+ _("Select\nNation"), adj_font(12), 0);
+ pBuf->size.w = adj_size(60);
+ pBuf->size.h = adj_size(60);
+ pBuf->size.x = pWindow->size.x + adj_size(10);
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - 3 * (pBuf->size.h +
adj_size(10));
+
+ pBuf->action = select_nation_callback;
+ set_wstate(pBuf, FC_WS_NORMAL);
+
add_to_gui_list(ID_BUTTON, pBuf);
pBuf = create_themeicon_button_from_chars(NULL, pWindow->dst,
- _("Tabs"), 12, 0);
- pBuf->size.w = 60;
- pBuf->size.h = 60;
- pBuf->size.x = pWindow->size.x + 10;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - 2 * (pBuf->size.h + 10);
- /*pBuf->action = client_config_callback;
- set_wstate(pBuf, FC_WS_NORMAL);*/
+ _("Server\nSettings"), adj_font(12), 0);
+ pBuf->size.w = adj_size(60);
+ pBuf->size.h = adj_size(60);
+ pBuf->size.x = pWindow->size.x + adj_size(10);
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - 2 * (pBuf->size.h +
adj_size(10));
+ pConnDlg->pConfigure = pBuf;
+ pBuf->action = server_config_callback;
+ set_wstate(pBuf, FC_WS_DISABLED);
add_to_gui_list(ID_BUTTON, pBuf);
pBuf = create_themeicon_button_from_chars(NULL, pWindow->dst,
- _("Quit"), 12, 0);
- pBuf->size.w = 60;
- pBuf->size.h = 60;
- pBuf->size.x = pWindow->size.x + 10;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - (pBuf->size.h + 10);
+ _("Quit"), adj_font(12), 0);
+ pBuf->size.w = adj_size(60);
+ pBuf->size.h = adj_size(60);
+ pBuf->size.x = pWindow->size.x + adj_size(10);
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - (pBuf->size.h +
adj_size(10));
pBuf->action = disconnect_conn_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
add_to_gui_list(ID_BUTTON, pBuf);
pBuf = create_edit_from_unichars(NULL, pWindow->dst,
- NULL, 0, 12, pConnDlg->text_width + 120,
+ NULL, 0, adj_font(12), pConnDlg->text_width + adj_size(155),
(WF_DRAW_THEME_TRANSPARENT|WF_EDIT_LOOP));
- pBuf->size.x = pWindow->size.x + 10 + 60 + 10;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - (pBuf->size.h + 5);
+ pBuf->size.x = adj_size(10 + 60 + 10 - 3);
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - (pBuf->size.h +
adj_size(5));
pBuf->action = input_edit_conn_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pConnDlg->pEdit = pBuf;
add_to_gui_list(ID_EDIT, pBuf);
+#if 0
pBuf = create_themeicon_button_from_chars(NULL, pWindow->dst,
"?", 12, 0);
pBuf->size.y = pWindow->size.y + pWindow->size.h - (pBuf->size.h + 7);
pBuf->size.x = pWindow->size.x + pWindow->size.w - (pBuf->size.w + 10) - 5;
- /*pBuf->action = client_config_callback;
- set_wstate(pBuf, FC_WS_NORMAL);*/
+ pBuf->action = client_config_callback;
+ set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(ID_BUTTON, pBuf);
+#endif
pConnDlg->pBeginWidgetList = pBuf;
/* ------------------------------------------------------------ */
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/chatline.h
devel/client/gui-sdl/chatline.h
--- devel_distclean/client/gui-sdl/chatline.h 2005-10-15 23:27:27.000000000
+0200
+++ devel/client/gui-sdl/chatline.h 2005-11-15 06:52:44.000000000 +0100
@@ -27,6 +27,6 @@
void popup_input_line(void);
#define set_output_window_text( pString ) \
- real_append_output_window( pString )
+ append_output_window( pString )
#endif /* FC__CHATLINE_H */
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/citydlg.c
devel/client/gui-sdl/citydlg.c
--- devel_distclean/client/gui-sdl/citydlg.c 2005-10-18 21:02:43.000000000
+0200
+++ devel/client/gui-sdl/citydlg.c 2005-11-15 06:52:44.000000000 +0100
@@ -126,6 +126,12 @@
bool lock;
} *pCityDlg = NULL;
+enum specialist_type {
+ SP_ELVIS, SP_SCIENTIST, SP_TAXMAN, SP_LAST
+};
+
+static float city_map_zoom = 1;
+
static struct SMALL_DLG *pHurry_Prod_Dlg = NULL;
static void popdown_hurry_production_dialog(void);
@@ -136,6 +142,16 @@
/* ======================================================================= */
+Impr_type_id get_building_for_effect(enum effect_type effect_type) {
+
+ impr_type_iterate(imp) {
+ if (building_has_effect(imp, effect_type))
+ return imp;
+ } impr_type_iterate_end;
+
+ return B_LAST;
+}
+
/**************************************************************************
Destroy City Menu Dlg but not undraw.
**************************************************************************/
@@ -286,7 +302,7 @@
remove_locked_buffer();
}
del_city_dialog();
- center_tile_mapcanvas(pUnit->x, pUnit->y);
+ center_tile_mapcanvas(pUnit->tile);
set_unit_focus(pUnit);
flush_dirty();
}
@@ -420,7 +436,7 @@
remove_locked_buffer();
}
del_city_dialog();
- center_tile_mapcanvas(pUnit->x, pUnit->y);
+ center_tile_mapcanvas(pUnit->tile);
set_unit_focus(pUnit);
flush_dirty();
return -1;
@@ -433,11 +449,11 @@
ww = 0;
hh = 0;
i = 0;
- pUType = get_unit_type(pUnit->type);
+ pUType = pUnit->type;
/* ----- */
my_snprintf(cBuf, sizeof(cBuf), "%s :", _("Unit Commands"));
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
pWindow = create_window(pWindow->dst, pStr, 1, 1, 0);
pWindow->size.x = pButton->size.x;
@@ -450,9 +466,9 @@
/* ----- */
my_snprintf(cBuf, sizeof(cBuf), "%s", unit_description(pUnit));
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
- pBuf = create_iconlabel(GET_SURF(get_unit_type(pUnit->type)->sprite),
+ pBuf = create_iconlabel(GET_SURF(get_unittype_sprite(tileset, pUnit->type)),
pWindow->dst, pStr, 0);
ww = MAX(ww, pBuf->size.w);
add_to_gui_list(ID_LABEL, pBuf);
@@ -461,7 +477,7 @@
/* Activate unit */
pBuf =
create_icon_button_from_chars(NULL, pWindow->dst,
- _("Activate unit"), 12, 0);
+ _("Activate unit"), adj_font(12),
0);
i++;
ww = MAX(ww, pBuf->size.w);
hh = MAX(hh, pBuf->size.h);
@@ -474,7 +490,7 @@
/* Activate unit, close dlg. */
pBuf = create_icon_button_from_chars(NULL, pWindow->dst,
- _("Activate unit, close dialog"), 12, 0);
+ _("Activate unit, close dialog"), adj_font(12), 0);
i++;
ww = MAX(ww, pBuf->size.w);
hh = MAX(hh, pBuf->size.h);
@@ -488,7 +504,7 @@
if (pCityDlg->state == ARMY_PAGE) {
/* Sentry unit */
pBuf = create_icon_button_from_chars(NULL, pWindow->dst,
- _("Sentry unit"), 12, 0);
+ _("Sentry unit"), adj_font(12), 0);
i++;
ww = MAX(ww, pBuf->size.w);
hh = MAX(hh, pBuf->size.h);
@@ -504,7 +520,7 @@
/* Fortify unit */
pBuf = create_icon_button_from_chars(NULL, pWindow->dst,
- _("Fortify unit"), 12, 0);
+ _("Fortify unit"), adj_font(12), 0);
i++;
ww = MAX(ww, pBuf->size.w);
hh = MAX(hh, pBuf->size.h);
@@ -521,7 +537,7 @@
/* Disband unit */
pBuf = create_icon_button_from_chars(NULL, pWindow->dst,
- _("Disband unit"), 12, 0);
+ _("Disband unit"), adj_font(12), 0);
i++;
ww = MAX(ww, pBuf->size.w);
hh = MAX(hh, pBuf->size.h);
@@ -536,7 +552,7 @@
if (pUnit->homecity != pCityDlg->pCity->id) {
/* Make new Homecity */
pBuf = create_icon_button_from_chars(NULL, pWindow->dst,
- _("Make new homecity"), 12, 0);
+ _("Make new homecity"), adj_font(12),
0);
i++;
ww = MAX(ww, pBuf->size.w);
hh = MAX(hh, pBuf->size.h);
@@ -548,10 +564,10 @@
}
/* ----- */
- if (can_upgrade_unittype(game.player_ptr, pUnit->type) != -1) {
+ if (can_upgrade_unittype(game.player_ptr, pUType)) {
/* Upgrade unit */
pBuf = create_icon_button_from_chars(NULL, pWindow->dst,
- _("Upgrade unit"), 12, 0);
+ _("Upgrade unit"), adj_font(12), 0);
i++;
ww = MAX(ww, pBuf->size.w);
hh = MAX(hh, pBuf->size.h);
@@ -566,7 +582,7 @@
/* ----- */
/* Cancel */
pBuf = create_icon_button_from_chars(NULL, pWindow->dst,
- _("Cancel"), 12, 0);
+ _("Cancel"), adj_font(12), 0);
i++;
ww = MAX(ww, pBuf->size.w);
hh = MAX(hh, pBuf->size.h);
@@ -581,29 +597,29 @@
unsellect_widget_action();
/* ================================================== */
- ww += DOUBLE_FRAME_WH + 10;
- hh += 4;
+ ww += DOUBLE_FRAME_WH + adj_size(10);
+ hh += adj_size(4);
pWindow->size.x += FRAME_WH;
- pWindow->size.y += WINDOW_TILE_HIGH + 2;
+ pWindow->size.y += WINDOW_TILE_HIGH + adj_size(2);
/* create window background */
resize_window(pWindow, NULL,
get_game_colorRGB(COLOR_STD_BACKGROUND_BROWN), ww,
- WINDOW_TILE_HIGH + 2 + FRAME_WH + (i * hh) +
- pWindow->prev->size.h + 5);
+ WINDOW_TILE_HIGH + adj_size(2) + FRAME_WH + (i * hh) +
+ pWindow->prev->size.h + adj_size(5));
/* label */
pBuf = pWindow->prev;
pBuf->size.w = ww - DOUBLE_FRAME_WH;
pBuf->size.x = pWindow->size.x + FRAME_WH;
- pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 2;
+ pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(2);
pBuf = pBuf->prev;
/* first button */
pBuf->size.w = ww - DOUBLE_FRAME_WH;
pBuf->size.h = hh;
pBuf->size.x = pWindow->size.x + FRAME_WH;
- pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + 5;
+ pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + adj_size(5);
pBuf = pBuf->prev;
while (pBuf) {
@@ -635,10 +651,16 @@
{
int i, step;
SDL_Rect dest;
- SDL_Surface *pSurf =
- create_surf(tileset_full_tile_width(tileset),
tileset_full_tile_height(tileset), SDL_SWSURFACE);
+ SDL_Surface *pSurf = create_surf(tileset_full_tile_width(tileset),
+ tileset_full_tile_height(tileset), SDL_SWSURFACE);
+
+ struct canvas *destcanvas = canvas_create(tileset_full_tile_width(tileset),
+
tileset_full_tile_height(tileset));
- put_unit_pixmap_draw(pUnit, pSurf, 0, 3);
+ put_unit(pUnit, destcanvas, 0, 0);
+ SDL_BlitSurface(destcanvas->surf, NULL, pSurf, NULL);
+
+ canvas_free(destcanvas);
if (pSurf->w > 64) {
float zoom = 64.0 / pSurf->w;
@@ -648,8 +670,8 @@
}
if (support) {
- i = pUnit->upkeep + pUnit->upkeep_food +
- pUnit->upkeep_gold + pUnit->unhappiness;
+ i = pUnit->upkeep[O_SHIELD] + pUnit->upkeep[O_FOOD] +
+ pUnit->upkeep[O_GOLD] + pUnit->unhappiness;
if (i * pIcons->pFood->w > pSurf->w / 2) {
step = (pSurf->w / 2 - pIcons->pFood->w) / (i - 1);
@@ -660,17 +682,17 @@
dest.y = pSurf->h - pIcons->pFood->h - 2;
dest.x = pSurf->w / 8;
- for (i = 0; i < pUnit->upkeep; i++) {
+ for (i = 0; i < pUnit->upkeep[O_SHIELD]; i++) {
SDL_BlitSurface(pIcons->pShield, NULL, pSurf, &dest);
dest.x += step;
}
- for (i = 0; i < pUnit->upkeep_food; i++) {
+ for (i = 0; i < pUnit->upkeep[O_FOOD]; i++) {
SDL_BlitSurface(pIcons->pFood, NULL, pSurf, &dest);
dest.x += step;
}
- for (i = 0; i < pUnit->upkeep_gold; i++) {
+ for (i = 0; i < pUnit->upkeep[O_GOLD]; i++) {
SDL_BlitSurface(pIcons->pCoin, NULL, pSurf, &dest);
dest.x += step;
}
@@ -707,9 +729,9 @@
i = 0;
- unit_list_iterate(*pList, pUnit) {
+ unit_list_iterate(pList, pUnit) {
- pUType = get_unit_type(pUnit->type);
+ pUType = pUnit->type;
pHome_City = find_city_by_id(pUnit->homecity);
my_snprintf(cBuf, sizeof(cBuf), "%s (%d,%d,%d)%s\n%s\n(%d/%d)\n%s",
pUType->name, pUType->attack_strength,
@@ -720,17 +742,19 @@
pHome_City ? pHome_City->name : _("None"));
if (pCityDlg->state == SUPPORTED_UNITS_PAGE) {
- int pcity_near_dist;
- struct city *pNear_City = get_nearest_city(pUnit, &pcity_near_dist);
+ int pCity_near_dist;
+ struct city *pNear_City = get_nearest_city(pUnit, &pCity_near_dist);
sz_strlcat(cBuf, "\n");
- sz_strlcat(cBuf, get_nearest_city_text(pNear_City, pcity_near_dist));
- pSurf = create_unit_surface(pUnit, 1);
+ sz_strlcat(cBuf, get_nearest_city_text(pNear_City, pCity_near_dist));
+ pSurf = adj_surf(create_unit_surface(pUnit, 1));
+ SDL_SetColorKey(pSurf, SDL_SRCCOLORKEY, 0);
} else {
- pSurf = create_unit_surface(pUnit, 0);
+ pSurf = adj_surf(create_unit_surface(pUnit, 0));
+ SDL_SetColorKey(pSurf, SDL_SRCCOLORKEY, 0);
}
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pBuf = create_icon2(pSurf, pWindow->dst,
@@ -748,7 +772,7 @@
set_wflag(pBuf, WF_HIDDEN);
}
- if (pCityDlg->pCity->owner == game.player_idx) {
+ if (pCityDlg->pCity->owner == game.player_ptr) {
set_wstate(pBuf, FC_WS_NORMAL);
}
@@ -764,8 +788,8 @@
pCityDlg->pPanel->pActiveWidgetList = pEnd;
setup_vertical_widgets_position(NUM_UNITS_SHOWN,
- pWindow->size.x + 7,
- pWindow->size.y + WINDOW_TILE_HIGH + 40,
+ pWindow->size.x + adj_size(7),
+ pWindow->size.y + WINDOW_TILE_HIGH + adj_size(40),
0, 0, pCityDlg->pPanel->pBeginActiveWidgetList,
pCityDlg->pPanel->pEndActiveWidgetList);
@@ -781,15 +805,15 @@
/* create up button */
pBuf = pCityDlg->pPanel->pScroll->pUp_Left_Button;
- pBuf->size.x = pWindow->size.x + 6;
- pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 20;
- pBuf->size.w = 103;
+ pBuf->size.x = pWindow->size.x + adj_size(6);
+ pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(20);
+ pBuf->size.w = adj_size(103);
/* create down button */
pBuf = pCityDlg->pPanel->pScroll->pDown_Right_Button;
- pBuf->size.x = pWindow->size.x + 6 + 104;
- pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 20;
- pBuf->size.w = 103;
+ pBuf->size.x = pWindow->size.x + adj_size(6) + adj_size(104);
+ pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(20);
+ pBuf->size.w = adj_size(103);
}
@@ -889,49 +913,53 @@
**************************************************************************/
static int misc_panel_city_dlg_callback(struct GUI *pWidget)
{
- int new = pCityDlg->pCity->city_options & 0xff;
+/* int new = pCityDlg->pCity->city_options & 0xff; */
+ bv_city_options new_options = pCityDlg->pCity->city_options;
switch (MAX_ID - pWidget->ID) {
- case 0x01:
- new ^= 0x01;
- break;
- case 0x02:
- new ^= 0x02;
- break;
- case 0x04:
- new ^= 0x04;
- break;
- case 0x08:
- new ^= 0x08;
- break;
case 0x10:
- new ^= 0x10;
+ if (BV_ISSET(new_options, CITYO_DISBAND))
+ BV_CLR(new_options, CITYO_DISBAND);
+ else
+ BV_SET(new_options, CITYO_DISBAND);
break;
case 0x20:
- new ^= 0x20;
- new ^= 0x40;
- pWidget->gfx = get_citizen_surface(CITIZEN_TAXMAN, 0);
+ if (BV_ISSET(new_options, CITYO_NEW_EINSTEIN))
+ BV_CLR(new_options, CITYO_NEW_EINSTEIN);
+ else
+ BV_SET(new_options, CITYO_NEW_EINSTEIN);
+
+ if (BV_ISSET(new_options, CITYO_NEW_TAXMAN))
+ BV_CLR(new_options, CITYO_NEW_TAXMAN);
+ else
+ BV_SET(new_options, CITYO_NEW_TAXMAN);
+
+ pWidget->gfx = adj_surf(GET_SURF(get_tax_sprite(tileset, O_GOLD)));
pWidget->ID = MAX_ID - 0x40;
redraw_ibutton(pWidget);
flush_rect(pWidget->size);
break;
case 0x40:
- new &= 0x1f;
- pWidget->gfx = get_citizen_surface(CITIZEN_ELVIS, 0);
+ BV_CLR(new_options, CITYO_NEW_EINSTEIN);
+ BV_CLR(new_options, CITYO_NEW_TAXMAN);
+ pWidget->gfx = adj_surf(GET_SURF(get_tax_sprite(tileset, O_LUXURY)));
pWidget->ID = MAX_ID - 0x60;
redraw_ibutton(pWidget);
flush_rect(pWidget->size);
break;
case 0x60:
- new |= 0x20;
- pWidget->gfx = get_citizen_surface(CITIZEN_SCIENTIST, 0);
+ if (BV_ISSET(new_options, CITYO_NEW_EINSTEIN))
+ BV_CLR(new_options, CITYO_NEW_EINSTEIN);
+ else
+ BV_SET(new_options, CITYO_NEW_EINSTEIN);
+ pWidget->gfx = adj_surf(GET_SURF(get_tax_sprite(tileset, O_SCIENCE)));
pWidget->ID = MAX_ID - 0x20;
redraw_ibutton(pWidget);
flush_rect(pWidget->size);
break;
}
- dsend_packet_city_options_req(&aconnection, pCityDlg->pCity->id, new);
+ dsend_packet_city_options_req(&aconnection, pCityDlg->pCity->id,
new_options);
return -1;
}
@@ -946,111 +974,58 @@
SDL_String16 *pStr;
char cBuf[80];
- my_snprintf(cBuf, sizeof(cBuf), "%s\n%s" , _("Auto attack vs"), _("land
units"));
- pStr = create_str16_from_char(cBuf, 10);
- pStr->fgcol = *get_game_colorRGB(COLOR_STD_WHITE);
- pStr->style |= TTF_STYLE_BOLD;
- pBuf =
- create_textcheckbox(pWindow->dst, pCity->city_options & 0x01, pStr,
- WF_DRAW_THEME_TRANSPARENT);
- pBuf->size.x = pWindow->size.x + 10;
- pBuf->size.y = pWindow->size.y + 40;
- set_wstate(pBuf, FC_WS_NORMAL);
- pBuf->action = misc_panel_city_dlg_callback;
- add_to_gui_list(MAX_ID - 1, pBuf);
- pCityDlg->pPanel = MALLOC(sizeof(struct ADVANCED_DLG));
- pCityDlg->pPanel->pEndWidgetList = pBuf;
- /* ---- */
-
- my_snprintf(cBuf, sizeof(cBuf), "%s\n%s" , _("Auto attack vs"), _("sea
units"));
- pStr = create_str16_from_char(cBuf, 10);
+ my_snprintf(cBuf, sizeof(cBuf),
+ _("Disband if build\nsettler at size 1"));
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
- pStr->fgcol = *get_game_colorRGB(COLOR_STD_WHITE);
- pBuf =
- create_textcheckbox(pWindow->dst, pCity->city_options & 0x02, pStr,
- WF_DRAW_THEME_TRANSPARENT);
- set_wstate(pBuf, FC_WS_NORMAL);
- pBuf->action = misc_panel_city_dlg_callback;
- add_to_gui_list(MAX_ID - 2, pBuf);
- pBuf->size.x = pBuf->next->size.x;
- pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h;
- /* ----- */
+ pStr->fgcol = (SDL_Color){255, 255, 255, 255};
- my_snprintf(cBuf, sizeof(cBuf), "%s\n%s" , _("Auto attack vs"), _("heli
units"));
- pStr = create_str16_from_char(cBuf, 10);
- pStr->style |= TTF_STYLE_BOLD;
- pStr->fgcol = *get_game_colorRGB(COLOR_STD_WHITE);
pBuf =
- create_textcheckbox(pWindow->dst, pCity->city_options & 0x04, pStr,
+ create_textcheckbox(pWindow->dst, BV_ISSET(pCity->city_options,
CITYO_DISBAND), pStr,
WF_DRAW_THEME_TRANSPARENT);
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = misc_panel_city_dlg_callback;
- add_to_gui_list(MAX_ID - 4, pBuf);
- pBuf->size.x = pBuf->next->size.x;
- pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h;
- /* ----- */
-
- my_snprintf(cBuf, sizeof(cBuf), "%s\n%s" , _("Auto attack vs"), _("air
units"));
- pStr = create_str16_from_char(cBuf, 10);
- pStr->style |= TTF_STYLE_BOLD;
- pStr->fgcol = *get_game_colorRGB(COLOR_STD_WHITE);
+ add_to_gui_list(MAX_ID - 0x10, pBuf);
+ pBuf->size.x = pWindow->size.x + adj_size(10);
+ pBuf->size.y = pWindow->size.y + adj_size(40);
- pBuf =
- create_textcheckbox(pWindow->dst, pCity->city_options & 0x08, pStr,
- WF_DRAW_THEME_TRANSPARENT);
- set_wstate(pBuf, FC_WS_NORMAL);
- pBuf->action = misc_panel_city_dlg_callback;
- add_to_gui_list(MAX_ID - 8, pBuf);
- pBuf->size.x = pBuf->next->size.x;
- pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h;
/* ----- */
- my_snprintf(cBuf, sizeof(cBuf),
- _("Disband if build\nsettler at size 1"));
- pStr = create_str16_from_char(cBuf, 10);
- pStr->style |= TTF_STYLE_BOLD;
- pStr->fgcol = *get_game_colorRGB(COLOR_STD_WHITE);
+ pCityDlg->pPanel = MALLOC(sizeof(struct ADVANCED_DLG));
+ pCityDlg->pPanel->pEndWidgetList = pBuf;
- pBuf =
- create_textcheckbox(pWindow->dst, pCity->city_options & 0x10, pStr,
- WF_DRAW_THEME_TRANSPARENT);
- set_wstate(pBuf, FC_WS_NORMAL);
- pBuf->action = misc_panel_city_dlg_callback;
- add_to_gui_list(MAX_ID - 0x10, pBuf);
- pBuf->size.x = pBuf->next->size.x;
- pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h;
/* ----- */
my_snprintf(cBuf, sizeof(cBuf), "%s :", _("New citizens are"));
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
- change_ptsize16(pStr, 13);
+ change_ptsize16(pStr, adj_font(13));
- if (pCity->city_options & 0x20) {
- pSurf = get_citizen_surface(CITIZEN_SCIENTIST, 0);
+ if (BV_ISSET(pCity->city_options, CITYO_NEW_EINSTEIN)) {
+ pSurf = adj_surf(GET_SURF(get_tax_sprite(tileset, O_SCIENCE)));
pBuf = create_icon_button(pSurf, pWindow->dst, pStr, WF_ICON_CENTER_RIGHT);
add_to_gui_list(MAX_ID - 0x20, pBuf);
} else {
- if (pCity->city_options & 0x40) {
- pSurf = get_citizen_surface(CITIZEN_TAXMAN, 0);
+ if (BV_ISSET(pCity->city_options, CITYO_NEW_TAXMAN)) {
+ pSurf = adj_surf(GET_SURF(get_tax_sprite(tileset, O_GOLD)));
pBuf = create_icon_button(pSurf, pWindow->dst,
pStr, WF_ICON_CENTER_RIGHT);
add_to_gui_list(MAX_ID - 0x40, pBuf);
} else {
- pSurf = get_citizen_surface(CITIZEN_ELVIS, 0);
+ pSurf = adj_surf(GET_SURF(get_tax_sprite(tileset, O_LUXURY)));
pBuf = create_icon_button(pSurf, pWindow->dst,
pStr, WF_ICON_CENTER_RIGHT);
add_to_gui_list(MAX_ID - 0x60, pBuf);
}
}
- pBuf->size.w = 199;
+ pBuf->size.w = adj_size(199);
pBuf->action = misc_panel_city_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
pBuf->size.x = pBuf->next->size.x;
- pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + 5;
+ pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + adj_size(5);
pCityDlg->pPanel->pBeginWidgetList = pBuf;
}
@@ -1218,7 +1193,7 @@
}
hh = WINDOW_TILE_HIGH + 2;
- pStr = create_str16_from_char(_("Buy It?"), 12);
+ pStr = create_str16_from_char(_("Buy It?"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
pWindow = create_window(pDest, pStr, 100, 100, 0);
pWindow->action = hurry_production_window_callback;
@@ -1229,7 +1204,7 @@
/* ============================================================= */
/* label */
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pStr->fgcol.r = 255;
pStr->fgcol.g = 255;
@@ -1241,7 +1216,7 @@
hh += pText->h + 5;
pBuf = create_themeicon_button_from_chars(pTheme->CANCEL_Icon,
- pWindow->dst, _("No"), 12, 0);
+ pWindow->dst, _("No"), adj_font(12), 0);
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
pBuf->action = cancel_buy_prod_city_dlg_callback;
@@ -1253,7 +1228,7 @@
if (!pCity->did_buy && game.player_ptr->economic.gold >= value) {
pBuf = create_themeicon_button_from_chars(pTheme->OK_Icon, pWindow->dst,
- _("Yes"), 12, 0);
+ _("Yes"), adj_font(12), 0);
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
pBuf->action = ok_buy_prod_city_dlg_callback;
@@ -1300,7 +1275,8 @@
}
} else {
put_window_near_map_tile(pWindow,
- ww + DOUBLE_FRAME_WH, hh + FRAME_WH + 5, pCity->x , pCity->y);
+ ww + DOUBLE_FRAME_WH, hh + FRAME_WH + 5,
+ pCity->tile);
}
}
@@ -1426,7 +1402,7 @@
/* create ok button */
pOK_Button = create_themeicon_button_from_chars(
- pTheme->Small_OK_Icon, pImpr->dst, _("Sell"), 10, 0);
+ pTheme->Small_OK_Icon, pImpr->dst, _("Sell"), adj_font(10), 0);
pOK_Button->data.ptr = (void *)pLabel;
clear_wflag(pOK_Button, WF_DRAW_FRAME_AROUND_WIDGET);
@@ -1434,7 +1410,7 @@
/* create cancel button */
pCancel_Button =
create_themeicon_button_from_chars(pTheme->Small_CANCEL_Icon,
- pImpr->dst, _("Cancel"), 10, 0);
+ pImpr->dst, _("Cancel"), adj_font(10), 0);
clear_wflag(pCancel_Button, WF_DRAW_FRAME_AROUND_WIDGET);
@@ -1446,7 +1422,7 @@
/* create text label */
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pStr->fgcol.r = 255;
pStr->fgcol.g = 255;
@@ -1454,7 +1430,7 @@
pLabel = create_iconlabel(NULL, pImpr->dst, pStr, 0);
/* create window */
- pStr = create_str16_from_char(_("Sell It?"), 12);
+ pStr = create_str16_from_char(_("Sell It?"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
/* correct sizes */
@@ -1551,7 +1527,7 @@
struct GUI *pTmpWidget = pCityDlg->pImprv->pEndActiveWidgetList;
while (TRUE) {
- if (get_improvement_type(MAX_ID - 3000 - pTmpWidget->ID)->is_wonder) {
+ if (is_wonder(MAX_ID - 3000 - pTmpWidget->ID)) {
set_wstate(pTmpWidget, FC_WS_DISABLED);
} else {
set_wstate(pTmpWidget, FC_WS_NORMAL);
@@ -1606,126 +1582,23 @@
}
/* ======================================================================== */
-//#define NO_ISO
-
-#ifdef NO_ISO
-/**************************************************************************
-This converts a city coordinate position to citymap canvas coordinates
-(either isometric or overhead). It should be in cityview.c instead.
-**************************************************************************/
-static bool sdl_city_to_canvas_pos(int *canvas_x, int *canvas_y, int city_x,
int city_y)
-{
- if (tileset_is_isometric(tileset)) {
- /*
- * The top-left corner is in the center of tile (-2, 2). However,
- * we're looking for the top-left corner of the tile, so we
- * subtract off half a tile in each direction. For a more
- * rigorous example, see map_pos_to_canvas_pos().
- */
- int iso_x = (city_x - city_y) - (-4);
- int iso_y = (city_x + city_y) - (0);
-
- *canvas_x = (iso_x - 1) * SCALLED_TILE_WIDTH / 2;
- *canvas_y = (iso_y - 1) * SCALLED_TILE_HEIGHT / 2;
- } else {
- *canvas_x = city_x * SCALLED_TILE_WIDTH;
- *canvas_y = city_y * SCALLED_TILE_HEIGHT;
- }
-
- if (!is_valid_city_coords(city_x, city_y)) {
- assert(FALSE);
- return FALSE;
- }
- return TRUE;
-}
-
/**************************************************************************
-This converts a citymap canvas position to a city coordinate position
-(either isometric or overhead). It should be in cityview.c instead.
-**************************************************************************/
-static bool sdl_canvas_to_city_pos(int *city_x, int *city_y, int canvas_x, int
canvas_y)
-{
- int orig_canvas_x = canvas_x, orig_canvas_y = canvas_y;
-
- if (tileset_is_isometric(tileset)) {
- const int W = SCALLED_TILE_WIDTH, H = SCALLED_TILE_HEIGHT;
-
- /* Shift the tile right so the top corner of tile (-2,2) is at
- canvas position (0,0). */
- canvas_y += H / 2;
-
- /* Perform a pi/4 rotation, with scaling. See canvas_pos_to_map_pos
- for a full explanation. */
- *city_x = DIVIDE(canvas_x * H + canvas_y * W, W * H);
- *city_y = DIVIDE(canvas_y * W - canvas_x * H, W * H);
-
- /* Add on the offset of the top-left corner to get the final
- * coordinates (like in canvas_to_map_pos). */
- *city_x -= 2;
- *city_y += 2;
- } else {
- *city_x = canvas_x / SCALLED_TILE_WIDTH;
- *city_y = canvas_y / SCALLED_TILE_HEIGHT;
- }
- freelog(LOG_DEBUG, "canvas_to_city_pos(pos=(%d,%d))=(%d,%d)",
- orig_canvas_x, orig_canvas_y, *city_x, *city_y);
-
- return is_valid_city_coords(*city_x, *city_y);
-}
-#else
-
-/**************************************************************************
- city resource map: calculate screen position to city map position.
-
- col = ( map_x - X0 ) / W + ( map_y - Y0 ) / H;
- row = ( map_y - Y0 ) / H - ( map_x - X0 ) / W;
-
- map_x = mouse_x_pos_on_screen - resource_map_x_pos_on_screen;
- map_y = mouse_y_pos_on_screen - resource_map_y_pos_on_screen;
- W - resource_tile_width (zoomed) = 48;
- H - resource_tile_hight (zoomed) = 24;
- X0 - x_pos of first tile (0,0) + W / 2 on resource map = 1.5 * W + W / 2 =
72;
- Y0 - y_pos of first tile (0,0) resource map = 0;
+ ...
**************************************************************************/
-static bool get_citymap_cr(Sint16 map_x, Sint16 map_y, int *pCol, int *pRow)
-{
- float a = (float) (map_x) / SCALLED_TILE_WIDTH;
- float b = (float) (map_y) / SCALLED_TILE_HEIGHT;
- /* 2.0 come from 2 * SCALLED_TILE_WIDTH in "a"
- parm ( map_x - 2 * SCALLED_TILE_WIDTH ) */
- float result = a + b - 2.0;
- if (result < 0) {
- /* correct negative numbers in (0 ... -1) to show as -1 tile (and more) */
- *pCol = (result - 1.0);
- } else {
- *pCol = result;
- }
-
- result = (b - a) + 2.0;
- if (result < 0) {
- /* correct negative numbers in (0 ... -1) to show as -1 tile (and more) */
- *pRow = (result - 1.0);
- } else {
- *pRow = result;
- }
-
- freelog(LOG_DEBUG, "get_citymap_cr(pos=(%d,%d))=(%d,%d)",
- map_x, map_y, *pCol, *pRow);
-
- return is_valid_city_coords(*pCol, *pRow);
-}
-#endif
-
SDL_Surface * get_scaled_city_map(struct city *pCity)
{
SDL_Surface *pBuf = create_city_map(pCity);
- if (pBuf->w > 192 || pBuf->h > 134)
+ if (pBuf->w > adj_size(192) || pBuf->h > adj_size(134))
{
- float zoom = (pBuf->w > 192 ? 192.0 / pBuf->w : 134.0 / pBuf->h);
- SDL_Surface *pRet = ZoomSurface(pBuf, zoom, zoom, 1);
- FREESURFACE(pBuf);
+ city_map_zoom = (pBuf->w > adj_size(192) ?
+ (float)adj_size(192) / adj_size(pBuf->w)
+ : (float)adj_size(134) / adj_size(pBuf->h));
+
+ SDL_Surface *pRet = ZoomSurface(pBuf, city_map_zoom, city_map_zoom, 1);
+/* FREESURFACE(pBuf);*/
return pRet;
}
+
return pBuf;
}
@@ -1735,159 +1608,15 @@
static int resource_map_city_dlg_callback(struct GUI *pMap)
{
int col, row;
-#ifndef NO_ISO
- if (get_citymap_cr(Main.event.motion.x - pMap->size.x,
- Main.event.motion.y - pMap->size.y, &col, &row)) {
- city_toggle_worker(pCityDlg->pCity, col, row);
- }
-#else
- if (sdl_canvas_to_city_pos(&col, &row, Main.event.motion.x - pMap->size.x,
- Main.event.motion.y - pMap->size.y)) {
-
- city_toggle_worker(pCityDlg->pCity, col, row);
- }
-#endif
- return -1;
-}
-
-/**************************************************************************
- ...
-**************************************************************************/
-static void fill_tile_resorce_surf(SDL_Surface * pTile,
- const struct city *pCity,
- Uint16 city_col, Uint16 city_row)
-{
- int i, step;
- SDL_Rect dest;
- int food = city_get_food_tile(city_col, city_row, pCity);
- int shield = city_get_shields_tile(city_col, city_row, pCity);
- int trade = city_get_trade_tile(city_col, city_row, pCity);
-
- step = food + shield + trade;
- if(step) {
- dest.y = (SCALLED_TILE_HEIGHT - pIcons->pFood->h) / 2;
- dest.x = 10;
- step = (SCALLED_TILE_WIDTH - 2 * dest.x) / step;
-
-
- for (i = 0; i < food; i++) {
- SDL_BlitSurface(pIcons->pFood, NULL, pTile, &dest);
- dest.x += step;
- }
-
- for (i = 0; i < shield; i++) {
- SDL_BlitSurface(pIcons->pShield, NULL, pTile, &dest);
- dest.x += step;
- }
-
- for (i = 0; i < trade; i++) {
- SDL_BlitSurface(pIcons->pTrade, NULL, pTile, &dest);
- dest.x += step;
- }
- } else {
- dest.x = (SCALLED_TILE_WIDTH - pIcons->pFace->w) / 2;
- dest.y = (SCALLED_TILE_HEIGHT - pIcons->pFace->h) / 2;
- SDL_BlitSurface(pIcons->pFace, NULL, pTile, &dest);
- }
-}
-
-/**************************************************************************
- Refresh (update) the city resource map
-**************************************************************************/
-void refresh_city_resource_map(SDL_Surface *pDest, int x, int y,
- const struct city *pCity,
- bool (*worker_check) (const struct city *,
- int, int))
-{
-#ifndef NO_ISO
- register int col, row;
- SDL_Rect dest;
- int sx, sy, row0, real_col = pCity->x, real_row = pCity->y;
- int x0 = x + SCALLED_TILE_WIDTH + SCALLED_TILE_WIDTH / 2;
- int y0 = y;
-
- SDL_Surface *pTile = create_surf(SCALLED_TILE_WIDTH,
- SCALLED_TILE_HEIGHT, SDL_SWSURFACE);
-
- SDL_SetColorKey(pTile, SDL_SRCCOLORKEY, 0x0);
-
- real_col -= 2;
- real_row -= 2;
- correction_map_pos((int *) &real_col, (int *) &real_row);
- row0 = real_row;
- /* draw loop */
- for (col = 0; col < CITY_MAP_SIZE; col++) {
- for (row = 0; row < CITY_MAP_SIZE; row++) {
- /* calculate start pixel position and check if it belong to 'pDest' */
- sx = x0 + (col - row) * (SCALLED_TILE_WIDTH / 2);
- sy = y0 + (row + col) * (SCALLED_TILE_HEIGHT / 2);
+ if (canvas_to_city_pos(&col, &row,
+ 1/city_map_zoom * (Main.event.motion.x - pMap->size.x),
+ 1/city_map_zoom * (Main.event.motion.y - pMap->size.y))) {
- if (!((!col && !row) ||
- (!col && (row == CITY_MAP_SIZE - 1)) ||
- (!row && (col == CITY_MAP_SIZE - 1)) ||
- ((col == CITY_MAP_SIZE - 1) && (row == CITY_MAP_SIZE - 1))
- )
- ) {
- dest.x = sx;
- dest.y = sy;
- if (worker_check(pCity, col, row)) {
- fill_tile_resorce_surf(pTile, pCity, col, row);
- SDL_BlitSurface(pTile, NULL, pDest, &dest);
- /* clear pTile */
- SDL_FillRect(pTile, NULL, 0x0);
- }
- }
-
- /* inc row with correct */
- if (++real_row >= map.ysize) {
- real_row = 0;
- }
-
- }
- real_row = row0;
- /* inc col with correct */
- if (++real_col >= map.xsize) {
- real_col = 0;
- }
-
- }
-
- FREESURFACE(pTile);
-#else
-
- int city_x, city_y;
- int map_x, map_y, canvas_x, canvas_y;
- SDL_Rect dest;
- SDL_Surface *pTile = create_surf(SCALLED_TILE_WIDTH,
- SCALLED_TILE_HEIGHT, SDL_SWSURFACE);
-
- /* We have to draw the tiles in a particular order, so its best
- to avoid using any iterator macro. */
- for (city_x = 0; city_x<CITY_MAP_SIZE; city_x++)
- {
- for (city_y = 0; city_y<CITY_MAP_SIZE; city_y++)
- {
- if (is_valid_city_coords(city_x, city_y)
- && city_map_to_map(&map_x, &map_y, pCity, city_x, city_y)
- && client_tile_get_known(map_x, map_y)
- && sdl_city_to_canvas_pos(&canvas_x, &canvas_y, city_x, city_y))
- {
- dest.x = canvas_x;
- dest.y = canvas_y;
- if (worker_check(pCity, map_x, map_y))
- {
- fill_tile_resorce_surf(pTile, pCity, map_x, map_y);
- SDL_BlitSurface(pTile, NULL, pDest, &dest);
- /* clear pTile */
- SDL_FillRect(pTile, NULL, 0x0);
- }
- }
- }
+ city_toggle_worker(pCityDlg->pCity, col, row);
}
- FREESURFACE(pTile);
-#endif
+ return -1;
}
/* ====================================================================== */
@@ -1897,10 +1626,10 @@
*************************************************************************/
static int city_comp_by_turn_founded(const void *a, const void *b)
{
- struct city *pcity1 = *((struct city **) a);
- struct city *pcity2 = *((struct city **) b);
+ struct city *pCity1 = *((struct city **) a);
+ struct city *pCity2 = *((struct city **) b);
- return pcity1->turn_founded - pcity2->turn_founded;
+ return pCity1->turn_founded - pCity2->turn_founded;
}
/**************************************************************************
@@ -1909,11 +1638,11 @@
static int next_prev_city_dlg_callback(struct GUI *pButton)
{
int i, dir, non_open_size, size =
- city_list_size(&game.player_ptr->cities);
+ city_list_size(game.player_ptr->cities);
struct city **array;
assert(size >= 1);
- assert(pCityDlg->pCity->owner == game.player_idx);
+ assert(pCityDlg->pCity->owner == game.player_ptr);
if (size == 1) {
return -1;
@@ -1935,7 +1664,7 @@
non_open_size = 0;
for (i = 0; i < size; i++) {
- array[non_open_size++] = city_list_get(&game.player_ptr->cities, i);
+ array[non_open_size++] = city_list_get(game.player_ptr->cities, i);
}
assert(non_open_size > 0);
@@ -2028,7 +1757,7 @@
my_snprintf(cBuf, sizeof(cBuf), _("Options panel"));
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->fgcol.r = 238;
pStr->fgcol.g = 156;
pStr->fgcol.b = 7;
@@ -2036,8 +1765,8 @@
pSurf = create_text_surf_from_str16(pStr);
- dest.x = pCityWindow->size.x + 5 + (207 - pSurf->w) / 2;
- dest.y = pCityWindow->size.y + WINDOW_TILE_HIGH + 6;
+ dest.x = pCityWindow->size.x + adj_size(5) + (adj_size(207) - pSurf->w) / 2;
+ dest.y = pCityWindow->size.y + WINDOW_TILE_HIGH + adj_size(6);
SDL_BlitSurface(pSurf, NULL, pCityWindow->dst, &dest);
@@ -2065,10 +1794,10 @@
struct unit_list *pList;
int size;
- if (pCityDlg->pCity->owner != game.player_idx) {
- pList = &(pCityDlg->pCity->info_units_supported);
+ if (pCityDlg->pCity->owner != game.player_ptr) {
+ pList = (pCityDlg->pCity->info_units_supported);
} else {
- pList = &(pCityDlg->pCity->units_supported);
+ pList = (pCityDlg->pCity->units_supported);
}
size = unit_list_size(pList);
@@ -2076,7 +1805,7 @@
my_snprintf(cBuf, sizeof(cBuf), _("Unit maintenance panel (%d %s)"),
size, PL_("unit", "units", size));
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->fgcol.r = 238;
pStr->fgcol.g = 156;
pStr->fgcol.b = 7;
@@ -2084,8 +1813,8 @@
pSurf = create_text_surf_from_str16(pStr);
- dest.x = pCityWindow->size.x + 5 + (207 - pSurf->w) / 2;
- dest.y = pCityWindow->size.y + WINDOW_TILE_HIGH + 6;
+ dest.x = pCityWindow->size.x + adj_size(5) + (adj_size(207) - pSurf->w) / 2;
+ dest.y = pCityWindow->size.y + WINDOW_TILE_HIGH + adj_size(6);
SDL_BlitSurface(pSurf, NULL, pCityWindow->dst, &dest);
@@ -2126,10 +1855,10 @@
int size;
- if (pCityDlg->pCity->owner != game.player_idx) {
- pList = &(pCityDlg->pCity->info_units_present);
+ if (pCityDlg->pCity->owner != game.player_ptr) {
+ pList = pCityDlg->pCity->info_units_present;
} else {
- pList = &(map_get_tile(pCityDlg->pCity->x, pCityDlg->pCity->y)->units);
+ pList = pCityDlg->pCity->tile->units;
}
size = unit_list_size(pList);
@@ -2137,7 +1866,7 @@
my_snprintf(cBuf, sizeof(cBuf), _("Garrison Panel (%d %s)"),
size, PL_("unit", "units", size));
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->fgcol.r = 238;
pStr->fgcol.g = 156;
pStr->fgcol.b = 7;
@@ -2145,8 +1874,8 @@
pSurf = create_text_surf_from_str16(pStr);
- dest.x = pCityWindow->size.x + 5 + (207 - pSurf->w) / 2;
- dest.y = pCityWindow->size.y + WINDOW_TILE_HIGH + 6;
+ dest.x = pCityWindow->size.x + adj_size(5) + (adj_size(207) - pSurf->w) / 2;
+ dest.y = pCityWindow->size.y + WINDOW_TILE_HIGH + adj_size(6);
SDL_BlitSurface(pSurf, NULL, pCityWindow->dst, &dest);
@@ -2187,7 +1916,7 @@
SDL_Rect dest;
my_snprintf(cBuf, sizeof(cBuf), _("Info Panel"));
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->fgcol.r = 238;
pStr->fgcol.g = 156;
pStr->fgcol.b = 7;
@@ -2195,17 +1924,17 @@
pSurf = create_text_surf_from_str16(pStr);
- dest.x = pCityWindow->size.x + 5 + (207 - pSurf->w) / 2;
- dest.y = pCityWindow->size.y + WINDOW_TILE_HIGH + 6;
+ dest.x = pCityWindow->size.x + adj_size(5) + (adj_size(207) - pSurf->w) / 2;
+ dest.y = pCityWindow->size.y + WINDOW_TILE_HIGH + adj_size(6);
SDL_BlitSurface(pSurf, NULL, pCityWindow->dst, &dest);
- dest.x = pCityWindow->size.x + 10;
+ dest.x = pCityWindow->size.x + adj_size(10);
dest.y += pSurf->h + 1;
FREESURFACE(pSurf);
- change_ptsize16(pStr, 12);
+ change_ptsize16(pStr, adj_font(12));
pStr->fgcol.r = 220;
pStr->fgcol.g = 186;
pStr->fgcol.b = 60;
@@ -2220,12 +1949,12 @@
SDL_BlitSurface(pSurf, NULL, pCityWindow->dst, &dest);
- dest.y += pSurf->h + 3;
+ dest.y += pSurf->h + adj_size(3);
FREESURFACE(pSurf);
- if (((pIcons->pPollution->w + 1) * pCity->pollution) > 187) {
- step = (187 - pIcons->pPollution->w) / (pCity->pollution - 1);
+ if (((pIcons->pPollution->w + 1) * pCity->pollution) > adj_size(187)) {
+ step = (adj_size(187) - pIcons->pPollution->w) / (pCity->pollution - 1);
} else {
step = pIcons->pPollution->w + 1;
}
@@ -2235,8 +1964,8 @@
dest.x += step;
}
- dest.x = pCityWindow->size.x + 10;
- dest.y += pIcons->pPollution->h + 30;
+ dest.x = pCityWindow->size.x + adj_size(10);
+ dest.y += pIcons->pPollution->h + adj_size(30);
} else {
my_snprintf(cBuf, sizeof(cBuf), _("Pollution : none"));
@@ -2247,7 +1976,7 @@
SDL_BlitSurface(pSurf, NULL, pCityWindow->dst, &dest);
- dest.y += pSurf->h + 3;
+ dest.y += pSurf->h + adj_size(3);
FREESURFACE(pSurf);
}
@@ -2261,12 +1990,12 @@
SDL_BlitSurface(pSurf, NULL, pCityWindow->dst, &dest);
xx = dest.x + pSurf->w;
- dest.y += pSurf->h + 3;
+ dest.y += pSurf->h + adj_size(3);
FREESURFACE(pSurf);
step = 0;
- dest.x = pCityWindow->size.x + 10;
+ dest.x = pCityWindow->size.x + adj_size(10);
for (i = 0; i < NUM_TRADEROUTES; i++) {
if (pCity->trade[i]) {
@@ -2288,11 +2017,11 @@
SDL_BlitSurface(pSurf, NULL, pCityWindow->dst, &dest);
/* blit trade icon */
- dest.x += pSurf->w + 3;
- dest.y += 4;
+ dest.x += pSurf->w + adj_size(3);
+ dest.y += adj_size(4);
SDL_BlitSurface(pIcons->pTrade, NULL, pCityWindow->dst, &dest);
- dest.x = pCityWindow->size.x + 10;
- dest.y -= 4;
+ dest.x = pCityWindow->size.x + adj_size(10);
+ dest.y -= adj_size(4);
dest.y += pSurf->h;
@@ -2307,8 +2036,8 @@
pSurf = create_text_surf_from_str16(pStr);
SDL_BlitSurface(pSurf, NULL, pCityWindow->dst, &dest);
- dest.x += pSurf->w + 3;
- dest.y += 4;
+ dest.x += pSurf->w + adj_size(3);
+ dest.y += adj_size(4);
SDL_BlitSurface(pIcons->pTrade, NULL, pCityWindow->dst, &dest);
FREESURFACE(pSurf);
@@ -2320,7 +2049,7 @@
pSurf = create_text_surf_from_str16(pStr);
dest.x = xx;
- dest.y -= pSurf->h + 3;
+ dest.y -= pSurf->h + adj_size(3);
SDL_BlitSurface(pSurf, NULL, pCityWindow->dst, &dest);
FREESURFACE(pSurf);
@@ -2340,14 +2069,15 @@
{
char cBuf[30];
int step, i, j, count;
- SDL_Surface *pTmp1, *pTmp2, *pTmp3, *pTmp4;
+ SDL_Surface *pTmp;
SDL_String16 *pStr = NULL;
SDL_Surface *pSurf = NULL;
SDL_Rect dest;
+ struct effect_list *sources = effect_list_new();
my_snprintf(cBuf, sizeof(cBuf), _("Happiness panel"));
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->fgcol.r = 238;
pStr->fgcol.g = 156;
pStr->fgcol.b = 7;
@@ -2355,11 +2085,11 @@
pSurf = create_text_surf_from_str16(pStr);
- dest.x = pCityWindow->size.x + 5 + (207 - pSurf->w) / 2;
- dest.y = pCityWindow->size.y + WINDOW_TILE_HIGH + 6;
+ dest.x = pCityWindow->size.x + adj_size(5) + (adj_size(207) - pSurf->w) / 2;
+ dest.y = pCityWindow->size.y + WINDOW_TILE_HIGH + adj_size(6);
SDL_BlitSurface(pSurf, NULL, pCityWindow->dst, &dest);
- dest.x = pCityWindow->size.x + 10;
+ dest.x = pCityWindow->size.x + adj_size(10);
dest.y += pSurf->h + 1;
FREESURFACE(pSurf);
@@ -2370,8 +2100,8 @@
+ pCity->specialists[SP_ELVIS] + pCity->specialists[SP_SCIENTIST]
+ pCity->specialists[SP_TAXMAN]);
- if (count * pIcons->pMale_Happy->w > 180) {
- step = (180 - pIcons->pMale_Happy->w) / (count - 1);
+ if (count * pIcons->pMale_Happy->w > adj_size(180)) {
+ step = (adj_size(180) - pIcons->pMale_Happy->w) / (count - 1);
} else {
step = pIcons->pMale_Happy->w;
}
@@ -2383,9 +2113,9 @@
|| pCity->ppl_angry[j - 1] != pCity->ppl_angry[j]) {
if (j != 0) {
- putline(pCityWindow->dst, dest.x, dest.y, dest.x + 195,
+ putline(pCityWindow->dst, dest.x, dest.y, dest.x + adj_size(195),
dest.y, 0xff000000);
- dest.y += 5;
+ dest.y += adj_size(5);
}
if (pCity->ppl_happy[j]) {
@@ -2463,7 +2193,7 @@
if (j == 1) { /* luxury effect */
dest.x =
- pCityWindow->size.x + 212 - pIcons->pBIG_Luxury->w - 2;
+ pCityWindow->size.x + adj_size(212) - pIcons->pBIG_Luxury->w -
adj_size(2);
count = dest.y;
dest.y += (pIcons->pMale_Happy->h -
pIcons->pBIG_Luxury->h) / 2;
@@ -2475,6 +2205,46 @@
pSurf = NULL;
count = 0;
+ get_city_bonus_effects(sources, pCity, NULL, EFT_MAKE_CONTENT);
+
+ effect_list_iterate(sources, psource) {
+
+ pTmp = ZoomSurface(GET_SURF(get_building_sprite(tileset,
get_building_for_effect( psource->type))),
+ 0.5, 0.5, 1);
+ count += (pTmp->h + 1);
+
+ FREESURFACE(pTmp);
+
+ if (!pSurf) {
+ pSurf = ZoomSurface(GET_SURF(get_building_sprite(tileset,
get_building_for_effect(psource->type))),
+ 0.5, 0.5, 1);
+ }
+
+ } effect_list_iterate_end;
+
+ dest.x = pCityWindow->size.x + adj_size(212) - pSurf->w - adj_size(2);
+ i = dest.y;
+ dest.y += (pIcons->pMale_Happy->h - count) / 2;
+
+ FREESURFACE(pSurf);
+
+ effect_list_iterate(sources, psource) {
+
+ pTmp = ZoomSurface(GET_SURF(get_building_sprite(tileset,
get_building_for_effect( psource->type))),
+ 0.5, 0.5, 1);
+
+ SDL_BlitSurface(pTmp, NULL, pCityWindow->dst, &dest);
+ dest.y += (pTmp->h + 1);
+
+ FREESURFACE(pTmp);
+ } effect_list_iterate_end;
+
+ effect_list_unlink_all(sources);
+
+ dest.y = i;
+
+ /* TODO: check if code replacement above is correct */
+#if 0
if (city_got_building(pCity, B_TEMPLE)) {
pTmp1 =
ZoomSurface(GET_SURF(get_improvement_type(B_TEMPLE)->sprite),
@@ -2511,7 +2281,7 @@
}
- dest.x = pCityWindow->size.x + 212 - pSurf->w - 2;
+ dest.x = pCityWindow->size.x + adj_size(212) - pSurf->w - adj_size(2);
i = dest.y;
dest.y += (pIcons->pMale_Happy->h - count) / 2;
@@ -2536,10 +2306,11 @@
FREESURFACE(pTmp2);
FREESURFACE(pTmp3);
dest.y = i;
+#endif
}
if (j == 3) { /* police effect */
- dest.x = pCityWindow->size.x + 212 - pIcons->pPolice->w - 5;
+ dest.x = pCityWindow->size.x + adj_size(212) - pIcons->pPolice->w -
adj_size(5);
i = dest.y;
dest.y +=
(pIcons->pMale_Happy->h - pIcons->pPolice->h) / 2;
@@ -2550,6 +2321,113 @@
if (j == 4) { /* wonders effect */
count = 0;
+ get_city_bonus_effects(sources, pCity, NULL, EFT_MAKE_HAPPY);
+ effect_list_iterate(sources, psource) {
+
+ pTmp = ZoomSurface(GET_SURF(get_building_sprite(tileset,
get_building_for_effect( psource->type))),
+ 0.5, 0.5, 1);
+ count += (pTmp->h + 1);
+
+ FREESURFACE(pTmp);
+
+ if (!pSurf) {
+ pSurf = ZoomSurface(GET_SURF(get_building_sprite(tileset,
get_building_for_effect( psource->type))),
+ 0.5, 0.5, 1);
+ }
+
+ } effect_list_iterate_end;
+
+ effect_list_unlink_all(sources);
+
+ get_city_bonus_effects(sources, pCity, NULL, EFT_FORCE_CONTENT);
+
+ effect_list_iterate(sources, psource) {
+
+ pTmp = ZoomSurface(GET_SURF(get_building_sprite(tileset,
get_building_for_effect( psource->type))),
+ 0.5, 0.5, 1);
+ count += (pTmp->h + 1);
+
+ FREESURFACE(pTmp);
+
+ if (!pSurf) {
+ pSurf = ZoomSurface(GET_SURF(get_building_sprite(tileset,
get_building_for_effect( psource->type))),
+ 0.5, 0.5, 1);
+ }
+
+ } effect_list_iterate_end;
+
+ effect_list_unlink_all(sources);
+
+ get_city_bonus_effects(sources, pCity, NULL, EFT_NO_UNHAPPY);
+
+ effect_list_iterate(sources, psource) {
+
+ pTmp = ZoomSurface(
+ GET_SURF(get_building_sprite(tileset, get_building_for_effect(
psource->type))),
+ 0.5, 0.5, 1);
+
+ count += (pTmp->h + 1);
+
+ FREESURFACE(pTmp);
+
+ } effect_list_iterate_end;
+
+ effect_list_unlink_all(sources);
+
+
+ dest.x = pCityWindow->size.x + adj_size(212) - pSurf->w - adj_size(2);
+ i = dest.y;
+ dest.y += (pIcons->pMale_Happy->h - count) / 2;
+
+ FREESURFACE(pSurf);
+
+ get_city_bonus_effects(sources, pCity, NULL, EFT_MAKE_HAPPY);
+
+ effect_list_iterate(sources, psource) {
+
+ pTmp = ZoomSurface(GET_SURF(get_building_sprite(tileset,
get_building_for_effect( psource->type))),
+ 0.5, 0.5, 1);
+
+ SDL_BlitSurface(pTmp, NULL, pCityWindow->dst, &dest);
+ dest.y += (pTmp->h + 1);
+
+ FREESURFACE(pTmp);
+ } effect_list_iterate_end;
+ effect_list_unlink_all(sources);
+
+ get_city_bonus_effects(sources, pCity, NULL, EFT_FORCE_CONTENT);
+
+ effect_list_iterate(sources, psource) {
+
+ pTmp = ZoomSurface(
+ GET_SURF(get_building_sprite(tileset, get_building_for_effect(
psource->type))),
+ 0.5, 0.5, 1);
+
+ SDL_BlitSurface(pTmp, NULL, pCityWindow->dst, &dest);
+ dest.y += (pTmp->h + 1);
+
+ FREESURFACE(pTmp);
+ } effect_list_iterate_end;
+ effect_list_unlink_all(sources);
+
+ get_city_bonus_effects(sources, pCity, NULL, EFT_NO_UNHAPPY);
+
+ effect_list_iterate(sources, psource) {
+
+ pTmp = ZoomSurface(GET_SURF(get_building_sprite(tileset,
get_building_for_effect( psource->type))),
+ 0.5, 0.5, 1);
+
+ SDL_BlitSurface(pTmp, NULL, pCityWindow->dst, &dest);
+ dest.y += (pTmp->h + 1);
+
+ FREESURFACE(pTmp);
+ } effect_list_iterate_end;
+ effect_list_unlink_all(sources);
+
+ dest.y = i;
+
+ /* TODO: check if code replacement above is correct */
+#if 0
if (city_affected_by_wonder(pCity, B_CURE)) {
pTmp1 =
ZoomSurface(GET_SURF(get_improvement_type(B_CURE)->sprite),
@@ -2596,7 +2474,7 @@
pTmp4 = NULL;
}
- dest.x = pCityWindow->size.x + 212 - pSurf->w - 2;
+ dest.x = pCityWindow->size.x + adj_size(212) - pSurf->w - adj_size(2);
i = dest.y;
dest.y += (pIcons->pMale_Happy->h - count) / 2;
@@ -2626,13 +2504,16 @@
FREESURFACE(pTmp3);
FREESURFACE(pTmp4);
dest.y = i;
+#endif
}
- dest.x = pCityWindow->size.x + 10;
- dest.y += pIcons->pMale_Happy->h + 5;
+ dest.x = pCityWindow->size.x + adj_size(10);
+ dest.y += pIcons->pMale_Happy->h + adj_size(5);
}
}
+
+ effect_list_free(sources);
}
/**************************************************************************
@@ -2642,12 +2523,12 @@
{
char cBuf[40];
int i, step, count, limit;
- int cost = 0; /* FIXME: possibly uninitialized */
+ int cost = 0;
SDL_Rect dest, src;
struct GUI *pWindow = pCityDlg->pEndCityWidgetList;
SDL_Surface *pBuf = NULL;
SDL_String16 *pStr = NULL;
- SDL_Color color = *get_game_colorRGB(COLOR_STD_GROUND);
+ SDL_Color color = *get_game_colorRGB(COLOR_OVERVIEW_LAND);
color.unused = 64; /* 25% transparecy */
@@ -2674,23 +2555,21 @@
redraw_group(pCityDlg->pBeginCityWidgetList,
pCityDlg->pEndCityWidgetList, 0);
- /* is_worker_here(struct city *, int, int) - is function pointer */
- refresh_city_resource_map(pCityDlg->pResource_Map->dst,
- pCityDlg->pResource_Map->size.x,
- pCityDlg->pResource_Map->size.y,
- pCity, is_worker_here);
+ /* update resource map */
+ FREESURFACE(pCityDlg->pResource_Map->theme);
+ pCityDlg->pResource_Map->theme = get_scaled_city_map(pCity);
/* ================================================================= */
my_snprintf(cBuf, sizeof(cBuf), _("City map"));
- pStr = create_str16_from_char(cBuf, 11);
+ pStr = create_str16_from_char(cBuf, adj_font(11));
pStr->fgcol = *get_game_colorRGB(COLOR_STD_CITY_GOLD);
pStr->style |= TTF_STYLE_BOLD;
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 222 + (115 - pBuf->w) / 2;
- dest.y = pWindow->size.y + 69 + (15 - pBuf->h) / 2;
+ dest.x = pWindow->size.x + adj_size(222) + (adj_size(115) - pBuf->w) / 2;
+ dest.y = pWindow->size.y + adj_size(69) + (adj_size(15) - pBuf->h) / 2;
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
@@ -2703,8 +2582,8 @@
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 354 + (147 - pBuf->w) / 2;
- dest.y = pWindow->size.y + 67 + (13 - pBuf->h) / 2;
+ dest.x = pWindow->size.x + adj_size(354) + (adj_size(147) - pBuf->w) / 2;
+ dest.y = pWindow->size.y + adj_size(67) + (adj_size(13) - pBuf->h) / 2;
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
@@ -2717,8 +2596,8 @@
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 517 + (115 - pBuf->w) / 2;
- dest.y = pWindow->size.y + 69 + (15 - pBuf->h) / 2;
+ dest.x = pWindow->size.x + adj_size(517) + (adj_size(115) - pBuf->w) / 2;
+ dest.y = pWindow->size.y + adj_size(69) + (adj_size(15) - pBuf->h) / 2;
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
@@ -2729,29 +2608,30 @@
pCity->prod[O_FOOD]);
copy_chars_to_string16(pStr, cBuf);
- pStr->fgcol = *get_game_colorRGB(COLOR_STD_GROUND);
+
+ pStr->fgcol = *get_game_colorRGB(COLOR_OVERVIEW_LAND);
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 200;
- dest.y = pWindow->size.y + 228 + (16 - pBuf->h) / 2;
+ dest.x = pWindow->size.x + adj_size(200);
+ dest.y = pWindow->size.y + adj_size(228) + (adj_size(16) - pBuf->h) / 2;
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
FREESURFACE(pBuf);
/* draw food income */
- dest.y = pWindow->size.y + 246 + (16 - pIcons->pBIG_Food->h) / 2;
- dest.x = pWindow->size.x + 203;
+ dest.y = pWindow->size.y + adj_size(246) + (adj_size(16) -
pIcons->pBIG_Food->h) / 2;
+ dest.x = pWindow->size.x + adj_size(203);
- if (pCity->food_surplus >= 0) {
- count = pCity->prod[O_FOOD] - pCity->food_surplus;
+ if (pCity->surplus[O_FOOD] >= 0) {
+ count = pCity->prod[O_FOOD] - pCity->surplus[O_FOOD];
} else {
count = pCity->prod[O_FOOD];
}
- if (((pIcons->pBIG_Food->w + 1) * count) > 200) {
- step = (200 - pIcons->pBIG_Food->w) / (count - 1);
+ if (((pIcons->pBIG_Food->w + 1) * count) > adj_size(200)) {
+ step = (adj_size(200) - pIcons->pBIG_Food->w) / (count - 1);
} else {
step = pIcons->pBIG_Food->w + 1;
}
@@ -2762,38 +2642,38 @@
}
my_snprintf(cBuf, sizeof(cBuf), Q_("?food:Surplus : %d"),
- pCity->food_surplus);
+ pCity->surplus[O_FOOD]);
copy_chars_to_string16(pStr, cBuf);
pStr->fgcol = *get_game_colorRGB(COLOR_STD_CITY_FOOD_SURPLUS);
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 440 - pBuf->w;
- dest.y = pWindow->size.y + 228 + (16 - pBuf->h) / 2;
+ dest.x = pWindow->size.x + adj_size(440) - pBuf->w;
+ dest.y = pWindow->size.y + adj_size(228) + (adj_size(16) - pBuf->h) / 2;
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
FREESURFACE(pBuf);
/* draw surplus of food */
- if (pCity->food_surplus) {
+ if (pCity->surplus[O_FOOD]) {
- if (pCity->food_surplus > 0) {
- count = pCity->food_surplus;
+ if (pCity->surplus[O_FOOD] > 0) {
+ count = pCity->surplus[O_FOOD];
pBuf = pIcons->pBIG_Food;
} else {
- count = -1 * pCity->food_surplus;
+ count = -1 * pCity->surplus[O_FOOD];
pBuf = pIcons->pBIG_Food_Corr;
}
- dest.x = pWindow->size.x + 423;
- dest.y = pWindow->size.y + 246 + (16 - pBuf->h) / 2;
+ dest.x = pWindow->size.x + adj_size(423);
+ dest.y = pWindow->size.y + adj_size(246) + (adj_size(16) - pBuf->h) / 2;
/*if ( ((pBuf->w + 1) * count ) > 30 ) */
if (count > 2) {
if (count < 18) {
- step = (30 - pBuf->w) / (count - 1);
+ step = (adj_size(30) - pBuf->w) / (count - 1);
} else {
step = 1;
count = 17;
@@ -2810,7 +2690,7 @@
/* ================================================================= */
/* productions label */
my_snprintf(cBuf, sizeof(cBuf), _("Production : %d (%d) per turn"),
- pCity->shield_surplus ,
+ pCity->surplus[O_SHIELD] ,
pCity->prod[O_SHIELD] + pCity->waste[O_SHIELD]);
copy_chars_to_string16(pStr, cBuf);
@@ -2818,29 +2698,29 @@
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 200;
- dest.y = pWindow->size.y + 263 + (15 - pBuf->h) / 2;
+ dest.x = pWindow->size.x + adj_size(200);
+ dest.y = pWindow->size.y + adj_size(263) + (adj_size(15) - pBuf->h) / 2;
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
FREESURFACE(pBuf);
/* draw productions schields */
- if (pCity->shield_surplus) {
+ if (pCity->surplus[O_SHIELD]) {
- if (pCity->shield_surplus > 0) {
- count = pCity->shield_surplus + pCity->waste[O_SHIELD];
+ if (pCity->surplus[O_SHIELD] > 0) {
+ count = pCity->surplus[O_SHIELD] + pCity->waste[O_SHIELD];
pBuf = pIcons->pBIG_Shield;
} else {
- count = -1 * pCity->shield_surplus;
+ count = -1 * pCity->surplus[O_SHIELD];
pBuf = pIcons->pBIG_Shield_Corr;
}
- dest.y = pWindow->size.y + 281 + (16 - pBuf->h) / 2;
- dest.x = pWindow->size.x + 203;
+ dest.y = pWindow->size.y + adj_size(281) + (adj_size(16) - pBuf->h) / 2;
+ dest.x = pWindow->size.x + adj_size(203);
- if ((pBuf->w * count) > 200) {
- step = (200 - pBuf->w) / (count - 1);
+ if ((pBuf->w * count) > adj_size(200)) {
+ step = (adj_size(200) - pBuf->w) / (count - 1);
} else {
step = pBuf->w;
}
@@ -2848,7 +2728,7 @@
for (i = 0; i < count; i++) {
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
dest.x += step;
- if(i > pCity->shield_surplus) {
+ if(i > pCity->surplus[O_SHIELD]) {
pBuf = pIcons->pBIG_Shield_Corr;
}
}
@@ -2856,35 +2736,35 @@
/* support shields label */
my_snprintf(cBuf, sizeof(cBuf), Q_("?production:Support : %d"),
- pCity->prod[O_SHIELD] + pCity->waste[O_SHIELD] -
pCity->shield_surplus);
+ pCity->prod[O_SHIELD] + pCity->waste[O_SHIELD] -
pCity->surplus[O_SHIELD]);
copy_chars_to_string16(pStr, cBuf);
pStr->fgcol = *get_game_colorRGB(COLOR_STD_CITY_SUPPORT);
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 440 - pBuf->w;
- dest.y = pWindow->size.y + 263 + (15 - pBuf->h) / 2;
+ dest.x = pWindow->size.x + adj_size(440) - pBuf->w;
+ dest.y = pWindow->size.y + adj_size(263) + (adj_size(15) - pBuf->h) / 2;
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
FREESURFACE(pBuf);
/* draw support shields */
- if (pCity->prod[O_SHIELD] - pCity->shield_surplus) {
- dest.x = pWindow->size.x + 423;
+ if (pCity->prod[O_SHIELD] - pCity->surplus[O_SHIELD]) {
+ dest.x = pWindow->size.x + adj_size(423);
dest.y =
- pWindow->size.y + 281 + (16 - pIcons->pBIG_Shield->h) / 2;
+ pWindow->size.y + adj_size(281) + (adj_size(16) -
pIcons->pBIG_Shield->h) / 2;
if ((pIcons->pBIG_Shield->w + 1) * (pCity->prod[O_SHIELD] -
- pCity->shield_surplus) > 30) {
+ pCity->surplus[O_SHIELD]) >
adj_size(30)) {
step =
- (30 - pIcons->pBIG_Food->w) / (pCity->prod[O_SHIELD] -
- pCity->shield_surplus - 1);
+ (adj_size(30) - pIcons->pBIG_Food->w) / (pCity->prod[O_SHIELD] -
+ pCity->surplus[O_SHIELD] - 1);
} else {
step = pIcons->pBIG_Shield->w + 1;
}
- for (i = 0; i < (pCity->prod[O_SHIELD] - pCity->shield_surplus); i++) {
+ for (i = 0; i < (pCity->prod[O_SHIELD] - pCity->surplus[O_SHIELD]); i++) {
SDL_BlitSurface(pIcons->pBIG_Shield, NULL, pWindow->dst, &dest);
dest.x -= step;
}
@@ -2893,33 +2773,33 @@
/* trade label */
my_snprintf(cBuf, sizeof(cBuf), _("Trade : %d per turn"),
- pCity->trade_prod);
+ pCity->surplus[O_TRADE]);
copy_chars_to_string16(pStr, cBuf);
pStr->fgcol = *get_game_colorRGB(COLOR_STD_CITY_TRADE);
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 200;
- dest.y = pWindow->size.y + 298 + (15 - pBuf->h) / 2;
+ dest.x = pWindow->size.x + adj_size(200);
+ dest.y = pWindow->size.y + adj_size(298) + (adj_size(15) - pBuf->h) / 2;
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
FREESURFACE(pBuf);
/* draw total (trade - corruption) */
- if (pCity->trade_prod) {
+ if (pCity->surplus[O_TRADE]) {
dest.y =
- pWindow->size.y + 316 + (16 - pIcons->pBIG_Trade->h) / 2;
- dest.x = pWindow->size.x + 203;
+ pWindow->size.y + adj_size(316) + (adj_size(16) -
pIcons->pBIG_Trade->h) / 2;
+ dest.x = pWindow->size.x + adj_size(203);
- if (((pIcons->pBIG_Trade->w + 1) * pCity->trade_prod) > 200) {
- step = (200 - pIcons->pBIG_Trade->w) / (pCity->trade_prod - 1);
+ if (((pIcons->pBIG_Trade->w + 1) * pCity->surplus[O_TRADE]) >
adj_size(200)) {
+ step = (adj_size(200) - pIcons->pBIG_Trade->w) /
(pCity->surplus[O_TRADE] - 1);
} else {
step = pIcons->pBIG_Trade->w + 1;
}
- for (i = 0; i < pCity->trade_prod; i++) {
+ for (i = 0; i < pCity->surplus[O_TRADE]; i++) {
SDL_BlitSurface(pIcons->pBIG_Trade, NULL, pWindow->dst, &dest);
dest.x += step;
}
@@ -2936,8 +2816,8 @@
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 440 - pBuf->w;
- dest.y = pWindow->size.y + 298 + (15 - pBuf->h) / 2;
+ dest.x = pWindow->size.x + adj_size(440) - pBuf->w;
+ dest.y = pWindow->size.y + adj_size(298) + (adj_size(15) - pBuf->h) / 2;
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
@@ -2945,13 +2825,13 @@
/* draw corruption */
if (pCity->waste[O_TRADE] > 0) {
- dest.x = pWindow->size.x + 423;
+ dest.x = pWindow->size.x + adj_size(423);
dest.y =
- pWindow->size.y + 316 + (16 - pIcons->pBIG_Trade->h) / 2;
+ pWindow->size.y + adj_size(316) + (adj_size(16) -
pIcons->pBIG_Trade->h) / 2;
- if (((pIcons->pBIG_Trade_Corr->w + 1) * pCity->waste[O_TRADE]) > 30) {
+ if (((pIcons->pBIG_Trade_Corr->w + 1) * pCity->waste[O_TRADE]) >
adj_size(30)) {
step =
- (30 - pIcons->pBIG_Trade_Corr->w) / (pCity->waste[O_TRADE] - 1);
+ (adj_size(30) - pIcons->pBIG_Trade_Corr->w) / (pCity->waste[O_TRADE]
- 1);
} else {
step = pIcons->pBIG_Trade_Corr->w + 1;
}
@@ -2973,15 +2853,15 @@
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 200;
- dest.y = pWindow->size.y + 342 + (15 - pBuf->h) / 2;
+ dest.x = pWindow->size.x + adj_size(200);
+ dest.y = pWindow->size.y + adj_size(342) + (adj_size(15) - pBuf->h) / 2;
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
FREESURFACE(pBuf);
/* draw coins */
- count = pcity->surplus[O_GOLD];
+ count = pCity->surplus[O_GOLD];
if (count) {
if (count > 0) {
@@ -2991,11 +2871,11 @@
pBuf = pIcons->pBIG_Coin_Corr;
}
- dest.y = pWindow->size.y + 359 + (16 - pBuf->h) / 2;
- dest.x = pWindow->size.x + 203;
+ dest.y = pWindow->size.y + adj_size(359) + (adj_size(16) - pBuf->h) / 2;
+ dest.x = pWindow->size.x + adj_size(203);
- if ((pBuf->w * count) > 110) {
- step = (110 - pBuf->w) / (count - 1);
+ if ((pBuf->w * count) > adj_size(110)) {
+ step = (adj_size(110) - pBuf->w) / (count - 1);
if (!step) {
step = 1;
count = 97;
@@ -3013,31 +2893,31 @@
/* upkeep label */
my_snprintf(cBuf, sizeof(cBuf), _("Upkeep : %d"),
- pCity->prod[O_GOLD] - pcity->surplus[O_GOLD]);
+ pCity->prod[O_GOLD] - pCity->surplus[O_GOLD]);
copy_chars_to_string16(pStr, cBuf);
pStr->fgcol = *get_game_colorRGB(COLOR_STD_CITY_UNKEEP);
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 440 - pBuf->w;
- dest.y = pWindow->size.y + 342 + (15 - pBuf->h) / 2;
+ dest.x = pWindow->size.x + adj_size(440) - pBuf->w;
+ dest.y = pWindow->size.y + adj_size(342) + (adj_size(15) - pBuf->h) / 2;
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
FREESURFACE(pBuf);
/* draw upkeep */
- count = pcity->surplus[O_GOLD];
+ count = pCity->surplus[O_GOLD];
if (pCity->prod[O_GOLD] - count) {
- dest.x = pWindow->size.x + 423;
- dest.y = pWindow->size.y + 359
- + (16 - pIcons->pBIG_Coin_UpKeep->h) / 2;
+ dest.x = pWindow->size.x + adj_size(423);
+ dest.y = pWindow->size.y + adj_size(359)
+ + (adj_size(16) - pIcons->pBIG_Coin_UpKeep->h) / 2;
if (((pIcons->pBIG_Coin_UpKeep->w + 1) *
- (pCity->prod[O_GOLD] - count)) > 110) {
- step = (110 - pIcons->pBIG_Coin_UpKeep->w) /
+ (pCity->prod[O_GOLD] - count)) > adj_size(110)) {
+ step = (adj_size(110) - pIcons->pBIG_Coin_UpKeep->w) /
(pCity->prod[O_GOLD] - count - 1);
} else {
step = pIcons->pBIG_Coin_UpKeep->w + 1;
@@ -3059,8 +2939,8 @@
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 200;
- dest.y = pWindow->size.y + 376 + (15 - pBuf->h) / 2;
+ dest.x = pWindow->size.x + adj_size(200);
+ dest.y = pWindow->size.y + adj_size(376) + (adj_size(15) - pBuf->h) / 2;
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
@@ -3071,11 +2951,11 @@
if (count) {
dest.y =
- pWindow->size.y + 394 + (16 - pIcons->pBIG_Colb->h) / 2;
- dest.x = pWindow->size.x + 203;
+ pWindow->size.y + adj_size(394) + (adj_size(16) - pIcons->pBIG_Colb->h)
/ 2;
+ dest.x = pWindow->size.x + adj_size(203);
- if ((pIcons->pBIG_Colb->w * count) > 235) {
- step = (235 - pIcons->pBIG_Colb->w) / (count - 1);
+ if ((pIcons->pBIG_Colb->w * count) > adj_size(235)) {
+ step = (adj_size(235) - pIcons->pBIG_Colb->w) / (count - 1);
if (!step) {
step = 1;
count = 222;
@@ -3099,8 +2979,8 @@
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 200;
- dest.y = pWindow->size.y + 412 + (15 - pBuf->h) / 2;
+ dest.x = pWindow->size.x + adj_size(200);
+ dest.y = pWindow->size.y + adj_size(412) + (adj_size(15) - pBuf->h) / 2;
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
@@ -3110,12 +2990,12 @@
if (pCity->prod[O_LUXURY]) {
dest.y =
- pWindow->size.y + 429 + (16 - pIcons->pBIG_Luxury->h) / 2;
- dest.x = pWindow->size.x + 203;
+ pWindow->size.y + adj_size(429) + (adj_size(16) -
pIcons->pBIG_Luxury->h) / 2;
+ dest.x = pWindow->size.x + adj_size(203);
- if ((pIcons->pBIG_Luxury->w * pCity->prod[O_LUXURY]) > 235) {
+ if ((pIcons->pBIG_Luxury->w * pCity->prod[O_LUXURY]) > adj_size(235)) {
step =
- (235 - pIcons->pBIG_Luxury->w) / (pCity->prod[O_LUXURY] - 1);
+ (adj_size(235) - pIcons->pBIG_Luxury->w) / (pCity->prod[O_LUXURY] -
1);
} else {
step = pIcons->pBIG_Luxury->w;
}
@@ -3144,12 +3024,13 @@
}
copy_chars_to_string16(pStr, cBuf);
- pStr->fgcol = *get_game_colorRGB(COLOR_STD_GROUND);
+
+ pStr->fgcol = *get_game_colorRGB(COLOR_OVERVIEW_LAND);
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 445 + (192 - pBuf->w) / 2;
- dest.y = pWindow->size.y + 227;
+ dest.x = pWindow->size.x + adj_size(445) + (adj_size(192) - pBuf->w) / 2;
+ dest.y = pWindow->size.y + adj_size(227);
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
@@ -3159,7 +3040,7 @@
count = (city_granary_size(pCity->size)) / 10;
if (count > 12) {
- step = (168 - pIcons->pBIG_Food->h) / (11 + count - 12);
+ step = (adj_size(168) - pIcons->pBIG_Food->h) / adj_size((11 + count -
12));
i = (count - 1) * step + 14;
count = 12;
} else {
@@ -3168,15 +3049,20 @@
}
/* food stock */
- if (city_got_building(pCity, B_GRANARY)
- || city_affected_by_wonder(pCity, B_PYRAMIDS)) {
+
+ /* FIXME: check if this code replacement is correct */
+ /* if (city_got_building(pCity, B_GRANARY) */
+ /* || city_affected_by_wonder(pCity, B_PYRAMIDS)) { */
+
+ if (get_city_bonus(pCity, EFT_GROWTH_FOOD) > 0) {
+
/* with granary */
/* stocks label */
copy_chars_to_string16(pStr, _("Stock"));
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 461 + (76 - pBuf->w) / 2;
- dest.y = pWindow->size.y + 258 - pBuf->h - 1;
+ dest.x = pWindow->size.x + adj_size(461) + (adj_size(76) - pBuf->w) / 2;
+ dest.y = pWindow->size.y + adj_size(258) - pBuf->h - 1;
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
@@ -3186,7 +3072,7 @@
copy_chars_to_string16(pStr, _("Granary"));
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 549 + (76 - pBuf->w) / 2;
+ dest.x = pWindow->size.x + adj_size(549) + (adj_size(76) - pBuf->w) / 2;
/*dest.y = pWindow->size.y + 258 - pBuf->h - 1; */
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
@@ -3194,8 +3080,8 @@
FREESURFACE(pBuf);
/* draw bcgd granary */
- dest.x = pWindow->size.x + 462;
- dest.y = pWindow->size.y + 260;
+ dest.x = pWindow->size.x + adj_size(462);
+ dest.y = pWindow->size.y + adj_size(260);
dest.w = 70 + 4;
dest.h = i + 4;
SDL_FillRectAlpha(pWindow->dst, &dest, &color);
@@ -3204,8 +3090,8 @@
dest.x + dest.w, dest.y + dest.h, 0xff000000);
/* draw bcgd stocks*/
- dest.x = pWindow->size.x + 550;
- dest.y = pWindow->size.y + 260;
+ dest.x = pWindow->size.x + adj_size(550);
+ dest.y = pWindow->size.y + adj_size(260);
SDL_FillRectAlpha(pWindow->dst, &dest, &color);
putframe(pWindow->dst, dest.x - 1, dest.y - 1,
@@ -3213,19 +3099,19 @@
/* draw stocks icons */
cost = city_granary_size(pCity->size);
- if (pCity->food_stock + pCity->food_surplus > cost) {
+ if (pCity->food_stock + pCity->surplus[O_FOOD] > cost) {
count = cost;
} else {
- if(pCity->food_surplus < 0) {
+ if(pCity->surplus[O_FOOD] < 0) {
count = pCity->food_stock;
} else {
- count = pCity->food_stock + pCity->food_surplus;
+ count = pCity->food_stock + pCity->surplus[O_FOOD];
}
}
cost /= 2;
- if(pCity->food_surplus < 0) {
- limit = pCity->food_stock + pCity->food_surplus;
+ if(pCity->surplus[O_FOOD] < 0) {
+ limit = pCity->food_stock + pCity->surplus[O_FOOD];
if(limit < 0) {
limit = 0;
}
@@ -3243,8 +3129,8 @@
count--;
cost--;
i++;
- if (dest.x > pWindow->size.x + 620) {
- dest.x = pWindow->size.x + 552;
+ if (dest.x > pWindow->size.x + adj_size(620)) {
+ dest.x = pWindow->size.x + adj_size(552);
dest.y += step;
}
if(i > limit - 1) {
@@ -3257,16 +3143,16 @@
}
}
/* draw granary icons */
- dest.x = pWindow->size.x + 462 + 2;
- dest.y = pWindow->size.y + 260 + 2;
+ dest.x = pWindow->size.x + adj_size(462) + adj_size(2);
+ dest.y = pWindow->size.y + adj_size(260) + adj_size(2);
while (count) {
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
dest.x += pBuf->w;
count--;
i++;
- if (dest.x > pWindow->size.x + 532) {
- dest.x = pWindow->size.x + 464;
+ if (dest.x > pWindow->size.x + adj_size(532)) {
+ dest.x = pWindow->size.x + adj_size(464);
dest.y += step;
}
if(i > limit - 1) {
@@ -3285,18 +3171,18 @@
copy_chars_to_string16(pStr, _("Stock"));
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 461 + (144 - pBuf->w) / 2;
- dest.y = pWindow->size.y + 258 - pBuf->h - 1;
+ dest.x = pWindow->size.x + adj_size(461) + (adj_size(144) - pBuf->w) / 2;
+ dest.y = pWindow->size.y + adj_size(258) - pBuf->h - 1;
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
FREESURFACE(pBuf);
/* food stock */
/* draw bcgd */
- dest.x = pWindow->size.x + 462;
- dest.y = pWindow->size.y + 260;
- dest.w = 144;
- dest.h = i + 4;
+ dest.x = pWindow->size.x + adj_size(462);
+ dest.y = pWindow->size.y + adj_size(260);
+ dest.w = adj_size(144);
+ dest.h = i + adj_size(4);
SDL_FillRectAlpha(pWindow->dst, &dest, &color);
putframe(pWindow->dst, dest.x - 1, dest.y - 1,
@@ -3304,18 +3190,18 @@
/* draw icons */
cost = city_granary_size(pCity->size);
- if (pCity->food_stock + pCity->food_surplus > cost) {
+ if (pCity->food_stock + pCity->surplus[O_FOOD] > cost) {
count = cost;
} else {
- if(pCity->food_surplus < 0) {
+ if(pCity->surplus[O_FOOD] < 0) {
count = pCity->food_stock;
} else {
- count = pCity->food_stock + pCity->food_surplus;
+ count = pCity->food_stock + pCity->surplus[O_FOOD];
}
}
- if(pCity->food_surplus < 0) {
- limit = pCity->food_stock + pCity->food_surplus;
+ if(pCity->surplus[O_FOOD] < 0) {
+ limit = pCity->food_stock + pCity->surplus[O_FOOD];
if(limit < 0) {
limit = 0;
}
@@ -3323,8 +3209,8 @@
limit = 0xffff;
}
- dest.x += 2;
- dest.y += 2;
+ dest.x += adj_size(2);
+ dest.y += adj_size(2);
i = 0;
pBuf = pIcons->pBIG_Food;
while (count) {
@@ -3332,8 +3218,8 @@
dest.x += pBuf->w;
count--;
i++;
- if (dest.x > pWindow->size.x + 602) {
- dest.x = pWindow->size.x + 464;
+ if (dest.x > pWindow->size.x + adj_size(602)) {
+ dest.x = pWindow->size.x + adj_size(464);
dest.y += step;
}
if(i > limit - 1) {
@@ -3351,28 +3237,28 @@
/* draw productions shields progress */
if (pCity->production.is_unit) {
struct unit_type *pUnit = get_unit_type(pCity->production.value);
- cost = unit_build_shield_cost(pCity->production.value);
+ cost = unit_build_shield_cost(get_unit_type(pCity->production.value));
count = cost / 10;
copy_chars_to_string16(pStr, pUnit->name);
- src = get_smaller_surface_rect(GET_SURF(pUnit->sprite));
+ src = get_smaller_surface_rect(GET_SURF(get_unittype_sprite(tileset,
get_unit_type(pCity->production.value))));
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 6 + (185 - (pBuf->w + src.w + 5)) / 2;
- dest.y = pWindow->size.y + 233;
+ dest.x = pWindow->size.x + adj_size(6) + (adj_size(185) - (pBuf->w + src.w
+ adj_size(5))) / 2;
+ dest.y = pWindow->size.y + adj_size(233);
/* blit unit icon */
- SDL_BlitSurface(GET_SURF(pUnit->sprite), &src, pWindow->dst, &dest);
+ SDL_BlitSurface(GET_SURF(get_unittype_sprite(tileset,
get_unit_type(pCity->production.value))), &src, pWindow->dst, &dest);
dest.y += (src.h - pBuf->h) / 2;
- dest.x += src.w + 5;
+ dest.x += src.w + adj_size(5);
} else {
struct impr_type *pImpr =
get_improvement_type(pCity->production.value);
- if (pCity->production.value == B_CAPITAL) {
+ if (pCity->production.value == get_building_for_effect( EFT_PROD_TO_GOLD))
{
if (pCityDlg->pBuy_Button
&& get_wstate(pCityDlg->pBuy_Button) != FC_WS_DISABLED) {
@@ -3397,18 +3283,18 @@
}
copy_chars_to_string16(pStr, pImpr->name);
- pBuf = GET_SURF(pImpr->sprite);
+ pBuf = GET_SURF(get_building_sprite(tileset, pCity->production.value));
/* blit impr icon */
- dest.x = pWindow->size.x + 6 + (185 - pBuf->w) / 2;
- dest.y = pWindow->size.y + 230;
+ dest.x = pWindow->size.x + adj_size(6) + (adj_size(185) - pBuf->w) / 2;
+ dest.y = pWindow->size.y + adj_size(230);
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
- dest.y += (pBuf->h + 2);
+ dest.y += (pBuf->h + adj_size(2));
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 6 + (185 - pBuf->w) / 2;
+ dest.x = pWindow->size.x + adj_size(6) + (adj_size(185) - pBuf->w) / 2;
}
/* blit unit/impr name */
@@ -3418,7 +3304,7 @@
if (count) {
if (count > 11) {
- step = (154 - pIcons->pBIG_Shield->h) / (10 + count - 11);
+ step = (adj_size(154) - pIcons->pBIG_Shield->h) / adj_size((10 + count -
11));
if(!step) step = 1;
@@ -3429,19 +3315,19 @@
}
/* draw sheild stock background */
- dest.x = pWindow->size.x + 28;
- dest.y = pWindow->size.y + 270;
- dest.w = 144;
- dest.h = i + 4;
+ dest.x = pWindow->size.x + adj_size(28);
+ dest.y = pWindow->size.y + adj_size(270);
+ dest.w = adj_size(144);
+ dest.h = i + adj_size(4);
SDL_FillRectAlpha(pWindow->dst, &dest, &color);
putframe(pWindow->dst, dest.x - 1, dest.y - 1,
dest.x + dest.w, dest.y + dest.h, 0xff000000);
/* draw production progres text */
- dest.y = pWindow->size.y + 270 + dest.h + 1;
+ dest.y = pWindow->size.y + adj_size(270) + dest.h + 1;
if (pCity->shield_stock < cost) {
count = city_turns_to_build(pCity,
- pCity->production.value, pCity->production.is_unit, TRUE);
+ pCity->production, TRUE);
if (count == 999) {
my_snprintf(cBuf, sizeof(cBuf), "(%d/%d) %s!",
pCity->shield_stock, cost, _("blocked"));
@@ -3459,7 +3345,7 @@
pBuf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->size.x + 6 + (185 - pBuf->w) / 2;
+ dest.x = pWindow->size.x + adj_size(6) + (adj_size(185) - pBuf->w) / 2;
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
@@ -3467,13 +3353,13 @@
FREESURFACE(pBuf);
/* draw sheild stock */
- if (pCity->shield_stock + pCity->shield_surplus <= cost) {
- count = pCity->shield_stock + pCity->shield_surplus;
+ if (pCity->shield_stock + pCity->surplus[O_SHIELD] <= cost) {
+ count = pCity->shield_stock + pCity->surplus[O_SHIELD];
} else {
count = cost;
}
- dest.x = pWindow->size.x + 29 + 2;
- dest.y = pWindow->size.y + 270 + 2;
+ dest.x = pWindow->size.x + adj_size(29) + adj_size(2);
+ dest.y = pWindow->size.y + adj_size(270) + adj_size(2);
i = 0;
pBuf = pIcons->pBIG_Shield;
@@ -3481,8 +3367,8 @@
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
dest.x += pBuf->w;
count--;
- if (dest.x > pWindow->size.x + 170) {
- dest.x = pWindow->size.x + 31;
+ if (dest.x > pWindow->size.x + adj_size(170)) {
+ dest.x = pWindow->size.x + adj_size(31);
dest.y += step;
}
i++;
@@ -3500,20 +3386,22 @@
+ pCity->specialists[SP_ELVIS] + pCity->specialists[SP_SCIENTIST]
+ pCity->specialists[SP_TAXMAN]);
- pBuf = get_citizen_surface(CITIZEN_ELVIS, 0);
+ pBuf = adj_surf(GET_SURF(get_tax_sprite(tileset, O_LUXURY)));
+
if (count > 13) {
- step = (400 - pBuf->w) / (12 + count - 13);
+ step = (adj_size(400) - pBuf->w) / (adj_size(12 + count - 13));
} else {
step = pBuf->w;
}
dest.y =
- pWindow->size.y + 26 + (42 - pBuf->h) / 2;
- dest.x = pWindow->size.x + 227;
+ pWindow->size.y + adj_size(26) + (adj_size(42) - pBuf->h) / 2;
+ dest.x = pWindow->size.x + adj_size(227);
if (pCity->ppl_happy[4]) {
for (i = 0; i < pCity->ppl_happy[4]; i++) {
- pBuf = get_citizen_surface(CITIZEN_HAPPY, i);
+ pBuf = adj_surf(get_citizen_surface(CITIZEN_HAPPY, i));
+
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
dest.x += step;
}
@@ -3521,7 +3409,8 @@
if (pCity->ppl_content[4]) {
for (i = 0; i < pCity->ppl_content[4]; i++) {
- pBuf = get_citizen_surface(CITIZEN_CONTENT, i);
+ pBuf = adj_surf(get_citizen_surface(CITIZEN_CONTENT, i));
+
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
dest.x += step;
}
@@ -3529,7 +3418,8 @@
if (pCity->ppl_unhappy[4]) {
for (i = 0; i < pCity->ppl_unhappy[4]; i++) {
- pBuf = get_citizen_surface(CITIZEN_UNHAPPY, i);
+ pBuf = adj_surf(get_citizen_surface(CITIZEN_UNHAPPY, i));
+
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
dest.x += step;
}
@@ -3537,7 +3427,7 @@
if (pCity->ppl_angry[4]) {
for (i = 0; i < pCity->ppl_angry[4]; i++) {
- pBuf = get_citizen_surface(CITIZEN_ANGRY, i);
+ pBuf = adj_surf(get_citizen_surface(CITIZEN_ANGRY, i));
SDL_BlitSurface(pBuf, NULL, pWindow->dst, &dest);
dest.x += step;
}
@@ -3548,7 +3438,8 @@
pCityDlg->specs[2] = FALSE;
if (pCity->specialists[SP_ELVIS]) {
- pBuf = get_citizen_surface(CITIZEN_ELVIS, 0);
+ pBuf = adj_surf(GET_SURF(get_tax_sprite(tileset, O_LUXURY)));
+
pCityDlg->specs_area[0].x = dest.x;
pCityDlg->specs_area[0].y = dest.y;
pCityDlg->specs_area[0].w = pBuf->w;
@@ -3563,7 +3454,8 @@
}
if (pCity->specialists[SP_TAXMAN]) {
- pBuf = get_citizen_surface(CITIZEN_TAXMAN, 0);
+ pBuf = adj_surf(GET_SURF(get_tax_sprite(tileset, O_GOLD)));
+
pCityDlg->specs_area[1].x = dest.x;
pCityDlg->specs_area[1].y = dest.y;
pCityDlg->specs_area[1].w = pBuf->w;
@@ -3578,7 +3470,8 @@
}
if (pCity->specialists[SP_SCIENTIST]) {
- pBuf = get_citizen_surface(CITIZEN_SCIENTIST, 0);
+ pBuf = adj_surf(GET_SURF(get_tax_sprite(tileset, O_SCIENCE)));
+
pCityDlg->specs_area[2].x = dest.x;
pCityDlg->specs_area[2].y = dest.y;
pCityDlg->specs_area[2].w = pBuf->w;
@@ -3661,13 +3554,13 @@
pImpr = get_improvement_type(imp);
- pStr = create_str16_from_char(get_impr_name_ex(pCity, imp), 12);
- pStr->fgcol = *get_game_colorRGB(COLOR_STD_WHITE);
+ pStr = create_str16_from_char(get_impr_name_ex(pCity, imp), adj_font(12));
+ pStr->fgcol = (SDL_Color){255, 255, 255, 255};
pStr->bgcol.unused = 128;/* 50% transp */
pStr->style |= TTF_STYLE_BOLD;
- pLogo = ZoomSurface(GET_SURF(pImpr->sprite), 0.6, 0.6 , 1);
+ pLogo = ZoomSurface(GET_SURF(get_building_sprite(tileset, imp)), 0.6, 0.6
, 1);
pBuf = create_iconlabel(pLogo, pWindow->dst, pStr,
(WF_FREE_THEME | WF_DRAW_THEME_TRANSPARENT));
@@ -3679,7 +3572,7 @@
pBuf->action = sell_imprvm_dlg_callback;
if (!pCityDlg->pCity->did_sell
- && !pImpr->is_wonder && (pOwner == game.player_ptr)) {
+ && !is_wonder(imp) && (pOwner == game.player_ptr)) {
set_wstate(pBuf, FC_WS_NORMAL);
}
@@ -3755,7 +3648,7 @@
Pop up (or bring to the front) a dialog for the given city. It may or
may not be modal.
**************************************************************************/
-void popup_city_dialog(struct city *pCity, bool make_modal)
+void popup_city_dialog(struct city *pCity)
{
struct GUI *pWindow = NULL, *pBuf = NULL;
SDL_Surface *pLogo = NULL;
@@ -3772,17 +3665,17 @@
pCityDlg = MALLOC(sizeof(struct city_dialog));
pCityDlg->pCity = pCity;
- pStr = create_string16(NULL, 0, 12);
+ pStr = create_string16(NULL, 0, adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(get_locked_buffer(), pStr, 640, 480, 0);
+ pWindow = create_window(get_locked_buffer(), pStr, adj_size(640),
adj_size(480), 0);
unlock_buffer();
rebuild_citydlg_title_str(pWindow, pCity);
- pWindow->size.x = (pWindow->dst->w - 640) / 2;
- pWindow->size.y = (pWindow->dst->h - 480) / 2;
- pWindow->size.w = 640;
- pWindow->size.h = 480;
+ pWindow->size.x = (pWindow->dst->w - adj_size(640)) / 2;
+ pWindow->size.y = (pWindow->dst->h - adj_size(480)) / 2;
+ pWindow->size.w = adj_size(640);
+ pWindow->size.h = adj_size(480);
pWindow->action = city_dlg_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -3794,7 +3687,6 @@
pLogo = get_city_gfx();
SDL_BlitSurface(pLogo, NULL, pWindow->theme, NULL);
- FREESURFACE(pLogo);
SDL_SetAlpha(pWindow->theme, 0x0, 0x0);
pCityDlg->pEndCityWidgetList = pWindow;
@@ -3802,26 +3694,39 @@
/* ============================================================= */
+#if 0
+ /* in title bar */
pBuf = create_themeicon(pTheme->CANCEL_Icon, pWindow->dst,
(WF_WIDGET_HAS_INFO_LABEL |
WF_DRAW_THEME_TRANSPARENT));
- pBuf->string16 = create_str16_from_char(_("Cancel"), 12);
+ pBuf->string16 = create_str16_from_char(_("Cancel"), adj_font(12));
pBuf->action = exit_city_dlg_callback;
- pBuf->size.x = pWindow->size.x + pWindow->size.w - pBuf->size.w - 10;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - 9;
+ pBuf->size.x = pWindow->size.x + pWindow->size.w - pBuf->size.w;
+ pBuf->size.y = pWindow->size.y;
pBuf->key = SDLK_ESCAPE;
set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(ID_CITY_DLG_EXIT_BUTTON, pBuf);
+#endif
/* Buttons */
+ pBuf = create_themeicon(pTheme->CANCEL_Icon, pWindow->dst,
+ (WF_WIDGET_HAS_INFO_LABEL |
+ WF_DRAW_THEME_TRANSPARENT));
+ pBuf->string16 = create_str16_from_char(_("Cancel"), adj_font(12));
+ pBuf->action = exit_city_dlg_callback;
+ pBuf->size.x = pWindow->size.x + pWindow->size.w - pBuf->size.w -
adj_size(10);
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h -
adj_size(9);
+ set_wstate(pBuf, FC_WS_NORMAL);
+ add_to_gui_list(ID_CITY_DLG_EXIT_BUTTON, pBuf);
+
pBuf = create_themeicon(pTheme->INFO_Icon, pWindow->dst,
(WF_WIDGET_HAS_INFO_LABEL |
WF_DRAW_THEME_TRANSPARENT));
- pBuf->string16 = create_str16_from_char(_("Information panel"), 12);
+ pBuf->string16 = create_str16_from_char(_("Information panel"),
adj_font(12));
pBuf->action = info_city_dlg_callback;
pBuf->size.x =
- pWindow->size.x + pWindow->size.w - 2 * pBuf->size.w - 5 - 10;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - 9;
+ pWindow->size.x + pWindow->size.w - 2 * pBuf->size.w - adj_size(5) -
adj_size(10);
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h -
adj_size(9);
set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(ID_CITY_DLG_INFO_BUTTON, pBuf);
/* -------- */
@@ -3829,11 +3734,11 @@
pBuf = create_themeicon(pTheme->Happy_Icon, pWindow->dst,
(WF_WIDGET_HAS_INFO_LABEL |
WF_DRAW_THEME_TRANSPARENT));
- pBuf->string16 = create_str16_from_char(_("Happiness panel"), 12);
+ pBuf->string16 = create_str16_from_char(_("Happiness panel"), adj_font(12));
pBuf->action = happy_city_dlg_callback;
pBuf->size.x =
- pWindow->size.x + pWindow->size.w - 3 * pBuf->size.w - 10 - 10;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - 9;
+ pWindow->size.x + pWindow->size.w - 3 * pBuf->size.w - adj_size(10) -
adj_size(10);
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h -
adj_size(9);
set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(ID_CITY_DLG_HAPPY_BUTTON, pBuf);
/* -------- */
@@ -3841,11 +3746,11 @@
pBuf = create_themeicon(pTheme->Army_Icon, pWindow->dst,
(WF_WIDGET_HAS_INFO_LABEL |
WF_DRAW_THEME_TRANSPARENT));
- pBuf->string16 = create_str16_from_char(_("Garrison panel"), 12);
+ pBuf->string16 = create_str16_from_char(_("Garrison panel"), adj_font(12));
pBuf->action = army_city_dlg_callback;
pBuf->size.x =
- pWindow->size.x + pWindow->size.w - 4 * pBuf->size.w - 10 - 10;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - 9;
+ pWindow->size.x + pWindow->size.w - 4 * pBuf->size.w - adj_size(10) -
adj_size(10);
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h -
adj_size(9);
set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(ID_CITY_DLG_ARMY_BUTTON, pBuf);
/* -------- */
@@ -3853,11 +3758,11 @@
pBuf = create_themeicon(pTheme->Support_Icon, pWindow->dst,
(WF_WIDGET_HAS_INFO_LABEL |
WF_DRAW_THEME_TRANSPARENT));
- pBuf->string16 = create_str16_from_char(_("Maintenance panel"), 12);
+ pBuf->string16 = create_str16_from_char(_("Maintenance panel"),
adj_font(12));
pBuf->action = supported_unit_city_dlg_callback;
pBuf->size.x =
- pWindow->size.x + pWindow->size.w - 5 * pBuf->size.w - 10 - 10;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - 9;
+ pWindow->size.x + pWindow->size.w - 5 * pBuf->size.w - adj_size(10) -
adj_size(10);
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h -
adj_size(9);
set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(ID_CITY_DLG_SUPPORT_BUTTON, pBuf);
@@ -3878,7 +3783,7 @@
}
pBuf->size.x =
pWindow->size.x + (pWindow->size.w - pBuf->size.w) / 2 - 1;
- pBuf->size.y = pWindow->size.y + 87 + (134 - pBuf->size.h) / 2;
+ pBuf->size.y = pWindow->size.y + adj_size(87) + (adj_size(134) -
pBuf->size.h) / 2;
add_to_gui_list(ID_CITY_DLG_RESOURCE_MAP, pBuf);
/* -------- */
@@ -3886,11 +3791,11 @@
pBuf = create_themeicon(pTheme->Options_Icon, pWindow->dst,
(WF_WIDGET_HAS_INFO_LABEL |
WF_DRAW_THEME_TRANSPARENT));
- pBuf->string16 = create_str16_from_char(_("Options panel"), 12);
+ pBuf->string16 = create_str16_from_char(_("Options panel"), adj_font(12));
pBuf->action = options_city_dlg_callback;
pBuf->size.x =
- pWindow->size.x + pWindow->size.w - 6 * pBuf->size.w - 10 - 10;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - 9;
+ pWindow->size.x + pWindow->size.w - 6 * pBuf->size.w - adj_size(10) -
adj_size(10);
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h -
adj_size(9);
set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(ID_CITY_DLG_OPTIONS_BUTTON, pBuf);
/* -------- */
@@ -3898,10 +3803,10 @@
pBuf = create_themeicon(pTheme->PROD_Icon, pWindow->dst,
(WF_WIDGET_HAS_INFO_LABEL |
WF_DRAW_THEME_TRANSPARENT));
- pBuf->string16 = create_str16_from_char(_("Change Production"), 12);
+ pBuf->string16 = create_str16_from_char(_("Change Production"),
adj_font(12));
pBuf->action = change_prod_dlg_callback;
- pBuf->size.x = pWindow->size.x + 10;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - 9;
+ pBuf->size.x = pWindow->size.x + adj_size(10);
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h -
adj_size(9);
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_c;
add_to_gui_list(ID_CITY_DLG_CHANGE_PROD_BUTTON, pBuf);
@@ -3910,10 +3815,10 @@
pBuf = create_themeicon(pTheme->Buy_PROD_Icon, pWindow->dst,
(WF_WIDGET_HAS_INFO_LABEL |
WF_DRAW_THEME_TRANSPARENT));
- pBuf->string16 = create_str16_from_char(_("Hurry production"), 12);
+ pBuf->string16 = create_str16_from_char(_("Hurry production"),
adj_font(12));
pBuf->action = buy_prod_city_dlg_callback;
- pBuf->size.x = pWindow->size.x + 10 + (pBuf->size.w + 2);
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - 9;
+ pBuf->size.x = pWindow->size.x + adj_size(10) + (pBuf->size.w + 2);
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h -
adj_size(9);
pCityDlg->pBuy_Button = pBuf;
pBuf->key = SDLK_h;
if (!pCity->did_buy) {
@@ -3925,11 +3830,11 @@
pBuf = create_themeicon(pTheme->CMA_Icon, pWindow->dst,
(WF_WIDGET_HAS_INFO_LABEL |
WF_DRAW_THEME_TRANSPARENT));
- pBuf->string16 = create_str16_from_char(_("Citizen Management Agent"), 12);
+ pBuf->string16 = create_str16_from_char(_("Citizen Management Agent"),
adj_font(12));
pBuf->action = cma_city_dlg_callback;
pBuf->key = SDLK_a;
- pBuf->size.x = pWindow->size.x + 10 + (pBuf->size.w + 2) * 2;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - 9;
+ pBuf->size.x = pWindow->size.x + adj_size(10) + (pBuf->size.w +
adj_size(2)) * 2;
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h -
adj_size(9);
set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(ID_CITY_DLG_CMA_BUTTON, pBuf);
@@ -3939,10 +3844,10 @@
(WF_WIDGET_HAS_INFO_LABEL |
WF_DRAW_THEME_TRANSPARENT));
- pBuf->string16 = create_str16_from_char(_("Prev city"), 12);
+ pBuf->string16 = create_str16_from_char(_("Prev city"), adj_font(12));
pBuf->action = next_prev_city_dlg_callback;
- pBuf->size.x = pWindow->size.x + 220 - pBuf->size.w - 5;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - 2;
+ pBuf->size.x = pWindow->size.x + adj_size(220) - pBuf->size.w -
adj_size(5);
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h -
adj_size(2);
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_LEFT;
pBuf->mod = KMOD_LSHIFT;
@@ -3952,10 +3857,10 @@
pBuf = create_themeicon(pTheme->R_ARROW_Icon, pWindow->dst,
(WF_WIDGET_HAS_INFO_LABEL |
WF_DRAW_THEME_TRANSPARENT));
- pBuf->string16 = create_str16_from_char(_("Next city"), 12);
+ pBuf->string16 = create_str16_from_char(_("Next city"), adj_font(12));
pBuf->action = next_prev_city_dlg_callback;
- pBuf->size.x = pWindow->size.x + 420 + 5;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - 2;
+ pBuf->size.x = pWindow->size.x + adj_size(420) + adj_size(5);
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h -
adj_size(2);
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_RIGHT;
pBuf->mod = KMOD_LSHIFT;
@@ -3963,10 +3868,10 @@
/* -------- */
pBuf = create_edit_from_chars(NULL, pWindow->dst, pCity->name,
- 10, 200, WF_DRAW_THEME_TRANSPARENT);
+ adj_font(10), adj_size(200),
WF_DRAW_THEME_TRANSPARENT);
pBuf->action = new_name_city_dlg_callback;
pBuf->size.x = pWindow->size.x + (pWindow->size.w - pBuf->size.w) / 2;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - 5;
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h -
adj_size(5);
set_wstate(pBuf, FC_WS_NORMAL);
pCityDlg->pCity_Name_Edit = pBuf;
@@ -4082,7 +3987,7 @@
{
struct city *pCity_sup = find_city_by_id(pUnit->homecity);
- struct city *pCity_pre = tile_get_city(pUnit->x, pUnit->y);
+ struct city *pCity_pre = tile_get_city(pUnit->tile);
if (pCityDlg && ((pCityDlg->pCity == pCity_sup)
|| (pCityDlg->pCity == pCity_pre))) {
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/citydlg.h
devel/client/gui-sdl/citydlg.h
--- devel_distclean/client/gui-sdl/citydlg.h 2005-10-15 23:27:27.000000000
+0200
+++ devel/client/gui-sdl/citydlg.h 2005-11-15 06:52:44.000000000 +0100
@@ -32,5 +32,6 @@
const struct city *pCity,
bool (*worker_check) (const struct city *,
int, int));
+Impr_type_id get_building_for_effect(enum effect_type effect_type);
#endif /* FC__CITYDLG_H */
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/cityrep.c
devel/client/gui-sdl/cityrep.c
--- devel_distclean/client/gui-sdl/cityrep.c 2005-10-18 21:02:43.000000000
+0200
+++ devel/client/gui-sdl/cityrep.c 2005-11-15 06:52:44.000000000 +0100
@@ -86,7 +86,7 @@
static int popup_citydlg_from_city_report_callback(struct GUI *pWidget)
{
- popup_city_dialog(pWidget->data.city, 0);
+ popup_city_dialog(pWidget->data.city);
return -1;
}
@@ -142,7 +142,8 @@
SDL_Surface *pText1, *pText2, *pText3, *pUnits_Icon, *pCMA_Icon, *pText4;
SDL_Surface *pLogo;
int togrow, w = 0 , count , h = 0, ww = 0, hh = 0, name_w = 0, prod_w = 0, H;
- char cBuf[128], *pName;
+ char cBuf[128];
+ const char *pName;
SDL_Color color = {255,255,255,128};
SDL_Rect dst;
@@ -154,7 +155,7 @@
}
my_snprintf(cBuf, sizeof(cBuf), _("size"));
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pText1 = create_text_surf_from_str16(pStr);
@@ -165,7 +166,7 @@
my_snprintf(cBuf, sizeof(cBuf), _("City Name"));
copy_chars_to_string16(pStr, cBuf);
pText3 = create_text_surf_from_str16(pStr);
- name_w = pText3->w + 6;
+ name_w = pText3->w + adj_size(6);
my_snprintf(cBuf, sizeof(cBuf), _("Production"));
copy_chars_to_string16(pStr, cBuf);
@@ -177,10 +178,10 @@
pCMA_Icon = create_icon_from_theme(pTheme->CMA_Icon, 0);
/* --------------- */
- pStr = create_str16_from_char(_("Cities Report"), 12);
+ pStr = create_str16_from_char(_("Cities Report"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 40, 30, 0);
+ pWindow = create_window(NULL, pStr, adj_size(40), adj_size(30), 0);
pCityRep->pEndWidgetList = pWindow;
w = MAX(w, pWindow->size.w);
set_wstate(pWindow, FC_WS_NORMAL);
@@ -194,7 +195,7 @@
(WF_WIDGET_HAS_INFO_LABEL |
WF_DRAW_THEME_TRANSPARENT));
- pBuf->string16 = create_str16_from_char(_("Exit Report"), 12);
+ pBuf->string16 = create_str16_from_char(_("Exit Report"), adj_font(12));
pBuf->action = exit_city_report_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
@@ -205,7 +206,7 @@
(WF_WIDGET_HAS_INFO_LABEL |
WF_DRAW_THEME_TRANSPARENT));
- pBuf->string16 = create_str16_from_char(_("Information Report"), 12);
+ pBuf->string16 = create_str16_from_char(_("Information Report"),
adj_font(12));
/*
pBuf->action = info_city_report_callback;
set_wstate(pBuf, FC_WS_NORMAL);
@@ -216,7 +217,7 @@
(WF_WIDGET_HAS_INFO_LABEL |
WF_DRAW_THEME_TRANSPARENT));
- pBuf->string16 = create_str16_from_char(_("Happiness Report"), 12);
+ pBuf->string16 = create_str16_from_char(_("Happiness Report"), adj_font(12));
/*
pBuf->action = happy_city_report_callback;
set_wstate(pBuf, FC_WS_NORMAL);
@@ -227,7 +228,7 @@
(WF_WIDGET_HAS_INFO_LABEL |
WF_DRAW_THEME_TRANSPARENT));
- pBuf->string16 = create_str16_from_char(_("Garrison Report"), 12);
+ pBuf->string16 = create_str16_from_char(_("Garrison Report"), adj_font(12));
/*
pBuf->action = army_city_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
@@ -238,7 +239,7 @@
(WF_WIDGET_HAS_INFO_LABEL |
WF_DRAW_THEME_TRANSPARENT));
- pBuf->string16 = create_str16_from_char(_("Maintenance Report"), 12);
+ pBuf->string16 = create_str16_from_char(_("Maintenance Report"),
adj_font(12));
/*
pBuf->action = supported_unit_city_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
@@ -250,7 +251,7 @@
count = 0;
city_list_iterate(game.player_ptr->cities, pCity) {
- pStr = create_str16_from_char(pCity->name, 12);
+ pStr = create_str16_from_char(pCity->name, adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
(WF_DRAW_THEME_TRANSPARENT|WF_SELLECT_WITHOUT_BAR));
@@ -279,7 +280,7 @@
/* ----------- */
my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->size);
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
WF_DRAW_THEME_TRANSPARENT);
@@ -287,7 +288,7 @@
set_wflag(pBuf, WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
- pBuf->size.w = pText1->w + 8;
+ pBuf->size.w = pText1->w + adj_size(8);
add_to_gui_list(MAX_ID - pCity->id, pBuf);
/* ----------- */
@@ -303,22 +304,22 @@
pBuf->action = popup_cma_from_city_report_callback;
/* ----------- */
- my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->prod[O_FOOD] -
pCity->food_surplus);
- pStr = create_str16_from_char(cBuf, 10);
+ my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->prod[O_FOOD] -
pCity->surplus[O_FOOD]);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
- pStr->fgcol = *get_game_colorRGB(COLOR_STD_GROUND);
+ pStr->fgcol = *get_game_colorRGB(COLOR_OVERVIEW_LAND);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
WF_DRAW_THEME_TRANSPARENT);
if(count > 9 * COL) {
set_wflag(pBuf, WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
- pBuf->size.w = pIcons->pBIG_Food->w + 6;
+ pBuf->size.w = pIcons->pBIG_Food->w + adj_size(6);
add_to_gui_list(MAX_ID - pCity->id, pBuf);
/* ----------- */
- my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->food_surplus);
- pStr = create_str16_from_char(cBuf, 10);
+ my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->surplus[O_FOOD]);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pStr->fgcol = *get_game_colorRGB(COLOR_STD_CITY_FOOD_SURPLUS);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
@@ -327,7 +328,7 @@
set_wflag(pBuf, WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
- pBuf->size.w = pIcons->pBIG_Food_Corr->w + 6;
+ pBuf->size.w = pIcons->pBIG_Food_Corr->w + adj_size(6);
add_to_gui_list(MAX_ID - pCity->id, pBuf);
/* ----------- */
@@ -344,7 +345,7 @@
break;
}
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
if(togrow < 0) {
pStr->fgcol.r = 255;
@@ -355,12 +356,12 @@
set_wflag(pBuf, WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
- pBuf->size.w = pText2->w + 6;
+ pBuf->size.w = pText2->w + adj_size(6);
add_to_gui_list(MAX_ID - pCity->id, pBuf);
/* ----------- */
- my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->trade_prod);
- pStr = create_str16_from_char(cBuf, 10);
+ my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->surplus[O_TRADE]);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pStr->fgcol = *get_game_colorRGB(COLOR_STD_CITY_TRADE);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
@@ -369,12 +370,12 @@
set_wflag(pBuf, WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
- pBuf->size.w = pIcons->pBIG_Trade->w + 6;
+ pBuf->size.w = pIcons->pBIG_Trade->w + adj_size(6);
add_to_gui_list(MAX_ID - pCity->id, pBuf);
/* ----------- */
my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->waste[O_TRADE]);
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
WF_DRAW_THEME_TRANSPARENT);
@@ -382,12 +383,12 @@
set_wflag(pBuf, WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
- pBuf->size.w = pIcons->pBIG_Trade_Corr->w + 6;
+ pBuf->size.w = pIcons->pBIG_Trade_Corr->w + adj_size(6);
add_to_gui_list(MAX_ID - pCity->id, pBuf);
/* ----------- */
- my_snprintf(cBuf, sizeof(cBuf), "%d", pcity->surplus[O_GOLD]);
- pStr = create_str16_from_char(cBuf, 10);
+ my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->surplus[O_GOLD]);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pStr->fgcol = *get_game_colorRGB(COLOR_STD_CITY_GOLD);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
@@ -396,12 +397,12 @@
set_wflag(pBuf, WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
- pBuf->size.w = pIcons->pBIG_Coin->w + 6;
+ pBuf->size.w = pIcons->pBIG_Coin->w + adj_size(6);
add_to_gui_list(MAX_ID - pCity->id, pBuf);
/* ----------- */
my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->prod[O_SCIENCE]);
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pStr->fgcol = *get_game_colorRGB(COLOR_STD_CITY_SCIENCE);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
@@ -410,12 +411,12 @@
set_wflag(pBuf, WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
- pBuf->size.w = pIcons->pBIG_Colb->w + 6;
+ pBuf->size.w = pIcons->pBIG_Colb->w + adj_size(6);
add_to_gui_list(MAX_ID - pCity->id, pBuf);
/* ----------- */
my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->prod[O_LUXURY]);
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pStr->fgcol = *get_game_colorRGB(COLOR_STD_CITY_LUX);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
@@ -424,13 +425,13 @@
set_wflag(pBuf, WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
- pBuf->size.w = pIcons->pBIG_Luxury->w + 6;
+ pBuf->size.w = pIcons->pBIG_Luxury->w + adj_size(6);
add_to_gui_list(MAX_ID - pCity->id, pBuf);
/* ----------- */
my_snprintf(cBuf, sizeof(cBuf), "%d",
pCity->prod[O_SHIELD] + pCity->waste[O_SHIELD]);
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pStr->fgcol = *get_game_colorRGB(COLOR_STD_CITY_PROD);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
@@ -439,12 +440,12 @@
set_wflag(pBuf, WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
- pBuf->size.w = pIcons->pBIG_Shield->w + 6;
+ pBuf->size.w = pIcons->pBIG_Shield->w + adj_size(6);
add_to_gui_list(MAX_ID - pCity->id, pBuf);
/* ----------- */
my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->waste[O_SHIELD]);
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
WF_DRAW_THEME_TRANSPARENT);
@@ -452,13 +453,13 @@
set_wflag(pBuf, WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
- pBuf->size.w = pIcons->pBIG_Shield_Corr->w + 6;
+ pBuf->size.w = pIcons->pBIG_Shield_Corr->w + adj_size(6);
add_to_gui_list(MAX_ID - pCity->id, pBuf);
/* ----------- */
my_snprintf(cBuf, sizeof(cBuf), "%d",
- pCity->prod[O_SHIELD] + pCity->waste[O_SHIELD] -
pCity->shield_surplus);
- pStr = create_str16_from_char(cBuf, 10);
+ pCity->prod[O_SHIELD] + pCity->waste[O_SHIELD] -
pCity->surplus[O_SHIELD]);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pStr->fgcol = *get_game_colorRGB(COLOR_STD_CITY_SUPPORT);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
@@ -467,34 +468,34 @@
set_wflag(pBuf, WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
- pBuf->size.w = pUnits_Icon->w + 6;
+ pBuf->size.w = pUnits_Icon->w + adj_size(6);
add_to_gui_list(MAX_ID - pCity->id, pBuf);
/* ----------- */
- my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->shield_surplus);
- pStr = create_str16_from_char(cBuf, 10);
+ my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->surplus[O_SHIELD]);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
- //pStr->forecol = *get_game_colorRGB(COLOR_STD_CITY_TRADE);
+ pStr->fgcol = *get_game_colorRGB(COLOR_STD_CITY_TRADE);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
WF_DRAW_THEME_TRANSPARENT);
if(count > 9 * COL) {
set_wflag(pBuf, WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
- pBuf->size.w = pIcons->pBIG_Shield_Surplus->w + 6;
+ pBuf->size.w = pIcons->pBIG_Shield_Surplus->w + adj_size(6);
add_to_gui_list(MAX_ID - pCity->id, pBuf);
/* ----------- */
if(pCity->production.is_unit) {
struct unit_type *pUnit = get_unit_type(pCity->production.value);
- pLogo = ResizeSurface(GET_SURF(pUnit->sprite), 36, 24, 1);
+ pLogo = ResizeSurface(GET_SURF(get_unittype_sprite(tileset,
get_unit_type(pCity->production.value))), adj_size(36), adj_size(24), 1);
SDL_SetColorKey(pLogo,
SDL_SRCCOLORKEY|SDL_RLEACCEL, get_first_pixel(pLogo));
- togrow = unit_build_shield_cost(pCity->production.value);
+ togrow = unit_build_shield_cost(get_unit_type(pCity->production.value));
pName = pUnit->name;
} else {
struct impr_type *pImprv = get_improvement_type(pCity->production.value);
- pLogo = ResizeSurface(GET_SURF(pImprv->sprite), 36, 24, 1);
+ pLogo = ResizeSurface(GET_SURF(get_building_sprite(tileset,
pCity->production.value)), adj_size(36), adj_size(24), 1);
togrow = impr_build_shield_cost(pCity->production.value);
pName = pImprv->name;
}
@@ -514,11 +515,11 @@
}
/* info string */
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
togrow = city_turns_to_build(pCity,
- pCity->production.value, pCity->production.is_unit, TRUE);
+ pCity->production, TRUE);
if(togrow == 999)
{
my_snprintf(cBuf, sizeof(cBuf), "%s", _("never"));
@@ -539,7 +540,7 @@
pBuf->action = popup_worklist_from_city_report_callback;
pBuf->data.city = pCity;
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pStr->fgcol = color;
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
@@ -555,15 +556,15 @@
pBuf->action = popup_buy_production_from_city_report_callback;
count += COL;
- h += (hh + 2);
+ h += (hh + adj_size(2));
} city_list_iterate_end;
H = hh;
pCityRep->pBeginWidgetList = pBuf;
/* setup window width */
- w = name_w + 6 + pText1->w + 8 + pCMA_Icon->w +
- (pIcons->pBIG_Food->w + 6) * 10 + pText2->w + 6 +
- pUnits_Icon->w + 6 + prod_w + 170;
+ w = name_w + adj_size(6) + pText1->w + adj_size(8) + pCMA_Icon->w +
+ (pIcons->pBIG_Food->w + adj_size(6)) * 10 + pText2->w + adj_size(6) +
+ pUnits_Icon->w + adj_size(6) + prod_w + adj_size(170);
if(count) {
pCityRep->pBeginActiveWidgetList = pBuf;
@@ -575,7 +576,7 @@
}
ww = create_vertical_scrollbar(pCityRep, COL, 10, TRUE, TRUE);
w += ww;
- h = (10 * (hh + 2)) + WINDOW_TILE_HIGH + 1 + FRAME_WH;
+ h = (10 * (hh + adj_size(2))) + WINDOW_TILE_HIGH + 1 + FRAME_WH;
} else {
h += WINDOW_TILE_HIGH + 1 + FRAME_WH;
}
@@ -583,8 +584,8 @@
h = WINDOW_TILE_HIGH + 1 + FRAME_WH;
}
- h += pText2->h + 40;
- w += DOUBLE_FRAME_WH + 2;
+ h += pText2->h + adj_size(40);
+ w += DOUBLE_FRAME_WH + adj_size(2);
pWindow->size.x = (Main.screen->w - w) / 2;
pWindow->size.y = (Main.screen->h - h) / 2;
@@ -602,53 +603,53 @@
/* exit button */
pBuf = pWindow->prev;
- pBuf->size.x = pWindow->size.x + pWindow->size.w - pBuf->size.w - FRAME_WH -
25;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - FRAME_WH -
5;
+ pBuf->size.x = pWindow->size.x + pWindow->size.w - pBuf->size.w - FRAME_WH -
adj_size(25);
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - FRAME_WH -
adj_size(5);
/* info button */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x - 5 - pBuf->size.w;
+ pBuf->size.x = pBuf->next->size.x - adj_size(5) - pBuf->size.w;
pBuf->size.y = pBuf->next->size.y;
/* happy button */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x - 5 - pBuf->size.w;
+ pBuf->size.x = pBuf->next->size.x - adj_size(5) - pBuf->size.w;
pBuf->size.y = pBuf->next->size.y;
/* army button */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x - 5 - pBuf->size.w;
+ pBuf->size.x = pBuf->next->size.x - adj_size(5) - pBuf->size.w;
pBuf->size.y = pBuf->next->size.y;
/* supported button */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x - 5 - pBuf->size.w;
+ pBuf->size.x = pBuf->next->size.x - adj_size(5) - pBuf->size.w;
pBuf->size.y = pBuf->next->size.y;
/* cities background and labels */
- dst.x = FRAME_WH + 2;
- dst.y = WINDOW_TILE_HIGH + 2;
- dst.w = (name_w + 6) + (pText1->w + 8) + 5;
- dst.h = h - WINDOW_TILE_HIGH - 2 - FRAME_WH - 32;
+ dst.x = FRAME_WH + adj_size(2);
+ dst.y = WINDOW_TILE_HIGH + adj_size(2);
+ dst.w = (name_w + adj_size(6)) + (pText1->w + adj_size(8)) + adj_size(5);
+ dst.h = h - WINDOW_TILE_HIGH - adj_size(2) - FRAME_WH - adj_size(32);
SDL_FillRectAlpha(pWindow->theme, &dst, &color);
putframe(pWindow->theme, dst.x , dst.y,
dst.x + dst.w, dst.y + dst.h - 1, 0xFF000000);
dst.y += (pText2->h - pText3->h) / 2;
- dst.x += ((name_w + 6) - pText3->w) / 2;
+ dst.x += ((name_w + adj_size(6)) - pText3->w) / 2;
SDL_BlitSurface(pText3, NULL, pWindow->theme, &dst);
FREESURFACE(pText3);
/* city size background and label */
- dst.x = FRAME_WH + 5 + name_w + 5 + 4;
+ dst.x = FRAME_WH + adj_size(5) + name_w + adj_size(5 + 4);
SDL_BlitSurface(pText1, NULL, pWindow->theme, &dst);
ww = pText1->w;
FREESURFACE(pText1);
/* cma icon */
- dst.x += (ww + 9);
- dst.y = WINDOW_TILE_HIGH + 2 + (pText2->h - pCMA_Icon->h) / 2;
+ dst.x += (ww + adj_size(9));
+ dst.y = WINDOW_TILE_HIGH + adj_size(2) + (pText2->h - pCMA_Icon->h) / 2;
SDL_BlitSurface(pCMA_Icon, NULL, pWindow->theme, &dst);
ww = pCMA_Icon->w;
FREESURFACE(pCMA_Icon);
@@ -656,32 +657,32 @@
/* -------------- */
/* populations food unkeep background and label */
dst.x += (ww + 1);
- dst.y = WINDOW_TILE_HIGH + 2;
- w = dst.x + 2;
- dst.w = (pIcons->pBIG_Food->w + 6) + 10 +
- (pIcons->pBIG_Food_Surplus->w + 6) + 10 +
- pText2->w + 6 + 2;
- dst.h = h - WINDOW_TILE_HIGH - 2 - FRAME_WH - 32;
- color = *get_game_colorRGB(COLOR_STD_GROUND);
+ dst.y = WINDOW_TILE_HIGH + adj_size(2);
+ w = dst.x + adj_size(2);
+ dst.w = (pIcons->pBIG_Food->w + adj_size(6)) + adj_size(10) +
+ (pIcons->pBIG_Food_Surplus->w + adj_size(6)) + adj_size(10) +
+ pText2->w + adj_size(6 + 2);
+ dst.h = h - WINDOW_TILE_HIGH - adj_size(2) - FRAME_WH - adj_size(32);
+ color = *get_game_colorRGB(COLOR_OVERVIEW_LAND);
color.unused = 96;
SDL_FillRectAlpha(pWindow->theme, &dst, &color);
putframe(pWindow->theme, dst.x , dst.y,
dst.x + dst.w, dst.y + dst.h - 1, 0xFF000000);
- dst.y = WINDOW_TILE_HIGH + 2 + (pText2->h - pIcons->pBIG_Food->h) / 2;
- dst.x += 5;
+ dst.y = WINDOW_TILE_HIGH + adj_size(2) + (pText2->h - pIcons->pBIG_Food->h)
/ 2;
+ dst.x += adj_size(5);
SDL_BlitSurface(pIcons->pBIG_Food, NULL, pWindow->theme, &dst);
/* food surplus Icon */
- w += (pIcons->pBIG_Food->w + 6) + 10;
- dst.x = w + 3;
+ w += (pIcons->pBIG_Food->w + adj_size(6)) + adj_size(10);
+ dst.x = w + adj_size(3);
SDL_BlitSurface(pIcons->pBIG_Food_Surplus, NULL, pWindow->theme, &dst);
/* to grow label */
- w += (pIcons->pBIG_Food_Surplus->w + 6) + 10;
- dst.x = w + 3;
- dst.y = WINDOW_TILE_HIGH + 2;
+ w += (pIcons->pBIG_Food_Surplus->w + adj_size(6)) + adj_size(10);
+ dst.x = w + adj_size(3);
+ dst.y = WINDOW_TILE_HIGH + adj_size(2);
SDL_BlitSurface(pText2, NULL, pWindow->theme, &dst);
hh = pText2->h;
ww = pText2->w;
@@ -689,15 +690,15 @@
/* -------------- */
/* trade, corruptions, gold, science, luxury income background and label */
- dst.x = w + (ww + 8);
- dst.y = WINDOW_TILE_HIGH + 2;
- w = dst.x + 2;
- dst.w = (pIcons->pBIG_Trade->w + 6) + 10 +
- (pIcons->pBIG_Trade_Corr->w + 6) + 10 +
- (pIcons->pBIG_Coin->w + 6) + 10 +
- (pIcons->pBIG_Colb->w + 6) + 10 +
- (pIcons->pBIG_Luxury->w + 6) + 4;
- dst.h = h - WINDOW_TILE_HIGH - 2 - FRAME_WH - 32;
+ dst.x = w + (ww + adj_size(8));
+ dst.y = WINDOW_TILE_HIGH + adj_size(2);
+ w = dst.x + adj_size(2);
+ dst.w = (pIcons->pBIG_Trade->w + adj_size(6)) + adj_size(10) +
+ (pIcons->pBIG_Trade_Corr->w + adj_size(6)) + adj_size(10) +
+ (pIcons->pBIG_Coin->w + adj_size(6)) + adj_size(10) +
+ (pIcons->pBIG_Colb->w + adj_size(6)) + adj_size(10) +
+ (pIcons->pBIG_Luxury->w + adj_size(6)) + adj_size(4);
+ dst.h = h - WINDOW_TILE_HIGH - adj_size(2) - FRAME_WH - adj_size(32);
color = *get_game_colorRGB(COLOR_STD_CITY_TRADE);
color.unused = 96;
@@ -706,37 +707,37 @@
putframe(pWindow->theme, dst.x , dst.y,
dst.x + dst.w, dst.y + dst.h - 1, 0xFF000000);
- dst.y = WINDOW_TILE_HIGH + 2 + (hh - pIcons->pBIG_Trade->h) / 2;
- dst.x += 5;
+ dst.y = WINDOW_TILE_HIGH + adj_size(2) + (hh - pIcons->pBIG_Trade->h) / 2;
+ dst.x += adj_size(5);
SDL_BlitSurface(pIcons->pBIG_Trade, NULL, pWindow->theme, &dst);
- w += (pIcons->pBIG_Trade->w + 6) + 10;
- dst.x = w + 3;
+ w += (pIcons->pBIG_Trade->w + adj_size(6)) + adj_size(10);
+ dst.x = w + adj_size(3);
SDL_BlitSurface(pIcons->pBIG_Trade_Corr, NULL, pWindow->theme, &dst);
- w += (pIcons->pBIG_Food_Corr->w + 6) + 10;
- dst.x = w + 3;
+ w += (pIcons->pBIG_Food_Corr->w + adj_size(6)) + adj_size(10);
+ dst.x = w + adj_size(3);
SDL_BlitSurface(pIcons->pBIG_Coin, NULL, pWindow->theme, &dst);
- w += (pIcons->pBIG_Coin->w + 6) + 10;
- dst.x = w + 3;
+ w += (pIcons->pBIG_Coin->w + adj_size(6)) + adj_size(10);
+ dst.x = w + adj_size(3);
SDL_BlitSurface(pIcons->pBIG_Colb, NULL, pWindow->theme, &dst);
- w += (pIcons->pBIG_Colb->w + 6) + 10;
- dst.x = w + 3;
+ w += (pIcons->pBIG_Colb->w + adj_size(6)) + adj_size(10);
+ dst.x = w + adj_size(3);
SDL_BlitSurface(pIcons->pBIG_Luxury, NULL, pWindow->theme, &dst);
/* --------------------- */
/* total productions, waste, support, shields surplus background and label */
- w += (pIcons->pBIG_Luxury->w + 6) + 4;
+ w += (pIcons->pBIG_Luxury->w + adj_size(6)) + adj_size(4);
dst.x = w;
- w += 2;
- dst.y = WINDOW_TILE_HIGH + 2;
- dst.w = (pIcons->pBIG_Shield->w + 6) + 10 +
- (pIcons->pBIG_Shield_Corr->w + 6) + 10 +
- (pUnits_Icon->w + 6) + 10 +
- (pIcons->pBIG_Shield_Surplus->w + 6) + 4;
- dst.h = h - WINDOW_TILE_HIGH - 2 - FRAME_WH - 32;
+ w += adj_size(2);
+ dst.y = WINDOW_TILE_HIGH + adj_size(2);
+ dst.w = (pIcons->pBIG_Shield->w + adj_size(6)) + adj_size(10) +
+ (pIcons->pBIG_Shield_Corr->w + adj_size(6)) + adj_size(10) +
+ (pUnits_Icon->w + adj_size(6)) + adj_size(10) +
+ (pIcons->pBIG_Shield_Surplus->w + adj_size(6)) + adj_size(4);
+ dst.h = h - WINDOW_TILE_HIGH - adj_size(2) - FRAME_WH - adj_size(32);
color = *get_game_colorRGB(COLOR_STD_CITY_PROD);
color.unused = 96;
@@ -745,47 +746,47 @@
putframe(pWindow->theme, dst.x , dst.y,
dst.x + dst.w, dst.y + dst.h - 1, 0xFF000000);
- dst.y = WINDOW_TILE_HIGH + 2 + (hh - pIcons->pBIG_Shield->h) / 2;
- dst.x += 5;
+ dst.y = WINDOW_TILE_HIGH + adj_size(2) + (hh - pIcons->pBIG_Shield->h) / 2;
+ dst.x += adj_size(5);
SDL_BlitSurface(pIcons->pBIG_Shield, NULL, pWindow->theme, &dst);
- w += (pIcons->pBIG_Shield->w + 6) + 10;
- dst.x = w + 3;
+ w += (pIcons->pBIG_Shield->w + adj_size(6)) + adj_size(10);
+ dst.x = w + adj_size(3);
SDL_BlitSurface(pIcons->pBIG_Shield_Corr, NULL, pWindow->theme, &dst);
- w += (pIcons->pBIG_Shield_Corr->w + 6) + 10;
- dst.x = w + 3;
- dst.y = WINDOW_TILE_HIGH + 2 + (hh - pUnits_Icon->h) / 2;
+ w += (pIcons->pBIG_Shield_Corr->w + adj_size(6)) + adj_size(10);
+ dst.x = w + adj_size(3);
+ dst.y = WINDOW_TILE_HIGH + adj_size(2) + (hh - pUnits_Icon->h) / 2;
SDL_BlitSurface(pUnits_Icon, NULL, pWindow->theme, &dst);
- w += (pUnits_Icon->w + 6) + 10;
+ w += (pUnits_Icon->w + adj_size(6)) + adj_size(10);
FREESURFACE(pUnits_Icon);
- dst.x = w + 3;
- dst.y = WINDOW_TILE_HIGH + 2 + (hh - pIcons->pBIG_Shield_Surplus->h) / 2;
+ dst.x = w + adj_size(3);
+ dst.y = WINDOW_TILE_HIGH + adj_size(2) + (hh -
pIcons->pBIG_Shield_Surplus->h) / 2;
SDL_BlitSurface(pIcons->pBIG_Shield_Surplus, NULL, pWindow->theme, &dst);
/* ------------------------------- */
- w += (pIcons->pBIG_Shield_Surplus->w + 6) + 10;
+ w += (pIcons->pBIG_Shield_Surplus->w + adj_size(6)) + adj_size(10);
dst.x = w;
- w += 2;
- dst.y = WINDOW_TILE_HIGH + 2;
- dst.w = 36 + 5 + prod_w;
- dst.h = hh + 2;
+ w += adj_size(2);
+ dst.y = WINDOW_TILE_HIGH + adj_size(2);
+ dst.w = adj_size(36) + adj_size(5) + prod_w;
+ dst.h = hh + adj_size(2);
SDL_FillRectAlpha(pWindow->theme, &dst, &color);
putframe(pWindow->theme, dst.x , dst.y,
dst.x + dst.w, dst.y + dst.h - 1, 0xFF000000);
- dst.y = WINDOW_TILE_HIGH + 2 + (hh - pText4->h) / 2;
+ dst.y = WINDOW_TILE_HIGH + adj_size(2) + (hh - pText4->h) / 2;
dst.x += (dst.w - pText4->w) / 2;;
SDL_BlitSurface(pText4, NULL, pWindow->theme, &dst);
FREESURFACE(pText4);
if(count) {
- int start_x = pWindow->size.x + FRAME_WH + 5;
- int start_y = pWindow->size.y + WINDOW_TILE_HIGH + 2 + hh + 2;
- H += 2;
+ int start_x = pWindow->size.x + FRAME_WH + adj_size(5);
+ int start_y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(2) + hh +
adj_size(2);
+ H += adj_size(2);
pBuf = pBuf->prev;
while(TRUE) {
@@ -796,83 +797,83 @@
/* cit size */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 5;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(5);
pBuf->size.y = start_y + (H - pBuf->size.h) / 2;
/* cma */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 6;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(6);
pBuf->size.y = start_y + (H - pBuf->size.h) / 2;
/* food cons. */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 6;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(6);
pBuf->size.y = start_y + (H - pBuf->size.h) / 2;
/* food surplus */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = start_y + (H - pBuf->size.h) / 2;
/* time to grow */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = start_y + (H - pBuf->size.h) / 2;
/* trade */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 5;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(5);
pBuf->size.y = start_y + (H - pBuf->size.h) / 2;
/* trade corruptions */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = start_y + (H - pBuf->size.h) / 2;
/* net gold income */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = start_y + (H - pBuf->size.h) / 2;
/* science income */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = start_y + (H - pBuf->size.h) / 2;
/* luxuries income */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = start_y + (H - pBuf->size.h) / 2;
/* total production */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 6;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(6);
pBuf->size.y = start_y + (H - pBuf->size.h) / 2;
/* waste */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = start_y + (H - pBuf->size.h) / 2;
/* units support */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = start_y + (H - pBuf->size.h) / 2;
/* producrion surplus */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = start_y + (H - pBuf->size.h) / 2;
/* currently build */
/* icon */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = start_y + (H - pBuf->size.h) / 2;
/* label */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 5;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(5);
pBuf->size.y = start_y + (H - pBuf->size.h) / 2;
pBuf->size.w = prod_w;
@@ -901,7 +902,8 @@
static struct GUI * real_city_report_dialog_update_city(struct GUI *pWidget,
struct city *pCity)
{
- char cBuf[64], *pName;
+ char cBuf[64];
+ const char *pName;
int togrow;
SDL_Surface *pLogo;
SDL_Rect dst;
@@ -932,12 +934,12 @@
/* food consumptions */
pWidget = pWidget->prev;
- my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->prod[O_FOOD] -
pCity->food_surplus);
+ my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->prod[O_FOOD] -
pCity->surplus[O_FOOD]);
copy_chars_to_string16(pWidget->string16, cBuf);
/* food surplus */
pWidget = pWidget->prev;
- my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->food_surplus);
+ my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->surplus[O_FOOD]);
copy_chars_to_string16(pWidget->string16, cBuf);
/* time to grow */
@@ -964,7 +966,7 @@
/* trade production */
pWidget = pWidget->prev;
- my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->trade_prod);
+ my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->surplus[O_TRADE]);
copy_chars_to_string16(pWidget->string16, cBuf);
/* corruptions */
@@ -974,7 +976,7 @@
/* gold surplus */
pWidget = pWidget->prev;
- my_snprintf(cBuf, sizeof(cBuf), "%d", pcity->surplus[O_GOLD]);
+ my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->surplus[O_GOLD]);
copy_chars_to_string16(pWidget->string16, cBuf);
/* science income */
@@ -1000,26 +1002,28 @@
/* units support */
pWidget = pWidget->prev;
- my_snprintf(cBuf, sizeof(cBuf), "%d",
- pCity->prod[O_SHIELD] + pCity->waste[O_SHIELD] -
pCity->shield_surplus);
+ my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->prod[O_SHIELD] +
+ pCity->waste[O_SHIELD] -
pCity->surplus[O_SHIELD]);
copy_chars_to_string16(pWidget->string16, cBuf);
/* production income */
pWidget = pWidget->prev;
- my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->shield_surplus);
+ my_snprintf(cBuf, sizeof(cBuf), "%d", pCity->surplus[O_SHIELD]);
copy_chars_to_string16(pWidget->string16, cBuf);
/* change production */
if(pCity->production.is_unit) {
struct unit_type *pUnit = get_unit_type(pCity->production.value);
- pLogo = ResizeSurface(GET_SURF(pUnit->sprite), 36, 24, 1);
+ pLogo = ResizeSurface(GET_SURF(get_unittype_sprite(tileset,
+ get_unit_type(pCity->production.value))),
adj_size(36), adj_size(24), 1);
SDL_SetColorKey(pLogo,
SDL_SRCCOLORKEY|SDL_RLEACCEL, get_first_pixel(pLogo));
- togrow = unit_build_shield_cost(pCity->production.value);
+ togrow = unit_build_shield_cost(get_unit_type(pCity->production.value));
pName = pUnit->name;
} else {
struct impr_type *pImprv = get_improvement_type(pCity->production.value);
- pLogo = ResizeSurface(GET_SURF(pImprv->sprite), 36, 24, 1);
+ pLogo = ResizeSurface(GET_SURF(get_building_sprite(tileset,
+ pCity->production.value)), adj_size(36),
adj_size(24), 1);
togrow = impr_build_shield_cost(pCity->production.value);
pName = pImprv->name;
}
@@ -1046,7 +1050,7 @@
/* hurry productions */
pWidget = pWidget->prev;
togrow = city_turns_to_build(pCity,
- pCity->production.value, pCity->production.is_unit, TRUE);
+ pCity->production, TRUE);
if(togrow == 999)
{
my_snprintf(cBuf, sizeof(cBuf), "%s", _("never"));
@@ -1159,7 +1163,7 @@
/****************************************************************
Toggle a city's hilited status.
*****************************************************************/
-void toggle_city_hilite(struct city *pcity, bool on_off)
+void toggle_city_hilite(struct city *pCity, bool on_off)
{
freelog(LOG_DEBUG, "toggle_city_hilite : PORT ME");
}
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/cma_fe.c
devel/client/gui-sdl/cma_fe.c
--- devel_distclean/client/gui-sdl/cma_fe.c 2005-10-16 00:08:13.000000000
+0200
+++ devel/client/gui-sdl/cma_fe.c 2005-11-15 06:52:44.000000000 +0100
@@ -55,6 +55,10 @@
struct cm_parameter edited_cm_parm;
} *pCma = NULL;
+enum specialist_type {
+ SP_ELVIS, SP_SCIENTIST, SP_TAXMAN, SP_LAST
+};
+
static void set_cma_hscrollbars(void);
/* =================================================================== */
@@ -264,11 +268,11 @@
pCma->pAdv = MALLOC(sizeof(struct ADVANCED_DLG));
- hh = WINDOW_TILE_HIGH + 2;
- pStr = create_str16_from_char(_("Name new preset"), 12);
+ hh = WINDOW_TILE_HIGH + adj_size(2);
+ pStr = create_str16_from_char(_("Name new preset"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 100, 100, 0);
+ pWindow = create_window(NULL, pStr, adj_size(100), adj_size(100), 0);
pWindow->action = save_cma_window_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -279,7 +283,7 @@
/* ============================================================= */
/* label */
- pStr = create_str16_from_char(_("What should we name the preset?"), 10);
+ pStr = create_str16_from_char(_("What should we name the preset?"),
adj_font(10));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pStr->fgcol.r = 255;
pStr->fgcol.g = 255;
@@ -287,11 +291,11 @@
pText = create_text_surf_from_str16(pStr);
FREESTRING16(pStr);
ww = MAX(ww, pText->w);
- hh += pText->h + 5;
+ hh += pText->h + adj_size(5);
/* ============================================================= */
pBuf = create_edit(NULL, pWindow->dst,
- create_str16_from_char(_("new preset"), 12), 100,
+ create_str16_from_char(_("new preset"), adj_font(12)),
adj_size(100),
(WF_DRAW_THEME_TRANSPARENT|WF_FREE_STRING));
set_wstate(pBuf, FC_WS_NORMAL);
hh += pBuf->size.h;
@@ -301,7 +305,7 @@
/* ============================================================= */
pBuf = create_themeicon_button_from_chars(pTheme->OK_Icon, pWindow->dst,
- _("Yes"), 12, 0);
+ _("Yes"), adj_font(12), 0);
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
pBuf->action = ok_save_cma_callback;
@@ -311,7 +315,7 @@
pBuf->data.ptr = (void *)pBuf->next;
pBuf = create_themeicon_button_from_chars(pTheme->CANCEL_Icon,
- pWindow->dst, _("No"), 12, 0);
+ pWindow->dst, _("No"), adj_font(12), 0);
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
pBuf->action = cancel_SLD_cma_callback;
set_wstate(pBuf, FC_WS_NORMAL);
@@ -322,13 +326,13 @@
hh += pBuf->size.h;
pBuf->size.w = MAX(pBuf->next->size.w, pBuf->size.w);
pBuf->next->size.w = pBuf->size.w;
- ww = MAX(ww, 2 * pBuf->size.w + 20);
+ ww = MAX(ww, 2 * pBuf->size.w + adj_size(20));
pCma->pAdv->pBeginWidgetList = pBuf;
/* setup window size and start position */
- ww += 20;
- hh += 15;
+ ww += adj_size(20);
+ hh += adj_size(15);
pWindow->size.x = pWidget->size.x - (ww + DOUBLE_FRAME_WH) / 2;
pWindow->size.y = pWidget->size.y - (hh + FRAME_WH);
@@ -340,27 +344,27 @@
/* setup rest of widgets */
/* label */
dst.x = FRAME_WH + (pWindow->size.w - DOUBLE_FRAME_WH - pText->w) / 2;
- dst.y = WINDOW_TILE_HIGH + 2;
+ dst.y = WINDOW_TILE_HIGH + adj_size(2);
SDL_BlitSurface(pText, NULL, pWindow->theme, &dst);
- dst.y += pText->h + 5;
+ dst.y += pText->h + adj_size(5);
FREESURFACE(pText);
/* edit */
pBuf = pWindow->prev;
- pBuf->size.w = pWindow->size.w - 10;
- pBuf->size.x = pWindow->size.x + 5;
+ pBuf->size.w = pWindow->size.w - adj_size(10);
+ pBuf->size.x = pWindow->size.x + adj_size(5);
pBuf->size.y = pWindow->size.y + dst.y;
- dst.y += pBuf->size.h + 5;
+ dst.y += pBuf->size.h + adj_size(5);
/* yes */
pBuf = pBuf->prev;
pBuf->size.x = pWindow->size.x +
- (pWindow->size.w - DOUBLE_FRAME_WH - (2 * pBuf->size.w + 20)) / 2;
+ (pWindow->size.w - DOUBLE_FRAME_WH - (2 * pBuf->size.w +
adj_size(20))) / 2;
pBuf->size.y = pWindow->size.y + dst.y;
/* no */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 20;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(20);
pBuf->size.y = pBuf->next->size.y;
/* ================================================== */
@@ -433,10 +437,10 @@
pCma->pAdv = MALLOC(sizeof(struct ADVANCED_DLG));
- pStr = create_str16_from_char(_("Presets"), 12);
+ pStr = create_str16_from_char(_("Presets"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 10, 10, WF_DRAW_THEME_TRANSPARENT);
+ pWindow = create_window(NULL, pStr, adj_size(10), adj_size(10),
WF_DRAW_THEME_TRANSPARENT);
pWindow->action = save_cma_window_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -453,7 +457,7 @@
pBuf->action = cancel_SLD_cma_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
- ww += (pBuf->size.w + 10);
+ ww += (pBuf->size.w + adj_size(10));
add_to_gui_list(ID_BUTTON, pBuf);
/* ---------- */
@@ -489,7 +493,7 @@
pCma->pAdv->pEndActiveWidgetList = pWindow->prev->prev;
pCma->pAdv->pActiveWidgetList = pWindow->prev->prev;
- ww += (DOUBLE_FRAME_WH + 2);
+ ww += (DOUBLE_FRAME_WH + adj_size(2));
hh += FRAME_WH + 1;
if (count > 11)
@@ -517,7 +521,7 @@
pBuf->size.y = pWindow->size.y + 1;
pBuf = pBuf->prev;
- ww -= (DOUBLE_FRAME_WH + 2);
+ ww -= (DOUBLE_FRAME_WH + adj_size(2));
hh = (pCma->pAdv->pScroll ? pCma->pAdv->pScroll->pUp_Left_Button->size.h + 1
: 0);
setup_vertical_widgets_position(1, pWindow->size.x + FRAME_WH + 1,
pWindow->size.y + WINDOW_TILE_HIGH + 1 + hh, ww, 0,
@@ -589,7 +593,6 @@
static void set_cma_hscrollbars(void)
{
- int i;
struct GUI *pBuf;
char cBuf[4];
@@ -608,7 +611,7 @@
/* min scrollbar */
pBuf = pBuf->prev;
pBuf->size.x = pBuf->next->size.x
- + pBuf->next->size.w + 5 + 20 + *(int *)pBuf->data.ptr;
+ + pBuf->next->size.w + adj_size(5) + adj_size(20) + *(int
*)pBuf->data.ptr;
/* factor label */
pBuf = pBuf->prev;
@@ -618,7 +621,7 @@
/* factor scrollbar*/
pBuf = pBuf->prev;
pBuf->size.x = pBuf->next->size.x
- + pBuf->next->size.w + 5 + *(int *)pBuf->data.ptr - 1;
+ + pBuf->next->size.w + adj_size(5) + *(int *)pBuf->data.ptr - 1;
} output_type_iterate_end;
@@ -630,7 +633,7 @@
/* happy factor scrollbar */
pBuf = pBuf->prev;
pBuf->size.x = pBuf->next->size.x
- + pBuf->next->size.w + 5 + *(int *)pBuf->data.ptr - 1;
+ + pBuf->next->size.w + adj_size(5) + *(int *)pBuf->data.ptr - 1;
}
@@ -662,23 +665,25 @@
if(result.found_a_valid) {
/* redraw resources */
pCma->pResult = &result;
+#if 0
refresh_city_resource_map(pBuf->dst, pBuf->size.x + 25,
pBuf->size.y + WINDOW_TILE_HIGH + 35, pCma->pCity, is_worker);
+#endif
pCma->pResult = NULL;
/* redraw Citizens */
count = pCma->pCity->size;
- pText = get_citizen_surface(CITIZEN_ELVIS, 0);
- step = (pBuf->size.w - 20) / pText->w;
+ pText = GET_SURF(get_tax_sprite(tileset, O_LUXURY));
+ step = (pBuf->size.w - adj_size(20)) / pText->w;
if (count > step) {
- step = (pBuf->size.w - 20 - pText->w) / (count - 1);
+ step = (pBuf->size.w - adj_size(20) - pText->w) / (count - 1);
} else {
step = pText->w;
}
dst.y = pBuf->size.y + WINDOW_TILE_HIGH + 1;
- dst.x = pBuf->size.x + 10;
+ dst.x = pBuf->size.x + adj_size(10);
for (i = 0;
i < count - (result.specialists[SP_ELVIS]
@@ -689,19 +694,19 @@
dst.x += step;
}
- pText = get_citizen_surface(CITIZEN_ELVIS, 0);
+ pText = GET_SURF(get_tax_sprite(tileset, O_LUXURY));
for (i = 0; i < result.specialists[SP_ELVIS]; i++) {
SDL_BlitSurface(pText, NULL, pBuf->dst, &dst);
dst.x += step;
}
- pText = get_citizen_surface(CITIZEN_TAXMAN, 0);
+ pText = GET_SURF(get_tax_sprite(tileset, O_GOLD));
for (i = 0; i < result.specialists[SP_TAXMAN]; i++) {
SDL_BlitSurface(pText, NULL, pBuf->dst, &dst);
dst.x += step;
}
- pText = get_citizen_surface(CITIZEN_SCIENTIST, 0);
+ pText = GET_SURF(get_tax_sprite(tileset, O_SCIENCE));
for (i = 0; i < result.specialists[SP_SCIENTIST]; i++) {
SDL_BlitSurface(pText, NULL, pBuf->dst, &dst);
dst.x += step;
@@ -716,16 +721,16 @@
FREESTRING16(pStr);
/* fill result text background */
- dst.x = pBuf->size.x + 10;
- dst.y = pBuf->size.y + WINDOW_TILE_HIGH + 150;
- dst.w = pText->w + 10;
- dst.h = pText->h + 10;
+ dst.x = pBuf->size.x + adj_size(10);
+ dst.y = pBuf->size.y + WINDOW_TILE_HIGH + adj_size(150);
+ dst.w = pText->w + adj_size(10);
+ dst.h = pText->h + adj_size(10);
SDL_FillRectAlpha(pBuf->dst, &dst, &color);
putframe(pBuf->dst, dst.x, dst.y,
dst.x + dst.w - 1, dst.y + dst.h - 1, 0xff000000);
- dst.x += 5;
- dst.y += 5;
+ dst.x += adj_size(5);
+ dst.y += adj_size(5);
SDL_BlitSurface(pText, NULL, pBuf->dst, &dst);
FREESURFACE(pText);
@@ -799,7 +804,7 @@
SDL_Surface *pCity_Map;
SDL_String16 *pStr;
char cBuf[128];
- int i, w, h, text_w, x, cs;
+ int w, h, text_w, x, cs;
SDL_Rect dst, area;
SDL_Color color = {255, 255, 255, 136};
@@ -823,10 +828,10 @@
pCity->name, population_to_text(city_population(pCity)),
_("Citizen Management Agent"));
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 10, 10, 0);
+ pWindow = create_window(NULL, pStr, adj_size(10), adj_size(10), 0);
pWindow->action = cma_dlg_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -842,11 +847,11 @@
pBuf->action = exit_cma_dialog_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
- w += (pBuf->size.w + 10);
+ w += (pBuf->size.w + adj_size(10));
add_to_gui_list(ID_BUTTON, pBuf);
- pStr = create_string16(NULL, 0, 12);
+ pStr = create_string16(NULL, 0, adj_font(12));
text_w = 0;
copy_chars_to_string16(pStr, _("Minimal Surplus"));
@@ -863,14 +868,14 @@
/* minimal label */
pBuf = create_iconlabel(NULL, pWindow->dst,
- create_str16_from_char("999", 10),
+ create_str16_from_char("999", adj_font(10)),
(WF_FREE_STRING | WF_DRAW_THEME_TRANSPARENT));
add_to_gui_list(ID_LABEL, pBuf);
/* minimal scrollbar */
- pBuf = create_horizontal(pTheme->Horiz, pWindow->dst, 30,
+ pBuf = create_horizontal(pTheme->Horiz, pWindow->dst, adj_size(30),
(WF_DRAW_THEME_TRANSPARENT));
pBuf->action = min_horiz_cma_callback;
@@ -882,13 +887,13 @@
/* factor label */
pBuf = create_iconlabel(NULL, pWindow->dst,
- create_str16_from_char("999", 10),
+ create_str16_from_char("999", adj_font(10)),
(WF_FREE_STRING | WF_DRAW_THEME_TRANSPARENT));
add_to_gui_list(ID_LABEL, pBuf);
/* factor scrollbar */
- pBuf = create_horizontal(pTheme->Horiz, pWindow->dst, 30,
+ pBuf = create_horizontal(pTheme->Horiz, pWindow->dst, adj_size(30),
(WF_DRAW_THEME_TRANSPARENT));
pBuf->action = factor_horiz_cma_callback;
@@ -905,13 +910,13 @@
/* happy factor label */
pBuf = create_iconlabel(NULL, pWindow->dst,
- create_str16_from_char("999", 10),
+ create_str16_from_char("999", adj_font(10)),
(WF_FREE_STRING | WF_DRAW_THEME_TRANSPARENT));
add_to_gui_list(ID_LABEL, pBuf);
/* happy factor scrollbar */
- pBuf = create_horizontal(pTheme->Horiz, pWindow->dst, 30,
+ pBuf = create_horizontal(pTheme->Horiz, pWindow->dst, adj_size(30),
(WF_DRAW_THEME_TRANSPARENT));
pBuf->action = factor_horiz_cma_callback;
@@ -934,7 +939,7 @@
(WF_DRAW_THEME_TRANSPARENT|WF_WIDGET_HAS_INFO_LABEL|WF_FREE_STRING));
pBuf->action = save_cma_callback;
- pBuf->string16 = create_str16_from_char(_("Save settings as..."), 10);
+ pBuf->string16 = create_str16_from_char(_("Save settings as..."),
adj_font(10));
add_to_gui_list(ID_ICON, pBuf);
@@ -943,7 +948,7 @@
(WF_DRAW_THEME_TRANSPARENT|WF_WIDGET_HAS_INFO_LABEL|WF_FREE_STRING));
pBuf->action = load_cma_callback;
- pBuf->string16 = create_str16_from_char(_("Load settings"), 10);
+ pBuf->string16 = create_str16_from_char(_("Load settings"), adj_font(10));
add_to_gui_list(ID_ICON, pBuf);
@@ -952,7 +957,7 @@
(WF_DRAW_THEME_TRANSPARENT|WF_WIDGET_HAS_INFO_LABEL|WF_FREE_STRING));
pBuf->action = del_cma_callback;
- pBuf->string16 = create_str16_from_char(_("Delete settings"), 10);
+ pBuf->string16 = create_str16_from_char(_("Delete settings"), adj_font(10));
add_to_gui_list(ID_ICON, pBuf);
@@ -961,7 +966,7 @@
(WF_DRAW_THEME_TRANSPARENT|WF_WIDGET_HAS_INFO_LABEL|WF_FREE_STRING));
pBuf->action = run_cma_callback;
- pBuf->string16 = create_str16_from_char(_("Control city"), 10);
+ pBuf->string16 = create_str16_from_char(_("Control city"), adj_font(10));
add_to_gui_list(ID_ICON, pBuf);
@@ -970,7 +975,7 @@
(WF_DRAW_THEME_TRANSPARENT|WF_WIDGET_HAS_INFO_LABEL|WF_FREE_STRING));
pBuf->action = run_cma_once_callback;
- pBuf->string16 = create_str16_from_char(_("Apply once"), 10);
+ pBuf->string16 = create_str16_from_char(_("Apply once"), adj_font(10));
add_to_gui_list(ID_ICON, pBuf);
@@ -979,17 +984,17 @@
(WF_DRAW_THEME_TRANSPARENT|WF_WIDGET_HAS_INFO_LABEL|WF_FREE_STRING));
pBuf->action = stop_cma_callback;
- pBuf->string16 = create_str16_from_char(_("Release city"), 10);
+ pBuf->string16 = create_str16_from_char(_("Release city"), adj_font(10));
add_to_gui_list(ID_ICON, pBuf);
/* -------------------------------- */
pCma->pDlg->pBeginWidgetList = pBuf;
- w = MAX(pCity_Map->w + 70 + text_w + 10 +
- (pWindow->prev->prev->size.w + 5 + 70 + 5 +
- pWindow->prev->prev->size.w + 5 + 55 + 15), w);
- h = 320;
+ w = MAX(pCity_Map->w + adj_size(70) + text_w + adj_size(10) +
+ (pWindow->prev->prev->size.w + adj_size(5 + 70 + 5) +
+ pWindow->prev->prev->size.w + adj_size(5 + 55 + 15)),
w);
+ h = adj_size(320);
pWindow->size.x = (Main.screen->w - w) / 2;
pWindow->size.y = (Main.screen->h - h) / 2;
@@ -1009,48 +1014,48 @@
pBuf->size.y = pWindow->size.y + 1;
/* ---------- */
- dst.x = pCity_Map->w + 50 +
- (pWindow->size.w - (pCity_Map->w + 40) -
- (text_w + 10 + pWindow->prev->prev->size.w + 5 + 70 + 5 +
- pWindow->prev->prev->size.w + 5 + 55)) / 2;
- dst.y = 75;
-
- x = area.x = dst.x - 10;
- area.y = dst.y - 20;
- w = area.w = 10 + text_w + 10 + pWindow->prev->prev->size.w + 5 + 70 + 5 +
- pWindow->prev->prev->size.w + 5 + 55 + 10;
- area.h = (O_COUNT + 1) * (pText[0]->h + 6) + 20;
+ dst.x = pCity_Map->w + adj_size(50) +
+ (pWindow->size.w - (pCity_Map->w + adj_size(40)) -
+ (text_w + adj_size(10) + pWindow->prev->prev->size.w + adj_size(5 +
70 + 5) +
+ pWindow->prev->prev->size.w + adj_size(5 + 55))) / 2;
+ dst.y = adj_size(75);
+
+ x = area.x = dst.x - adj_size(10);
+ area.y = dst.y - adj_size(20);
+ w = area.w = adj_size(10) + text_w + adj_size(10) +
pWindow->prev->prev->size.w + adj_size(5 + 70 + 5) +
+ pWindow->prev->prev->size.w + adj_size(5 + 55 + 10);
+ area.h = (O_COUNT + 1) * (pText[0]->h + adj_size(6)) + adj_size(20);
SDL_FillRectAlpha(pWindow->theme, &area, &color);
putframe(pWindow->theme, area.x, area.y,
area.x + area.w - 1, area.y + area.h - 1, 0xff000000);
- area.x = dst.x + text_w + 10;
+ area.x = dst.x + text_w + adj_size(10);
SDL_BlitSurface(pMinimal, NULL, pWindow->theme, &area);
- area.x += pMinimal->w + 10;
+ area.x += pMinimal->w + adj_size(10);
FREESURFACE(pMinimal);
SDL_BlitSurface(pFactor, NULL, pWindow->theme, &area);
FREESURFACE(pFactor);
- area.x = 25;
- area.y = WINDOW_TILE_HIGH + 35;
+ area.x = adj_size(25);
+ area.y = WINDOW_TILE_HIGH + adj_size(35);
SDL_BlitSurface(pCity_Map, NULL, pWindow->theme, &area);
FREESURFACE(pCity_Map);
output_type_iterate(i) {
/* min label */
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + dst.x + text_w + 10;
+ pBuf->size.x = pWindow->size.x + dst.x + text_w + adj_size(10);
pBuf->size.y = pWindow->size.y + dst.y + (pText[i]->h - pBuf->size.h) / 2;
/* min sb */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 5;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(5);
pBuf->size.y = pWindow->size.y + dst.y + (pText[i]->h - pBuf->size.h) / 2;
- area.x = pBuf->size.x - pWindow->size.x - 2;
+ area.x = pBuf->size.x - pWindow->size.x - adj_size(2);
area.y = pBuf->size.y - pWindow->size.y;
- area.w = 74;
+ area.w = adj_size(74);
area.h = pBuf->size.h;
SDL_FillRectAlpha(pWindow->theme, &area, &color);
putframe(pWindow->theme, area.x, area.y,
@@ -1058,24 +1063,24 @@
/* factor label */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + 75;
+ pBuf->size.x = pBuf->next->size.x + adj_size(75);
pBuf->size.y = pWindow->size.y + dst.y + (pText[i]->h - pBuf->size.h) / 2;
/* factor sb */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 5;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(5);
pBuf->size.y = pWindow->size.y + dst.y + (pText[i]->h - pBuf->size.h) / 2;
- area.x = pBuf->size.x - pWindow->size.x - 2;
+ area.x = pBuf->size.x - pWindow->size.x - adj_size(2);
area.y = pBuf->size.y - pWindow->size.y;
- area.w = 58;
+ area.w = adj_size(58);
area.h = pBuf->size.h;
SDL_FillRectAlpha(pWindow->theme, &area, &color);
putframe(pWindow->theme, area.x, area.y,
area.x + area.w - 1, area.y + area.h - 1, 0xff000000);
SDL_BlitSurface(pText[i], NULL, pWindow->theme, &dst);
- dst.y += pText[i]->h + 6;
+ dst.y += pText[i]->h + adj_size(6);
FREESURFACE(pText[i]);
} output_type_iterate_end;
@@ -1087,12 +1092,12 @@
/* happy factor sb */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 5;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(5);
pBuf->size.y = pWindow->size.y + dst.y + (pText[O_COUNT]->h - pBuf->size.h)
/ 2;
- area.x = pBuf->size.x - pWindow->size.x - 2;
+ area.x = pBuf->size.x - pWindow->size.x - adj_size(2);
area.y = pBuf->size.y - pWindow->size.y;
- area.w = 58;
+ area.w = adj_size(58);
area.h = pBuf->size.h;
SDL_FillRectAlpha(pWindow->theme, &area, &color);
putframe(pWindow->theme, area.x, area.y,
@@ -1100,11 +1105,11 @@
/* celebrate cbox */
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + dst.x + 10;
+ pBuf->size.x = pWindow->size.x + dst.x + adj_size(10);
pBuf->size.y = pWindow->size.y + dst.y;
/* celebrate static text */
- dst.x += (10 + pBuf->size.w + 5);
+ dst.x += (adj_size(10) + pBuf->size.w + adj_size(5));
dst.y += (pBuf->size.h - pText[O_COUNT]->h) / 2;
SDL_BlitSurface(pText[O_COUNT], NULL, pWindow->theme, &dst);
FREESURFACE(pText[O_COUNT]);
@@ -1112,40 +1117,40 @@
/* save as */
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + x + (w - (pBuf->size.w + 6) * 6) / 2;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h * 2 - 10;
+ pBuf->size.x = pWindow->size.x + x + (w - (pBuf->size.w + adj_size(6)) * 6)
/ 2;
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h * 2 -
adj_size(10);
area.x = x;
- area.y = pBuf->size.y - pWindow->size.y - 5;
+ area.y = pBuf->size.y - pWindow->size.y - adj_size(5);
area.w = w;
- area.h = pBuf->size.h + 10;
+ area.h = pBuf->size.h + adj_size(10);
SDL_FillRectAlpha(pWindow->theme, &area, &color);
putframe(pWindow->theme, area.x, area.y,
area.x + area.w - 1, area.y + area.h - 1, 0xff000000);
/* load */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 4;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(4);
pBuf->size.y = pBuf->next->size.y;
/* del */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 4;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(4);
pBuf->size.y = pBuf->next->size.y;
/* run */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 4;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(4);
pBuf->size.y = pBuf->next->size.y;
/* run one time */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 4;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(4);
pBuf->size.y = pBuf->next->size.y;
/* del */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 4;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(4);
pBuf->size.y = pBuf->next->size.y;
/* ------------------------ */
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/colors.c
devel/client/gui-sdl/colors.c
--- devel_distclean/client/gui-sdl/colors.c 2005-10-15 23:27:27.000000000
+0200
+++ devel/client/gui-sdl/colors.c 2005-11-15 06:52:44.000000000 +0100
@@ -25,41 +25,17 @@
#include <SDL/SDL.h>
-#include "colors.h"
+#include "tilespec.h"
+#include "mem.h"
+#include "log.h"
-/*
- r, g, b, a
-*/
-static SDL_Color colors_standard_rgb[COLOR_STD_LAST] = {
- {0, 0, 0, 255}, /* Black */
- {255, 255, 255, 255}, /* White */
- {255, 0, 0, 255}, /* Red */
- {255, 255, 0, 255}, /* Yellow */
- {0, 255, 200, 255}, /* Cyan */
- {0, 200, 0, 255}, /* Ground (green) */
- {0, 0, 200, 255}, /* Ocean (blue) */
- {86, 86, 86, 255}, /* Background (gray) */
- {128, 0, 0, 255}, /* race0 */
- {128, 255, 255, 255}, /* race1 */
- {255, 0, 0, 255}, /* race2 */
- {255, 0, 128, 255}, /* race3 */
- {0, 0, 128, 255}, /* race4 */
- {255, 0, 255, 255}, /* race5 */
- {255, 128, 0, 255}, /* race6 */
- {255, 255, 128, 255}, /* race7 */
- {255, 128, 128, 255}, /* race8 */
- {0, 0, 255, 255}, /* race9 */
- {0, 255, 0, 255}, /* race10 */
- {0, 128, 128, 255}, /* race11 */
- {0, 64, 64, 255}, /* race12 */
- {198, 198, 198, 255} /* race13 */
-};
+#include "colors.h"
/*
r, g, b, a
*/
static SDL_Color SDLClient_standard_rgba_colors[SDLCLIENT_STD_COLOR_LAST -
- COLOR_STD_LAST] = {
+ COLOR_LAST] = {
{72, 61, 139, 255}, /* race14 */
{100, 149, 237, 255}, /* race15 */
{255, 228, 181, 255}, /* race16 */
@@ -98,29 +74,47 @@
};
/**************************************************************************
- Initialize colors for the game.
-**************************************************************************/
-void init_color_system(void)
-{
-}
-
-/**************************************************************************
...
**************************************************************************/
-SDL_Color * get_game_colorRGB(Uint32 color_offset)
+SDL_Color * get_game_colorRGB(enum color_std color_offset)
{
- if (color_offset >= COLOR_STD_LAST) {
- return &SDLClient_standard_rgba_colors[color_offset - COLOR_STD_LAST];
+ if (color_offset >= COLOR_LAST) {
+ return &SDLClient_standard_rgba_colors[color_offset - COLOR_LAST];
}
- return &colors_standard_rgb[color_offset];
+ return get_color(tileset, color_offset)->color;
}
/**************************************************************************
...
**************************************************************************/
-Uint32 get_game_color(Uint32 color_offset , SDL_Surface *pDest)
+Uint32 get_game_color(struct color *pcolor , SDL_Surface *pDest)
{
- SDL_Color *pColor = get_game_colorRGB(color_offset);
- return SDL_MapRGBA(pDest->format, pColor->r, pColor->g,
- pColor->b, pColor->unused);
+ if (pcolor)
+
+ return SDL_MapRGBA(pDest->format, pcolor->color->r, pcolor->color->g,
+ pcolor->color->b, pcolor->color->unused);
+
+ else
+ return 0;
+
+}
+
+struct color *color_alloc(int r, int g, int b) {
+
+ struct color *result = fc_malloc(sizeof(*result));
+
+ SDL_Color *pcolor = fc_malloc(sizeof(*pcolor));
+ pcolor->r = r;
+ pcolor->g = g;
+ pcolor->b = b;
+ pcolor->unused = 255;
+
+ result->color = pcolor;
+
+ return result;
+}
+
+void color_free(struct color *pcolor) {
+ free(pcolor->color);
+ free(pcolor);
}
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/colors.h
devel/client/gui-sdl/colors.h
--- devel_distclean/client/gui-sdl/colors.h 2005-10-15 23:27:27.000000000
+0200
+++ devel/client/gui-sdl/colors.h 2005-11-15 06:52:44.000000000 +0100
@@ -24,8 +24,12 @@
#include "colors_g.h"
+struct color {
+ SDL_Color *color;
+};
+
enum SDLClient_std_color {
- COLOR_STD_RACE14 = COLOR_STD_LAST,
+ COLOR_STD_RACE14 = COLOR_LAST,
COLOR_STD_RACE15,
COLOR_STD_RACE16,
COLOR_STD_RACE17,
@@ -64,7 +68,7 @@
};
SDL_Color * get_game_colorRGB(Uint32 color_offset);
-Uint32 get_game_color(Uint32 color_offset, SDL_Surface *pDest);
+Uint32 get_game_color(struct color *pcolor, SDL_Surface *pDest);
/* Blend the RGB values of two pixels based on a source alpha value */
#define ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB) \
diff -u -r -b -B -X devel/diff_ignore
devel_distclean/client/gui-sdl/connectdlg.c devel/client/gui-sdl/connectdlg.c
--- devel_distclean/client/gui-sdl/connectdlg.c 2005-10-18 23:22:44.000000000
+0200
+++ devel/client/gui-sdl/connectdlg.c 2005-11-15 06:52:44.000000000 +0100
@@ -33,7 +33,6 @@
#include "fcintl.h"
#include "log.h"
#include "support.h"
-/*#include "version.h"*/
#include "civclient.h"
#include "chatline.h"
@@ -47,6 +46,7 @@
#include "gui_stuff.h"
#include "gui_tilespec.h"
#include "gui_id.h"
+#include "servers.h"
#include "gui_main.h"
#include "gui_zoom.h"
@@ -59,6 +59,8 @@
static struct server_list *pServer_list = NULL;
+static struct server_scan *pServer_scan = NULL;
+
static struct ADVANCED_DLG *pMeta_Severs = NULL;
static struct SMALL_DLG *pStartMenu = NULL;
@@ -99,6 +101,7 @@
errbuf, sizeof(errbuf)) != -1) {
} else {
append_output_window(errbuf);
+ real_update_meswin_dialog();
/* button up */
unsellect_widget_action();
@@ -126,16 +129,14 @@
static int exit_meta_severs_dlg_callback(struct GUI *pWidget)
{
queue_flush();
- if (pMeta_Severs->pEndWidgetList->ID == ID_META_SERVERS_WINDOW)
- {
- delete_server_list(pServer_list);
- } else {
- /* lan list */
- finish_lanserver_scan();
- }
+
+ server_scan_finish(pServer_scan);
+ pServer_scan = NULL;
pServer_list = NULL;
+
popup_join_game_callback(NULL);
- popup_meswin_dialog();
+ popup_meswin_dialog(true);
+
return -1;
}
@@ -147,7 +148,7 @@
{
struct server *pServer = (struct server *)pWidget->data.ptr;
- sz_strlcpy(server_host, pServer->name);
+ sz_strlcpy(server_host, pServer->host);
sscanf(pServer->port, "%d", &server_port);
exit_meta_severs_dlg_callback(NULL);
@@ -155,36 +156,44 @@
}
/**************************************************************************
+ Callback function for when there's an error in the server scan.
+**************************************************************************/
+static void server_scan_error(struct server_scan *scan,
+ const char *message)
+{
+ append_output_window(message);
+ freelog(LOG_NORMAL, "%s", message);
+
+ switch (server_scan_get_type(scan)) {
+ case SERVER_SCAN_LOCAL:
+ server_scan_finish(pServer_scan);
+ pServer_list = NULL;
+ break;
+ case SERVER_SCAN_GLOBAL:
+ server_scan_finish(pServer_scan);
+ pServer_list = NULL;
+ break;
+ case SERVER_SCAN_LAST:
+ break;
+ }
+}
+
+/**************************************************************************
SDL wraper on create_server_list(...) function witch add
same functionality for LAN server dettection.
WARING !: for LAN scan use "finish_lanserver_scan()" to free server list.
**************************************************************************/
-static struct server_list *sdl_create_server_list(char *errbuf, int n_errbuf,
bool lan)
+static struct server_list *sdl_create_server_list(bool lan)
{
- if (lan)
- {
- struct server_list *pList = NULL;
- if (begin_lanserver_scan())
- {
- int scan_count = 0;
- /* 5 sec scan on LAN network */
- while (scan_count++ < 50)
- {
- pList = get_lan_server_list();
- SDL_Delay(100);
- }
- if(!pList || (pList && !server_list_size(pList)))
- {
- my_snprintf(errbuf, n_errbuf, "No LAN Server Found");
- finish_lanserver_scan();
- pList = NULL;
- }
+ if (lan) {
+ pServer_scan = server_scan_begin(SERVER_SCAN_LOCAL, server_scan_error);
} else {
- my_snprintf(errbuf, n_errbuf, "LAN network scan error");
+ pServer_scan = server_scan_begin(SERVER_SCAN_GLOBAL, server_scan_error);
}
- return pList;
- }
- return create_server_list(errbuf, n_errbuf);
+
+ SDL_Delay(5000);
+
+ return server_scan_get_servers(pServer_scan);
}
@@ -193,10 +202,9 @@
**************************************************************************/
static int severs_callback(struct GUI *pWidget)
{
- char errbuf[128];
char cBuf[512];
int w = 0, h = 0, count = 0, meta_h;
- struct GUI *pBuf, *pWindow;
+ struct GUI *pNewWidget, *pWindow;
SDL_String16 *pStr;
SDL_Surface *pLogo , *pDest = pWidget->dst;
SDL_Color col = {255, 255, 255, 128};
@@ -208,44 +216,51 @@
popdown_meswin_dialog();
my_snprintf(cBuf, sizeof(cBuf), _("Creating Server List..."));
- pStr = create_str16_from_char(cBuf, 16);
+ pStr = create_str16_from_char(cBuf, adj_font(16));
pStr->style = TTF_STYLE_BOLD;
pStr->render = 3;
pStr->bgcol = col;
pLogo = create_text_surf_from_str16(pStr);
SDL_SetAlpha(pLogo, 0x0, 0x0);
- area.w = pLogo->w + 60;
- area.h = pLogo->h + 30;
+ area.w = pLogo->w + adj_size(60);
+ area.h = pLogo->h + adj_size(30);
area.x = (pDest->w - area.w) / 2;
area.y = (pDest->h - area.h) / 2;
SDL_FillRect(pDest, &area,
SDL_MapRGBA(pDest->format, col.r, col.g,col.b, col.unused));
putframe(pDest, area.x, area.y, area.x + area.w - 1,
- area.y + area.h - 1, 0xFF000000);
+ area.y + area.h - 1, SDL_MapRGB(pDest->format, 0, 0, 0));
sdl_dirty_rect(area);
- area.x += 30;
- area.y += 15;
+ area.x += adj_size(30);
+ area.y += adj_size(15);
SDL_BlitSurface(pLogo, NULL, pDest, &area);
unqueue_flush();
FREESURFACE(pLogo);
FREESTRING16(pStr);
- pServer_list = sdl_create_server_list(errbuf, sizeof(errbuf), lan_scan);
+ pServer_list = sdl_create_server_list(lan_scan);
+
+ popup_meswin_dialog(true);
if(!pServer_list) {
+ if (lan_scan) {
+ append_output_window("No LAN servers found");
+ } else {
+ append_output_window("No public servers found");
+ }
+ real_update_meswin_dialog();
popup_join_game_callback(NULL);
- append_output_window(errbuf);
return -1;
}
pMeta_Severs = MALLOC(sizeof(struct ADVANCED_DLG));
- pWindow = create_window(pDest, NULL, 10, 10, 0);
+ pWindow = create_window(pDest, NULL, adj_size(10), adj_size(10), 0);
pWindow->action = meta_severs_window_callback;
set_wstate(pWindow, FC_WS_NORMAL);
clear_wflag(pWindow, WF_DRAW_FRAME_AROUND_WIDGET);
@@ -257,46 +272,45 @@
}
pMeta_Severs->pEndWidgetList = pWindow;
/* ------------------------------ */
- pBuf = create_themeicon_button_from_chars(pTheme->CANCEL_Icon, pWindow->dst,
- _("Cancel"), 14, 0);
- pBuf->action = exit_meta_severs_dlg_callback;
- set_wstate(pBuf, FC_WS_NORMAL);
- add_to_gui_list(ID_BUTTON, pBuf);
+
+ pNewWidget = create_themeicon_button_from_chars(pTheme->CANCEL_Icon,
pWindow->dst,
+ _("Cancel"), adj_font(14),
0);
+ pNewWidget->action = exit_meta_severs_dlg_callback;
+ set_wstate(pNewWidget, FC_WS_NORMAL);
+ add_to_gui_list(ID_BUTTON, pNewWidget);
/* ------------------------------ */
- server_list_iterate(*pServer_list,pServer) {
+ server_list_iterate(pServer_list, pServer) {
my_snprintf(cBuf, sizeof(cBuf), "%s Port %s Ver: %s %s %s %s\n%s",
- pServer->name, pServer->port, pServer->version, _(pServer->status),
- _("Players"), pServer->players, pServer->metastring);
+ pServer->host, pServer->port, pServer->version, _(pServer->state),
+ _("Players"), pServer->nplayers, pServer->message);
- pBuf = create_iconlabel_from_chars(NULL, pWindow->dst, cBuf, 10,
+ pNewWidget = create_iconlabel_from_chars(NULL, pWindow->dst, cBuf,
adj_font(10),
WF_FREE_STRING|WF_DRAW_TEXT_LABEL_WITH_SPACE|WF_DRAW_THEME_TRANSPARENT);
- pBuf->string16->style |= SF_CENTER;
- pBuf->string16->render = 3;
- pBuf->string16->bgcol.r = 0;
- pBuf->string16->bgcol.g = 0;
- pBuf->string16->bgcol.b = 0;
- pBuf->string16->bgcol.unused = 0;
+ pNewWidget->string16->style |= SF_CENTER;
+ pNewWidget->string16->render = 3;
+ pNewWidget->string16->bgcol = (SDL_Color) {0, 0, 0, 0};
+
+ pNewWidget->action = sellect_meta_severs_callback;
+ set_wstate(pNewWidget, FC_WS_NORMAL);
+ pNewWidget->data.ptr = (void *)pServer;
- pBuf->action = sellect_meta_severs_callback;
- set_wstate(pBuf, FC_WS_NORMAL);
- pBuf->data.ptr = (void *)pServer;
- w = MAX(w, pBuf->size.w);
- h = MAX(h, pBuf->size.h);
+ add_to_gui_list(ID_BUTTON, pNewWidget);
- add_to_gui_list(ID_BUTTON, pBuf);
+ w = MAX(w, pNewWidget->size.w);
+ h = MAX(h, pNewWidget->size.h);
count++;
if(count > 10) {
- set_wflag(pBuf, WF_HIDDEN);
+ set_wflag(pNewWidget, WF_HIDDEN);
}
} server_list_iterate_end;
- pMeta_Severs->pBeginWidgetList = pBuf;
- pMeta_Severs->pBeginActiveWidgetList = pBuf;
+ pMeta_Severs->pBeginWidgetList = pNewWidget;
+ pMeta_Severs->pBeginActiveWidgetList = pNewWidget;
pMeta_Severs->pEndActiveWidgetList = pWindow->prev->prev;
pMeta_Severs->pActiveWidgetList = pWindow->prev->prev;
@@ -309,10 +323,10 @@
meta_h = count * h;
}
- w += 20;
+ w += adj_size(20);
area.h = meta_h;
- meta_h += pMeta_Severs->pEndWidgetList->prev->size.h + 10 + 20;
+ meta_h += pMeta_Severs->pEndWidgetList->prev->size.h + adj_size(10) +
adj_size(20);
pWindow->size.x = (pWindow->dst->w - w) /2;
pWindow->size.y = (pWindow->dst->h - meta_h) /2;
@@ -322,7 +336,7 @@
FREESURFACE(pLogo);
}
SDL_SetAlpha(pWindow->theme, 0x0, 0x0);
- w -= 20;
+ w -= adj_size(20);
area.w = w + 1;
@@ -331,40 +345,40 @@
}
/* exit button */
- pBuf = pWindow->prev;
- pBuf->size.x = pWindow->size.x + pWindow->size.w - pBuf->size.w - 10;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - 10;
+ pNewWidget = pWindow->prev;
+ pNewWidget->size.x = pWindow->size.x + pWindow->size.w - pNewWidget->size.w
- adj_size(10);
+ pNewWidget->size.y = pWindow->size.y + pWindow->size.h - pNewWidget->size.h
- adj_size(10);
/* meta labels */
- pBuf = pBuf->prev;
+ pNewWidget = pNewWidget->prev;
- pBuf->size.x = pWindow->size.x + 10;
- pBuf->size.y = pWindow->size.y + 10;
- pBuf->size.w = w;
- pBuf->size.h = h;
- pBuf = convert_iconlabel_to_themeiconlabel2(pBuf);
+ pNewWidget->size.x = pWindow->size.x + adj_size(10);
+ pNewWidget->size.y = pWindow->size.y + adj_size(10);
+ pNewWidget->size.w = w;
+ pNewWidget->size.h = h;
+ pNewWidget = convert_iconlabel_to_themeiconlabel2(pNewWidget);
- pBuf = pBuf->prev;
- while(pBuf)
+ pNewWidget = pNewWidget->prev;
+ while(pNewWidget)
{
- pBuf->size.w = w;
- pBuf->size.h = h;
- pBuf->size.x = pBuf->next->size.x;
- pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h;
- pBuf = convert_iconlabel_to_themeiconlabel2(pBuf);
+ pNewWidget->size.w = w;
+ pNewWidget->size.h = h;
+ pNewWidget->size.x = pNewWidget->next->size.x;
+ pNewWidget->size.y = pNewWidget->next->size.y + pNewWidget->next->size.h;
+ pNewWidget = convert_iconlabel_to_themeiconlabel2(pNewWidget);
- if (pBuf == pMeta_Severs->pBeginActiveWidgetList) {
+ if (pNewWidget == pMeta_Severs->pBeginActiveWidgetList) {
break;
}
- pBuf = pBuf->prev;
+ pNewWidget = pNewWidget->prev;
}
if(pMeta_Severs->pScroll) {
setup_vertical_scrollbar_area(pMeta_Severs->pScroll,
- pWindow->size.x + pWindow->size.w - 9,
+ pWindow->size.x + pWindow->size.w - adj_size(9),
pMeta_Severs->pEndActiveWidgetList->size.y,
- pWindow->size.h - 30 - pWindow->prev->size.h, TRUE);
+ pWindow->size.h - adj_size(30) - pWindow->prev->size.h, TRUE);
}
/* -------------------- */
@@ -445,8 +459,8 @@
SDL_Rect *area;
int start_x, start_y;
+ int pos_y;
int dialog_w, dialog_h;
- int start_button_y;
if(pWidget) {
@@ -463,24 +477,25 @@
/* -------------------------- */
- pPlayer_name = create_str16_from_char(_("Player Name :"), 10);
+ pPlayer_name = create_str16_from_char(_("Player Name :"), adj_font(10));
pPlayer_name->fgcol = color;
- pServer_name = create_str16_from_char(_("Freeciv Server :"), 10);
+ pServer_name = create_str16_from_char(_("Freeciv Server :"), adj_font(10));
pServer_name->fgcol = color;
- pPort_nr = create_str16_from_char(_("Port :"), 10);
+ pPort_nr = create_str16_from_char(_("Port :"), adj_font(10));
pPort_nr->fgcol = color;
/* ====================== INIT =============================== */
- pBuf = create_edit_from_chars(NULL, pDest, user_name, 14, 210,
+ pBuf = create_edit_from_chars(NULL, pDest, user_name, adj_font(14),
adj_size(210),
(WF_DRAW_THEME_TRANSPARENT|WF_FREE_DATA));
pBuf->action = convert_playername_callback;
set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(ID_PLAYER_NAME_EDIT, pBuf);
+
pBuf->data.ptr = (void *)area;
pStartMenu->pEndWidgetList = pBuf;
- /* ------------------------------ */
- pBuf = create_edit_from_chars(NULL, pDest, server_host, 14, 210,
+ /* ------------------------------ */
+ pBuf = create_edit_from_chars(NULL, pDest, server_host, adj_font(14),
adj_size(210),
WF_DRAW_THEME_TRANSPARENT);
pBuf->action = convert_servername_callback;
@@ -490,7 +505,7 @@
/* ------------------------------ */
my_snprintf(pCharPort, sizeof(pCharPort), "%d", server_port);
- pBuf = create_edit_from_chars(NULL, pDest, pCharPort, 14, 210,
+ pBuf = create_edit_from_chars(NULL, pDest, pCharPort, adj_font(14),
adj_size(210),
WF_DRAW_THEME_TRANSPARENT);
pBuf->action = convert_portnr_callback;
@@ -500,7 +515,7 @@
/* ------------------------------ */
pBuf = create_themeicon_button_from_chars(pTheme->OK_Icon, pDest,
- _("Connect"), 14, 0);
+ _("Connect"), adj_font(14), 0);
pBuf->action = connect_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_RETURN;
@@ -509,7 +524,7 @@
/* ------------------------------ */
pBuf = create_themeicon_button_from_chars(pTheme->CANCEL_Icon, pDest,
- _("Cancel"), 14, 0);
+ _("Cancel"), adj_font(14), 0);
pBuf->action = cancel_connect_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
@@ -520,18 +535,24 @@
/* ------------------------------ */
pStartMenu->pBeginWidgetList = pBuf;
+
/* ==================== Draw first time ===================== */
- dialog_w = 40 + pBuf->size.w * 2;
- dialog_w = MAX(dialog_w, 210);
- dialog_w += 80;
+ dialog_w = adj_size(40) + pBuf->size.w * 2;
+ dialog_w = MAX(dialog_w, adj_size(210));
+ dialog_w += adj_size(80);
+
+ #ifdef SMALL_SCREEN
+ dialog_h = 110;
+ #else
dialog_h = 200;
+ #endif
pLogo = get_logo_gfx();
pTmp = ResizeSurface(pLogo, dialog_w, dialog_h, 1);
FREESURFACE(pLogo);
area->x = (pDest->w - dialog_w)/ 2;
- area->y = (pDest->h - dialog_h)/ 2 + 40;
+ area->y = (pDest->h - dialog_h)/ 2 + adj_size(40);
SDL_SetAlpha(pTmp, 0x0, 0x0);
SDL_BlitSurface(pTmp, NULL, pDest, area);
FREESURFACE(pTmp);
@@ -542,40 +563,60 @@
area->w = dialog_w;
area->h = dialog_h;
/* ---------------------------------------- */
+
/* user edit */
pBuf = pStartMenu->pEndWidgetList;
+
start_x = area->x + (area->w - pBuf->size.w) / 2;
- start_y = area->y + 35;
- write_text16(pDest, start_x + 5, start_y - 13, pPlayer_name);
- draw_edit(pBuf, start_x, start_y);
+ start_y = area->y + adj_size(20);
+ pos_y = start_y;
+
+ write_text16(pDest, start_x + adj_size(5),
+ pos_y,
+ pPlayer_name);
+ pos_y += str16height(pPlayer_name);
+
+ draw_edit(pBuf, start_x, pos_y);
+ pos_y += pBuf->size.h;
+ /* -------- */
+
+ pos_y += adj_size(5);
/* server name */
pBuf = pBuf->prev;
- write_text16(pDest, start_x + 5, start_y - 13 + 15 +
- pBuf->next->size.h, pServer_name);
- draw_edit(pBuf, start_x, start_y + 15 + pBuf->next->size.h);
+ write_text16(pDest, start_x + adj_size(5), pos_y, pServer_name);
+ pos_y += str16height(pServer_name);
+
+ draw_edit(pBuf, start_x, pos_y);
+ pos_y += pBuf->size.h;
+ /* -------- */
+
+ pos_y += adj_size(5);
/* port */
pBuf = pBuf->prev;
- write_text16(pDest, start_x + 5, start_y - 13 + 30 +
- pBuf->next->next->size.h + pBuf->next->size.h, pPort_nr);
- draw_edit(pBuf, start_x,
- start_y + 30 + pBuf->next->next->size.h + pBuf->next->size.h);
+ write_text16(pDest, start_x + adj_size(5), pos_y, pPort_nr);
+ pos_y += str16height(pPort_nr);
+
+ draw_edit(pBuf, start_x, pos_y);
+ pos_y += pBuf->size.h;
+ /* -------- */
+
+ pos_y += adj_size(20);
/* --------------------------------- */
- start_button_y = pBuf->size.y + pBuf->size.h + 25;
/* connect button */
pBuf = pBuf->prev;
- draw_tibutton(pBuf, area->x + (dialog_w - (40 + pBuf->size.w * 2)) / 2,
- start_button_y);
+ draw_tibutton(pBuf, area->x + (dialog_w - (adj_size(40) + pBuf->size.w * 2))
/ 2,
+ pos_y);
draw_frame_around_widget(pBuf);
/* cancel button */
pBuf = pBuf->prev;
- draw_tibutton(pBuf, pBuf->next->size.x + pBuf->size.w + 40, start_button_y);
+ draw_tibutton(pBuf, pBuf->next->size.x + pBuf->size.w + adj_size(40), pos_y);
draw_frame_around_widget(pBuf);
flush_all();
@@ -654,17 +695,17 @@
/* -------------------------- */
- pStr = create_str16_from_char(pMessage, 12);
+ pStr = create_str16_from_char(pMessage, adj_font(12));
pStr->fgcol = color_white;
pText = create_text_surf_from_str16(pStr);
/* ====================== INIT =============================== */
- change_ptsize16(pStr, 16);
+ change_ptsize16(pStr, adj_font(16));
pStr->fgcol = color_black;
FREE(pStr->text);
- pBuf = create_edit(NULL, pDest, pStr, 210,
+ pBuf = create_edit(NULL, pDest, pStr, adj_size(210),
(WF_PASSWD_EDIT|WF_DRAW_THEME_TRANSPARENT|WF_FREE_DATA));
pBuf->action = convert_passwd_callback;
set_wstate(pBuf, FC_WS_NORMAL);
@@ -674,7 +715,7 @@
/* ------------------------------ */
pBuf = create_themeicon_button_from_chars(pTheme->OK_Icon, pDest,
- _("Next"), 14, 0);
+ _("Next"), adj_font(14),
0);
pBuf->action = send_passwd_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_RETURN;
@@ -683,7 +724,7 @@
/* ------------------------------ */
pBuf = create_themeicon_button_from_chars(pTheme->CANCEL_Icon, pDest,
- _("Cancel"), 14, 0);
+ _("Cancel"), adj_font(14),
0);
pBuf->action = cancel_connect_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
@@ -695,18 +736,18 @@
pStartMenu->pBeginWidgetList = pBuf;
/* ==================== Draw first time ===================== */
- dialog_w = 40 + pBuf->size.w * 2;
- dialog_w = MAX(dialog_w, 210);
+ dialog_w = adj_size(40) + pBuf->size.w * 2;
+ dialog_w = MAX(dialog_w, adj_size(210));
dialog_w = MAX(dialog_w, pText->w);
- dialog_w += 80;
- dialog_h = 170;
+ dialog_w += adj_size(80);
+ dialog_h = adj_size(170);
pLogo = get_logo_gfx();
pTmp = ResizeSurface(pLogo, dialog_w, dialog_h, 1);
FREESURFACE(pLogo);
area->x = (pDest->w - dialog_w)/ 2;
- area->y = (pDest->h - dialog_h)/ 2 + 40;
+ area->y = (pDest->h - dialog_h)/ 2 + adj_size(40);
SDL_SetAlpha(pTmp, 0x0, 0x0);
SDL_BlitSurface(pTmp, NULL, pDest, area);
FREESURFACE(pTmp);
@@ -720,25 +761,25 @@
/* passwd edit */
pBuf = pStartMenu->pEndWidgetList;
start_x = area->x + (area->w - pText->w) / 2;
- start_y = area->y + 50;
+ start_y = area->y + adj_size(50);
blit_entire_src(pText, pDest, start_x, start_y);
- start_y += pText->h + 5;
+ start_y += pText->h + adj_size(5);
FREESURFACE(pText);
start_x = area->x + (area->w - pBuf->size.w) / 2;
draw_edit(pBuf, start_x, start_y);
/* --------------------------------- */
- start_button_y = pBuf->size.y + pBuf->size.h + 25;
+ start_button_y = pBuf->size.y + pBuf->size.h + adj_size(25);
/* connect button */
pBuf = pBuf->prev;
- draw_tibutton(pBuf, area->x + (dialog_w - (40 + pBuf->size.w * 2)) / 2,
+ draw_tibutton(pBuf, area->x + (dialog_w - (adj_size(40) + pBuf->size.w * 2))
/ 2,
start_button_y);
draw_frame_around_widget(pBuf);
/* cancel button */
pBuf = pBuf->prev;
- draw_tibutton(pBuf, pBuf->next->size.x + pBuf->size.w + 40, start_button_y);
+ draw_tibutton(pBuf, pBuf->next->size.x + pBuf->size.w + adj_size(40),
start_button_y);
draw_frame_around_widget(pBuf);
flush_all();
@@ -819,19 +860,19 @@
/* -------------------------- */
- pStr = create_str16_from_char(pMessage, 12);
+ pStr = create_str16_from_char(pMessage, adj_font(12));
pStr->fgcol = color_white;
pText = create_text_surf_from_str16(pStr);
/* ====================== INIT =============================== */
- change_ptsize16(pStr, 16);
+ change_ptsize16(pStr, adj_font(16));
pStr->fgcol = color_black;
FREE(pStr->text);
pStr->n_alloc = 0;
- pBuf = create_edit(NULL, pDest, pStr, 210,
+ pBuf = create_edit(NULL, pDest, pStr, adj_size(210),
(WF_PASSWD_EDIT|WF_DRAW_THEME_TRANSPARENT|WF_FREE_DATA));
pBuf->action = convert_first_passwd_callback;
set_wstate(pBuf, FC_WS_NORMAL);
@@ -840,14 +881,14 @@
pStartMenu->pEndWidgetList = pBuf;
/* ------------------------------ */
- pBuf = create_edit(NULL, pDest, create_string16(NULL, 0, 16) , 210,
+ pBuf = create_edit(NULL, pDest, create_string16(NULL, 0, adj_font(16)) ,
adj_size(210),
(WF_PASSWD_EDIT|WF_DRAW_THEME_TRANSPARENT|WF_FREE_DATA));
pBuf->action = convert_secound_passwd_callback;
add_to_gui_list(ID_EDIT, pBuf);
/* ------------------------------ */
pBuf = create_themeicon_button_from_chars(pTheme->OK_Icon, pDest,
- _("Next"), 14, 0);
+ _("Next"), adj_font(14),
0);
pBuf->action = send_passwd_callback;
pBuf->key = SDLK_RETURN;
add_to_gui_list(ID_BUTTON, pBuf);
@@ -855,7 +896,7 @@
/* ------------------------------ */
pBuf = create_themeicon_button_from_chars(pTheme->CANCEL_Icon, pDest,
- _("Cancel"), 14, 0);
+ _("Cancel"), adj_font(14),
0);
pBuf->action = cancel_connect_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
@@ -867,18 +908,18 @@
pStartMenu->pBeginWidgetList = pBuf;
/* ==================== Draw first time ===================== */
- dialog_w = 40 + pBuf->size.w * 2;
- dialog_w = MAX(dialog_w, 210);
+ dialog_w = adj_size(40) + pBuf->size.w * 2;
+ dialog_w = MAX(dialog_w, adj_size(210));
dialog_w = MAX(dialog_w, pText->w);
- dialog_w += 80;
- dialog_h = 180;
+ dialog_w += adj_size(80);
+ dialog_h = adj_size(180);
pLogo = get_logo_gfx();
pTmp = ResizeSurface(pLogo, dialog_w, dialog_h, 1);
FREESURFACE(pLogo);
area->x = (pDest->w - dialog_w)/ 2;
- area->y = (pDest->h - dialog_h)/ 2 + 40;
+ area->y = (pDest->h - dialog_h)/ 2 + adj_size(40);
SDL_SetAlpha(pTmp, 0x0, 0x0);
SDL_BlitSurface(pTmp, NULL, pDest, area);
FREESURFACE(pTmp);
@@ -892,31 +933,31 @@
/* passwd edit */
pBuf = pStartMenu->pEndWidgetList;
start_x = area->x + (area->w - pText->w) / 2;
- start_y = area->y + 30;
+ start_y = area->y + adj_size(30);
blit_entire_src(pText, pDest, start_x, start_y);
- start_y += pText->h + 5;
+ start_y += pText->h + adj_size(5);
FREESURFACE(pText);
start_x = area->x + (area->w - pBuf->size.w) / 2;
draw_edit(pBuf, start_x, start_y);
- start_y += pBuf->size.h + 5;
+ start_y += pBuf->size.h + adj_size(5);
/* retype passwd */
pBuf = pBuf->prev;
draw_edit(pBuf, start_x, start_y);
/* --------------------------------- */
- start_button_y = pBuf->size.y + pBuf->size.h + 25;
+ start_button_y = pBuf->size.y + pBuf->size.h + adj_size(25);
/* connect button */
pBuf = pBuf->prev;
- draw_tibutton(pBuf, area->x + (dialog_w - (40 + pBuf->size.w * 2)) / 2,
+ draw_tibutton(pBuf, area->x + (dialog_w - (adj_size(40) + pBuf->size.w * 2))
/ 2,
start_button_y);
draw_frame_around_widget(pBuf);
/* cancel button */
pBuf = pBuf->prev;
- draw_tibutton(pBuf, pBuf->next->size.x + pBuf->size.w + 40, start_button_y);
+ draw_tibutton(pBuf, pBuf->next->size.x + pBuf->size.w + adj_size(40),
start_button_y);
draw_frame_around_widget(pBuf);
flush_all();
@@ -966,7 +1007,8 @@
FREE(pMeta_Severs->pScroll);
FREE(pMeta_Severs);
if(pServer_list) {
- delete_server_list(pServer_list);
+ server_scan_finish(pServer_scan);
+ pServer_scan = NULL;
pServer_list = NULL;
}
}
@@ -1012,7 +1054,7 @@
void gui_server_connect(void)
{
int w = 0 , h = 0, count = 0;
- struct GUI *pBuf = NULL, *pFirst;
+ struct GUI *pWidget = NULL, *pFirst;
SDL_Rect *pArea;
SDL_Surface *pLogo, *pTmp;
SDL_Color col = {255, 255, 255, 136};
@@ -1024,93 +1066,113 @@
/* create dialog */
pStartMenu = MALLOC(sizeof(struct SMALL_DLG));
- pFirst =
- create_iconlabel_from_chars(NULL, Main.gui, _("Start New Game"), 14,
+ /* Start New Game */
+ pWidget =
+ create_iconlabel_from_chars(NULL, Main.gui, _("Start New Game"),
adj_font(14),
(WF_SELLECT_WITHOUT_BAR|WF_DRAW_THEME_TRANSPARENT|WF_FREE_DATA));
/*pBuf->action = popup_start_new_game_callback;*/
- pFirst->string16->style |= SF_CENTER;
- pFirst->string16->fgcol.r = 128;
- pFirst->string16->fgcol.g = 128;
- pFirst->string16->fgcol.b = 128;
+ pWidget->string16->style |= SF_CENTER;
+ pWidget->string16->fgcol = (SDL_Color) {128, 128, 128, 255};
- w = MAX(w, pFirst->size.w);
- h = MAX(h, pFirst->size.h);
+ w = MAX(w, pWidget->size.w);
+ h = MAX(h, pWidget->size.h);
count++;
- add_to_gui_list(ID_START_NEW_GAME, pFirst);
+
+ add_to_gui_list(ID_START_NEW_GAME, pWidget);
+
+ pFirst = pWidget;
pStartMenu->pEndWidgetList = pFirst;
- pBuf = create_iconlabel_from_chars(NULL, Main.gui, _("Load Game"), 14,
+ /* Load Game */
+ pWidget = create_iconlabel_from_chars(NULL, Main.gui, _("Load Game"),
adj_font(14),
(WF_SELLECT_WITHOUT_BAR|WF_DRAW_THEME_TRANSPARENT));
- /*pBuf->action = popup_load_game_callback;*/
- pBuf->string16->style |= SF_CENTER;
- pBuf->string16->fgcol.r = 128;
- pBuf->string16->fgcol.g = 128;
- pBuf->string16->fgcol.b = 128;
+ /*pWidget->action = popup_load_game_callback;*/
+ pWidget->string16->style |= SF_CENTER;
+ pWidget->string16->fgcol = (SDL_Color) {128, 128, 128, 255};
+
+ add_to_gui_list(ID_LOAD_GAME, pWidget);
- w = MAX(w, pBuf->size.w);
- h = MAX(h, pBuf->size.h);
+ w = MAX(w, pWidget->size.w);
+ h = MAX(h, pWidget->size.h);
count++;
- add_to_gui_list(ID_LOAD_GAME, pBuf);
- pBuf = create_iconlabel_from_chars(NULL, Main.gui, _("Join Game"), 14,
+ /* Join Game */
+ pWidget = create_iconlabel_from_chars(NULL, Main.gui, _("Join Game"),
adj_font(14),
WF_SELLECT_WITHOUT_BAR|WF_DRAW_THEME_TRANSPARENT);
- pBuf->action = popup_join_game_callback;
- pBuf->string16->style |= SF_CENTER;
- set_wstate(pBuf, FC_WS_NORMAL);
- w = MAX(w, pBuf->size.w);
- h = MAX(h, pBuf->size.h);
+ pWidget->action = popup_join_game_callback;
+ pWidget->string16->style |= SF_CENTER;
+ set_wstate(pWidget, FC_WS_NORMAL);
+
+ add_to_gui_list(ID_JOIN_GAME, pWidget);
+
+ w = MAX(w, pWidget->size.w);
+ h = MAX(h, pWidget->size.h);
count++;
- add_to_gui_list(ID_JOIN_GAME, pBuf);
- pBuf = create_iconlabel_from_chars(NULL, Main.gui, _("Join Pubserver"), 14,
+ /* Join Pubserver */
+ pWidget = create_iconlabel_from_chars(NULL, Main.gui, _("Join Pubserver"),
adj_font(14),
WF_SELLECT_WITHOUT_BAR|WF_DRAW_THEME_TRANSPARENT);
- pBuf->action = severs_callback;
- pBuf->string16->style |= SF_CENTER;
- set_wstate(pBuf, FC_WS_NORMAL);
- w = MAX(w, pBuf->size.w);
- h = MAX(h, pBuf->size.h);
+ pWidget->action = severs_callback;
+ pWidget->string16->style |= SF_CENTER;
+ set_wstate(pWidget, FC_WS_NORMAL);
+
+ add_to_gui_list(ID_JOIN_META_GAME, pWidget);
+
+ w = MAX(w, pWidget->size.w);
+ h = MAX(h, pWidget->size.h);
count++;
- add_to_gui_list(ID_JOIN_META_GAME, pBuf);
- pBuf = create_iconlabel_from_chars(NULL, Main.gui, _("Join LAN Server"), 14,
+ /* Join LAN Server */
+ pWidget = create_iconlabel_from_chars(NULL, Main.gui, _("Join LAN Server"),
adj_font(14),
WF_SELLECT_WITHOUT_BAR|WF_DRAW_THEME_TRANSPARENT);
- pBuf->action = severs_callback;
- pBuf->string16->style |= SF_CENTER;
- set_wstate(pBuf, FC_WS_NORMAL);
- w = MAX(w, pBuf->size.w);
- h = MAX(h, pBuf->size.h);
+ pWidget->action = severs_callback;
+ pWidget->string16->style |= SF_CENTER;
+ set_wstate(pWidget, FC_WS_NORMAL);
+
+ add_to_gui_list(ID_JOIN_GAME, pWidget);
+
+ w = MAX(w, pWidget->size.w);
+ h = MAX(h, pWidget->size.h);
count++;
- add_to_gui_list(ID_JOIN_GAME, pBuf);
- pBuf = create_iconlabel_from_chars(NULL, Main.gui, _("Options"), 14,
+ /* Options */
+ pWidget = create_iconlabel_from_chars(NULL, Main.gui, _("Options"),
adj_font(14),
WF_SELLECT_WITHOUT_BAR|WF_DRAW_THEME_TRANSPARENT);
- pBuf->action = popup_option_callback;
- pBuf->string16->style |= SF_CENTER;
- w = MAX(w, pBuf->size.w);
- h = MAX(h, pBuf->size.h);
+ pWidget->action = popup_option_callback;
+ pWidget->string16->style |= SF_CENTER;
+ set_wstate(pWidget, FC_WS_NORMAL);
+
+ add_to_gui_list(ID_CLIENT_OPTIONS_BUTTON, pWidget);
+
+ w = MAX(w, pWidget->size.w);
+ h = MAX(h, pWidget->size.h);
count++;
- set_wstate(pBuf, FC_WS_NORMAL);
- add_to_gui_list(ID_CLIENT_OPTIONS_BUTTON, pBuf);
- pBuf = create_iconlabel_from_chars(NULL, Main.gui, _("Quit"), 14,
+ /* Quit */
+ pWidget = create_iconlabel_from_chars(NULL, Main.gui, _("Quit"),
adj_font(14),
WF_SELLECT_WITHOUT_BAR|WF_DRAW_THEME_TRANSPARENT);
- pBuf->action = quit_callback;
- pBuf->string16->style |= SF_CENTER;
- pBuf->key = SDLK_ESCAPE;
- set_wstate(pBuf, FC_WS_NORMAL);
- w = MAX(w, pBuf->size.w);
- h = MAX(h, pBuf->size.h);
+ pWidget->action = quit_callback;
+ pWidget->string16->style |= SF_CENTER;
+ pWidget->key = SDLK_ESCAPE;
+ set_wstate(pWidget, FC_WS_NORMAL);
+ add_to_gui_list(ID_QUIT, pWidget);
+
+ w = MAX(w, pWidget->size.w);
+ h = MAX(h, pWidget->size.h);
count++;
- add_to_gui_list(ID_QUIT, pBuf);
- pStartMenu->pBeginWidgetList = pBuf;
- w+=30;
- h+=6;
+
+ pStartMenu->pBeginWidgetList = pWidget;
+
+ /* ------*/
+
+ w+=adj_size(30);
+ h+=adj_size(6);
setup_vertical_widgets_position(1,
- (pFirst->dst->w - w) - 20, (pFirst->dst->h - (h * count)) - 20,
- w, h, pBuf, pFirst);
+ (pFirst->dst->w - w) - adj_size(20), (pFirst->dst->h - (h * count)) -
adj_size(20),
+ w, h, pWidget, pFirst);
pArea = MALLOC(sizeof(SDL_Rect));
@@ -1121,7 +1183,9 @@
pFirst->data.ptr = (void *)pArea;
+ /* FIXME: doesn't work after game has finished */
draw_intro_gfx();
+ flush_all();
pLogo = get_logo_gfx();
pTmp = ResizeSurface(pLogo, pArea->w, pArea->h , 1);
@@ -1133,7 +1197,7 @@
SDL_FillRectAlpha(pFirst->dst, pArea, &col);
- redraw_group(pBuf, pFirst, 0);
+ redraw_group(pWidget, pFirst, 0);
draw_frame(pFirst->dst, pFirst->size.x - FRAME_WH, pFirst->size.y - FRAME_WH
,
w + DOUBLE_FRAME_WH, (h*count) + DOUBLE_FRAME_WH);
@@ -1147,6 +1211,7 @@
" menu."));
set_output_window_text(_("Now.. Go give'em hell!"));
+ popup_meswin_dialog(true);
+
flush_all();
}
-
diff -u -r -b -B -X devel/diff_ignore
devel_distclean/client/gui-sdl/connectdlg.h devel/client/gui-sdl/connectdlg.h
--- devel_distclean/client/gui-sdl/connectdlg.h 2005-10-15 23:27:27.000000000
+0200
+++ devel/client/gui-sdl/connectdlg.h 2005-11-15 06:52:44.000000000 +0100
@@ -25,6 +25,6 @@
#include "connectdlg_g.h"
/* nothing yet */
-bool try_to_autoconnect(void);
+double try_to_autoconnect(void);
#endif /* FC__CONNECTDLG_H */
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/dialogs.c
devel/client/gui-sdl/dialogs.c
--- devel_distclean/client/gui-sdl/dialogs.c 2005-10-19 00:34:24.000000000
+0200
+++ devel/client/gui-sdl/dialogs.c 2005-11-15 07:01:36.000000000 +0100
@@ -78,6 +78,8 @@
#include "options.h"
#include "optiondlg.h"
#include "tilespec.h"
+#include "text.h"
+#include "movement.h"
#include "dialogs.h"
@@ -92,6 +94,7 @@
pBuf->action = pCallback; \
} while(0)
+struct player *races_player;
extern bool is_unit_move_blocked;
@@ -111,11 +114,11 @@
...
***********************************************************************/
void put_window_near_map_tile(struct GUI *pWindow,
- int window_width, int window_height, int x, int y)
+ int window_width, int window_height, struct tile *ptile)
{
int canvas_x, canvas_y;
- if (tile_to_canvas_pos(&canvas_x, &canvas_y, x, y)) {
+ if (tile_to_canvas_pos(&canvas_x, &canvas_y, ptile)) {
if (canvas_x + tileset_tile_width(tileset) + window_width >=
pWindow->dst->w)
{
if (canvas_x - window_width < 0) {
@@ -216,7 +219,7 @@
location.
**************************************************************************/
void popup_notify_goto_dialog(const char *headline, const char *lines,
- int x, int y)
+ struct tile *ptile)
{
freelog(LOG_NORMAL, "popup_notify_goto_dialog : PORT ME\n \
a: %s\nb: %s",headline, lines );
@@ -267,10 +270,10 @@
pNotifyDlg = MALLOC(sizeof(struct ADVANCED_DLG));
- pStr = create_str16_from_char(caption, 12);
+ pStr = create_str16_from_char(caption, adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 10, 10, 0);
+ pWindow = create_window(NULL, pStr, adj_size(10), adj_size(10), 0);
pWindow->action = notify_dialog_window_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -286,18 +289,18 @@
pBuf->action = exit_notify_dialog_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
- w += (pBuf->size.w + 10);
+ w += (pBuf->size.w + adj_size(10));
add_to_gui_list(ID_BUTTON, pBuf);
pNotifyDlg->pBeginWidgetList = pBuf;
- pStr = create_str16_from_char(headline, 16);
+ pStr = create_str16_from_char(headline, adj_font(16));
pStr->style |= TTF_STYLE_BOLD;
pHeadline = create_text_surf_from_str16(pStr);
if(lines && *lines != '\0') {
- change_ptsize16(pStr, 12);
+ change_ptsize16(pStr, adj_font(12));
pStr->style &= ~TTF_STYLE_BOLD;
copy_chars_to_string16(pStr, lines);
pLines = create_text_surf_from_str16(pStr);
@@ -311,10 +314,10 @@
if(pLines) {
w = MAX(w, pLines->w);
}
- w += 60;
- h = WINDOW_TILE_HIGH + 1 + FRAME_WH + 10 + pHeadline->h + 10;
+ w += adj_size(60);
+ h = WINDOW_TILE_HIGH + 1 + FRAME_WH + adj_size(10) + pHeadline->h +
adj_size(10);
if(pLines) {
- h += pLines->h + 10;
+ h += pLines->h + adj_size(10);
}
pWindow->size.x = (Main.screen->w - w) / 2;
pWindow->size.y = (Main.screen->h - h) / 2;
@@ -323,11 +326,11 @@
get_game_colorRGB(COLOR_STD_BACKGROUND_BROWN), w, h);
dst.x = (pWindow->size.w - pHeadline->w) / 2;
- dst.y = WINDOW_TILE_HIGH + 11;
+ dst.y = WINDOW_TILE_HIGH + adj_size(11);
SDL_BlitSurface(pHeadline, NULL, pWindow->theme, &dst);
if(pLines) {
- dst.y += pHeadline->h + 10;
+ dst.y += pHeadline->h + adj_size(10);
if(pHeadline->w < pLines->w) {
dst.x = (pWindow->size.w - pLines->w) / 2;
}
@@ -394,8 +397,7 @@
*****************************************************************/
void popup_unit_upgrade_dlg(struct unit *pUnit, bool city)
{
-
- int ut1, ut2;
+ struct unit_type *ut1, *ut2;
int value = 9999, hh, ww = 0;
char cBuf[128];
struct GUI *pBuf = NULL, *pWindow;
@@ -416,32 +418,32 @@
ut2 = can_upgrade_unittype(game.player_ptr, ut1);
- if (ut2 != -1) {
+ if (ut2) {
value = unit_upgrade_price(game.player_ptr, ut1, ut2);
if (game.player_ptr->economic.gold >= value) {
my_snprintf(cBuf, sizeof(cBuf),
_("Upgrade %s to %s for %d gold?\n"
"Treasury contains %d gold."),
- unit_types[ut1].name, unit_types[ut2].name,
+ get_unit_type(ut1->index)->name, get_unit_type(ut2->index)->name,
value, game.player_ptr->economic.gold);
} else {
my_snprintf(cBuf, sizeof(cBuf),
_("Upgrading %s to %s costs %d gold.\n"
"Treasury contains %d gold."),
- unit_types[ut1].name, unit_types[ut2].name,
+ get_unit_type(ut1->index)->name, get_unit_type(ut2->index)->name,
value, game.player_ptr->economic.gold);
}
} else {
my_snprintf(cBuf, sizeof(cBuf),
- _("Sorry: cannot upgrade %s."), unit_types[ut1].name);
+ _("Sorry: cannot upgrade %s."), get_unit_type(ut1->index)->name);
}
hh = WINDOW_TILE_HIGH + 1;
- pStr = create_str16_from_char(_("Upgrade Obsolete Units"), 12);
+ pStr = create_str16_from_char(_("Upgrade Obsolete Units"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 100, 100, 0);
+ pWindow = create_window(NULL, pStr, adj_size(100), adj_size(100), 0);
pWindow->action = upgrade_unit_window_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -453,7 +455,7 @@
/* ============================================================= */
/* create text label */
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pStr->fgcol.r = 255;
pStr->fgcol.g = 255;
@@ -462,24 +464,24 @@
pText = create_text_surf_from_str16(pStr);
FREESTRING16(pStr);
- hh += (pText->h + 10);
- ww = MAX(ww, pText->w + 20);
+ hh += (pText->h + adj_size(10));
+ ww = MAX(ww, pText->w + adj_size(20));
/* cancel button */
pBuf = create_themeicon_button_from_chars(pTheme->CANCEL_Icon,
- pWindow->dst, _("Cancel"), 12, 0);
+ pWindow->dst, _("Cancel"), adj_font(12), 0);
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
pBuf->action = cancel_upgrade_unit_callback;
set_wstate(pBuf, FC_WS_NORMAL);
- hh += (pBuf->size.h + 20);
+ hh += (pBuf->size.h + adj_size(20));
add_to_gui_list(ID_BUTTON, pBuf);
- if ((ut2 != -1) && (game.player_ptr->economic.gold >= value)) {
+ if ((ut2) && (game.player_ptr->economic.gold >= value)) {
pBuf = create_themeicon_button_from_chars(pTheme->OK_Icon, pWindow->dst,
- _("Upgrade"), 12, 0);
+ _("Upgrade"), adj_font(12), 0);
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
pBuf->action = ok_upgrade_unit_window_callback;
@@ -488,9 +490,9 @@
add_to_gui_list(ID_BUTTON, pBuf);
pBuf->size.w = MAX(pBuf->size.w, pBuf->next->size.w);
pBuf->next->size.w = pBuf->size.w;
- ww = MAX(ww, 30 + pBuf->size.w * 2);
+ ww = MAX(ww, adj_size(30) + pBuf->size.w * 2);
} else {
- ww = MAX(ww, pBuf->size.w + 20);
+ ww = MAX(ww, pBuf->size.w + adj_size(20));
}
/* ============================================ */
@@ -500,7 +502,7 @@
pWindow->size.y = Main.event.motion.y;
} else {
put_window_near_map_tile(pWindow,
- ww + DOUBLE_FRAME_WH, hh, pUnit->x, pUnit->y);
+ ww + DOUBLE_FRAME_WH, hh, pUnit->tile);
}
resize_window(pWindow, NULL,
@@ -510,26 +512,26 @@
/* setup rest of widgets */
/* label */
dst.x = FRAME_WH + (ww - DOUBLE_FRAME_WH - pText->w) / 2;
- dst.y = WINDOW_TILE_HIGH + 11;
+ dst.y = WINDOW_TILE_HIGH + adj_size(11);
SDL_BlitSurface(pText, NULL, pWindow->theme, &dst);
FREESURFACE(pText);
/* cancel button */
pBuf = pWindow->prev;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - 10;
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h -
adj_size(10);
- if ((ut2 != -1) && (game.player_ptr->economic.gold >= value)) {
+ if ((ut2) && (game.player_ptr->economic.gold >= value)) {
/* sell button */
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + (ww - (2 * pBuf->size.w + 10)) / 2;
+ pBuf->size.x = pWindow->size.x + (ww - (2 * pBuf->size.w + adj_size(10)))
/ 2;
pBuf->size.y = pBuf->next->size.y;
/* cancel button */
- pBuf->next->size.x = pBuf->size.x + pBuf->size.w + 10;
+ pBuf->next->size.x = pBuf->size.x + pBuf->size.w + adj_size(10);
} else {
/* x position of cancel button */
pBuf->size.x = pWindow->size.x +
- pWindow->size.w - FRAME_WH - pBuf->size.w - 10;
+ pWindow->size.w - FRAME_WH - pBuf->size.w -
adj_size(10);
}
@@ -625,7 +627,7 @@
#define NUM_SEEN 20
- n = unit_list_size(&ptile->units);
+ n = unit_list_size(ptile->units);
if (!n || pUnit_Select_Dlg) {
return;
@@ -635,10 +637,10 @@
pUnit_Select_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
my_snprintf(cBuf , sizeof(cBuf),"%s (%d)", _("Unit selection") , n);
- pStr = create_str16_from_char(cBuf , 12);
+ pStr = create_str16_from_char(cBuf , adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 10, 10, WF_DRAW_THEME_TRANSPARENT);
+ pWindow = create_window(NULL, pStr, adj_size(10), adj_size(10),
WF_DRAW_THEME_TRANSPARENT);
pWindow->action = unit_select_window_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -653,7 +655,7 @@
pBuf->action = exit_unit_select_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
- w += (pBuf->size.w + 10);
+ w += (pBuf->size.w + adj_size(10));
add_to_gui_list(ID_UNIT_SELLECT_DLG_EXIT_BUTTON, pBuf);
@@ -661,10 +663,10 @@
h = WINDOW_TILE_HIGH + 1 + FRAME_WH;
for(i = 0; i < n; i++) {
- pUnit = unit_list_get(&ptile->units, i);
+ pUnit = unit_list_get(ptile->units, i);
pUnitType = unit_type(pUnit);
- if(pUnit->owner == game.player_idx) {
+ if(pUnit->owner == game.player_ptr) {
my_snprintf(cBuf , sizeof(cBuf), _("Contact %s (%d / %d) %s(%d,%d,%d)
%s"),
pUnit->veteran ? _("Veteran") : "" ,
pUnit->hp, pUnitType->hp,
@@ -700,7 +702,7 @@
w = MAX(w, pBuf->size.w);
h += pBuf->size.h;
- if(pUnit->owner == game.player_idx) {
+ if(pUnit->owner == game.player_ptr) {
set_wstate(pBuf, FC_WS_NORMAL);
}
@@ -726,7 +728,7 @@
NUM_SEEN * pWindow->prev->prev->size.h + FRAME_WH;
}
- put_window_near_map_tile(pWindow, w, h, pUnit->x, pUnit->y);
+ put_window_near_map_tile(pWindow, w, h, pUnit->tile);
resize_window(pWindow, NULL, NULL, w, h);
if(pUnit_Select_Dlg->pScroll) {
@@ -799,18 +801,17 @@
/***************************************************************
Return a (static) string with terrain defense bonus;
***************************************************************/
-const char *sdl_get_tile_defense_info_text(struct tile *pTile)
+const char *sdl_get_tile_defense_info_text(struct tile *ptile)
{
static char buffer[64];
- int bonus = (terrains[pTile->terrain].defense_bonus - 10) * 10;
+ int bonus = (ptile->terrain->defense_bonus - 10) * 10;
- if((pTile->special & S_RIVER) == S_RIVER) {
+ if(tile_has_special(ptile, S_RIVER)) {
bonus += terrain_control.river_defense_bonus;
}
- if((pTile->special & S_FORTRESS) == S_FORTRESS) {
+ if(tile_has_special(ptile, S_FORTRESS)) {
bonus += terrain_control.fortress_defense_bonus;
}
-
my_snprintf(buffer, sizeof(buffer), "Terrain Defense Bonus: +%d%% ", bonus);
return buffer;
@@ -827,36 +828,36 @@
static char s[128];
bool first;
- my_snprintf(s, sizeof(s), "%s", terrains[pTile->terrain].name);
- if((pTile->special & S_RIVER) == S_RIVER) {
+ my_snprintf(s, sizeof(s), "%s", pTile->terrain->name);
+ if(tile_has_special(pTile, S_RIVER)) {
sz_strlcat(s, "/");
sz_strlcat(s, get_special_name(S_RIVER));
}
first = TRUE;
- if ((pTile->special & S_SPECIAL_1) == S_SPECIAL_1) {
+ if (tile_has_special(pTile, S_SPECIAL_1)) {
first = FALSE;
- cat_snprintf(s, sizeof(s), " (%s",
terrains[pTile->terrain].special_1_name);
+ cat_snprintf(s, sizeof(s), " (%s", pTile->terrain->special[0].name);
}
- if ((pTile->special & S_SPECIAL_2) == S_SPECIAL_2) {
+ if (tile_has_special(pTile, S_SPECIAL_2)) {
if (first) {
first = FALSE;
sz_strlcat(s, " (");
} else {
sz_strlcat(s, "/");
}
- sz_strlcat(s, terrains[pTile->terrain].special_2_name);
+ sz_strlcat(s, pTile->terrain->special[1].name);
}
if (!first) {
sz_strlcat(s, ")");
}
first = TRUE;
- if ((pTile->special & S_POLLUTION) == S_POLLUTION) {
+ if (tile_has_special(pTile, S_POLLUTION)) {
first = FALSE;
cat_snprintf(s, sizeof(s), "\n[%s", get_special_name(S_POLLUTION));
}
- if ((pTile->special & S_FALLOUT) == S_FALLOUT) {
+ if (tile_has_special(pTile, S_FALLOUT)) {
if (first) {
first = FALSE;
sz_strlcat(s, "\n[");
@@ -876,24 +877,25 @@
Popup terrain information dialog.
**************************************************************************/
static void popup_terrain_info_dialog(SDL_Surface *pDest,
- struct tile *pTile , int x , int y)
+ struct tile *ptile)
{
SDL_Surface *pSurf;
struct GUI *pBuf, *pWindow;
SDL_String16 *pStr;
char cBuf[256];
+ int infra_count;
if (pTerrain_Info_Dlg) {
return;
}
- pSurf = get_terrain_surface(x, y);
+ pSurf = get_terrain_surface(ptile);
pTerrain_Info_Dlg = MALLOC(sizeof(struct SMALL_DLG));
/* ----------- */
- my_snprintf(cBuf, sizeof(cBuf), "%s [%d,%d]", _("Terrain Info"), x , y);
+ my_snprintf(cBuf, sizeof(cBuf), "%s [%d,%d]", _("Terrain Info"), ptile->x ,
ptile->y);
- pWindow = create_window(pDest, create_str16_from_char(cBuf , 12), 10, 10, 0);
+ pWindow = create_window(pDest, create_str16_from_char(cBuf , adj_font(12)),
adj_size(10), adj_size(10), 0);
pWindow->string16->style |= TTF_STYLE_BOLD;
pWindow->action = terrain_info_window_dlg_callback;
@@ -903,65 +905,66 @@
pTerrain_Info_Dlg->pEndWidgetList = pWindow;
/* ---------- */
- if(client_tile_get_known(x, y) >= TILE_KNOWN_FOGGED) {
+ if(client_tile_get_known(ptile) >= TILE_KNOWN_FOGGED) {
my_snprintf(cBuf, sizeof(cBuf), _("Terrain: %s\nFood/Prod/Trade: %s\n%s"),
- sdl_map_get_tile_info_text(pTile),
- get_tile_output_text(x, y),
- sdl_get_tile_defense_info_text(pTile));
+ sdl_map_get_tile_info_text(ptile),
+ get_tile_output_text(ptile),
+ sdl_get_tile_defense_info_text(ptile));
- if (tile_has_special(pTile, S_HUT))
+ if (tile_has_special(ptile, S_HUT))
{
sz_strlcat(cBuf, _("\nMinor Tribe Village"));
}
else
{
- if (get_tile_infrastructure_set(pTile))
+ get_tile_infrastructure_set(ptile, &infra_count);
+ if (infra_count > 0)
{
cat_snprintf(cBuf, sizeof(cBuf), _("\nInfrastructure: %s"),
- get_infrastructure_text(pTile->special));
+ get_infrastructure_text(ptile->special));
}
}
- if (game.info.borders > 0 && !pTile->city) {
+ if (game.info.borders > 0 && !ptile->city) {
struct player_diplstate *ds = game.player_ptr->diplstates;
const char *diplo_nation_plural_adjectives[DS_LAST] =
{Q_("?nation:Neutral"), Q_("?nation:Hostile"),
"" /* unused, DS_CEASEFIRE*/, Q_("?nation:Peaceful"),
Q_("?nation:Friendly"), Q_("?nation:Mysterious")};
- if (pTile->owner == game.player_ptr){
+ if (ptile->owner == game.player_ptr){
cat_snprintf(cBuf, sizeof(cBuf), _("\nOur Territory"));
- } else if (pTile->owner) {
- if (ds[pTile->owner->player_no].type == DS_CEASEFIRE){
- int turns = ds[pTile->owner->player_no].turns_left;
+ } else if (ptile->owner) {
+ if (ds[ptile->owner->player_no].type == DS_CEASEFIRE){
+ int turns = ds[ptile->owner->player_no].turns_left;
cat_snprintf(cBuf, sizeof(cBuf),
PL_("\n%s territory (%d turn ceasefire)",
"\n%s territory (%d turn ceasefire)", turns),
- get_nation_name(pTile->owner->nation), turns);
+ get_nation_name(ptile->owner->nation), turns);
} else {
cat_snprintf(cBuf, sizeof(cBuf), _("\nTerritory of the %s %s"),
-
diplo_nation_plural_adjectives[ds[pTile->owner->player_no].type],
- get_nation_name_plural(pTile->owner->nation));
+
diplo_nation_plural_adjectives[ds[ptile->owner->player_no].type],
+ get_nation_name_plural(ptile->owner->nation));
}
} else {
cat_snprintf(cBuf, sizeof(cBuf), _("\nUnclaimed territory"));
}
}
- if (pTile->city) {
+ if (ptile->city) {
/* Look at city owner, not tile owner (the two should be the same, if
* borders are in use). */
- struct player *pOwner = city_owner(pTile->city);
+ struct player *pOwner = city_owner(ptile->city);
struct player_diplstate *ds = game.player_ptr->diplstates;
const char *diplo_city_adjectives[DS_LAST] =
{Q_("?city:Neutral"), Q_("?city:Hostile"),
"" /*unused, DS_CEASEFIRE */, Q_("?city:Peaceful"),
Q_("?city:Friendly"), Q_("?city:Mysterious")};
- cat_snprintf(cBuf, sizeof(cBuf), _("\nCity of %s"), pTile->city->name);
- if (city_got_citywalls(pTile->city)) {
+ cat_snprintf(cBuf, sizeof(cBuf), _("\nCity of %s"), ptile->city->name);
+ if (city_got_citywalls(ptile->city)) {
cat_snprintf(cBuf, sizeof(cBuf), _(" with City Walls"));
}
if (pOwner && pOwner != game.player_ptr) {
@@ -987,7 +990,7 @@
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pStr->style |= SF_CENTER;
pBuf = create_iconlabel(pSurf, pWindow->dst, pStr, WF_FREE_THEME);
@@ -996,17 +999,17 @@
add_to_gui_list(ID_LABEL, pBuf);
/* ------ window ---------- */
- pWindow->size.w = pBuf->size.w + 20;
+ pWindow->size.w = pBuf->size.w + adj_size(20);
pWindow->size.h = pBuf->size.h + WINDOW_TILE_HIGH + 1 + FRAME_WH;
- put_window_near_map_tile(pWindow, pWindow->size.w, pWindow->size.h, x, y);
+ put_window_near_map_tile(pWindow, pWindow->size.w, pWindow->size.h, ptile);
resize_window(pWindow, NULL,
get_game_colorRGB(COLOR_STD_BACKGROUND_BROWN),
pWindow->size.w, pWindow->size.h);
/* ------------------------ */
- pBuf->size.x = pWindow->size.x + 10;
+ pBuf->size.x = pWindow->size.x + adj_size(10);
pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 1;
pBuf = create_themeicon(pTheme->Small_CANCEL_Icon, pWindow->dst,
@@ -1077,7 +1080,7 @@
lock_buffer(pWidget->dst);
popdown_advanced_terrain_dialog();
- popup_terrain_info_dialog(get_locked_buffer(), map_get_tile(x , y), x, y);
+ popup_terrain_info_dialog(get_locked_buffer(), map_pos_to_tile(x , y));
unlock_buffer();
return -1;
}
@@ -1092,7 +1095,7 @@
lock_buffer(pWidget->dst);
popdown_advanced_terrain_dialog();
- popup_city_dialog(pCity, 0);
+ popup_city_dialog(pCity);
return -1;
}
@@ -1160,7 +1163,7 @@
popdown_advanced_terrain_dialog();
if (pUnit) {
- activate_all_units(pUnit->x, pUnit->y);
+ activate_all_units(pUnit->tile);
}
return -1;
}
@@ -1175,9 +1178,9 @@
popdown_advanced_terrain_dialog();
if (pUnit) {
- struct tile *ptile = map_get_tile(pUnit->x, pUnit->y);
+ struct tile *ptile = pUnit->tile;
unit_list_iterate(ptile->units, punit) {
- if (game.player_idx == punit->owner && (punit->activity == ACTIVITY_IDLE)
+ if (game.player_ptr == punit->owner && (punit->activity == ACTIVITY_IDLE)
&& !punit->ai.control && can_unit_do_activity(punit, ACTIVITY_SENTRY))
{
request_new_unit_activity(punit, ACTIVITY_SENTRY);
}
@@ -1197,7 +1200,7 @@
popdown_advanced_terrain_dialog();
/* may not work */
- send_goto_tile(get_unit_in_focus(), x, y);
+ send_goto_tile(get_unit_in_focus(), map_pos_to_tile(x, y));
return -1;
}
@@ -1216,7 +1219,7 @@
if(pUnit) {
enter_goto_state(pUnit);
/* may not work */
- do_unit_patrol_to(pUnit, x, y);
+ do_unit_patrol_to(pUnit, map_pos_to_tile(x, y));
exit_goto_state();
}
return -1;
@@ -1233,7 +1236,7 @@
popdown_advanced_terrain_dialog();
/* may not work */
- do_unit_paradrop_to(get_unit_in_focus(), x, y);
+ do_unit_paradrop_to(get_unit_in_focus(), map_pos_to_tile(x, y));
return -1;
}
@@ -1254,10 +1257,9 @@
Popup a generic dialog to display some generic information about
terrain : tile, units , cities, etc.
**************************************************************************/
-void popup_advanced_terrain_dialog(int x , int y)
+void popup_advanced_terrain_dialog(struct tile *ptile)
{
struct GUI *pWindow = NULL, *pBuf = NULL;
- struct tile *pTile;
struct city *pCity;
struct unit *pFocus_Unit;
SDL_String16 *pStr;
@@ -1270,30 +1272,29 @@
return;
}
- pTile = map_get_tile(x, y);
- pCity = pTile->city;
- n = unit_list_size(&pTile->units);
+ pCity = ptile->city;
+ n = unit_list_size(ptile->units);
pFocus_Unit = get_unit_in_focus();
if (!n && !pCity && !pFocus_Unit)
{
- popup_terrain_info_dialog(NULL, pTile, x, y);
+ popup_terrain_info_dialog(NULL, ptile);
return;
}
- h = WINDOW_TILE_HIGH + 3 + FRAME_WH;
+ h = WINDOW_TILE_HIGH + adj_size(3) + FRAME_WH;
is_unit_move_blocked = TRUE;
pAdvanced_Terrain_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
pCont = MALLOC(sizeof(struct CONTAINER));
- pCont->id0 = x;
- pCont->id1 = y;
+ pCont->id0 = ptile->x;
+ pCont->id1 = ptile->y;
- pStr = create_str16_from_char(_("Advanced Menu") , 12);
+ pStr = create_str16_from_char(_("Advanced Menu") , adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 10, 10, WF_DRAW_THEME_TRANSPARENT);
+ pWindow = create_window(NULL, pStr, adj_size(10), adj_size(10),
WF_DRAW_THEME_TRANSPARENT);
pWindow->action = advanced_terrain_window_dlg_callback;
set_wstate(pWindow , FC_WS_NORMAL);
@@ -1306,7 +1307,7 @@
pBuf = create_themeicon(pTheme->Small_CANCEL_Icon, pWindow->dst,
WF_DRAW_THEME_TRANSPARENT);
- w += pBuf->size.w + 10;
+ w += pBuf->size.w + adj_size(10);
pBuf->action = exit_advanced_terrain_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
@@ -1314,7 +1315,7 @@
add_to_gui_list(ID_TERRAIN_ADV_DLG_EXIT_BUTTON, pBuf);
/* ---------- */
- pStr = create_str16_from_char(_("Terrain Info") , 10);
+ pStr = create_str16_from_char(_("Terrain Info") , adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pBuf = create_iconlabel(NULL, pWindow->dst, pStr ,
@@ -1334,7 +1335,7 @@
h += pBuf->size.h;
/* ---------- */
- if (pCity && pCity->owner == game.player_idx)
+ if (pCity && pCity->owner == game.player_ptr)
{
/* separator */
pBuf = create_iconlabel(NULL, pWindow->dst, NULL, WF_FREE_THEME);
@@ -1394,7 +1395,7 @@
}
/* ---------- */
- if(pFocus_Unit && (pFocus_Unit->x != x || pFocus_Unit->y != y)) {
+ if(pFocus_Unit && (pFocus_Unit->tile->x != ptile->x || pFocus_Unit->tile->y
!= ptile->y)) {
/* separator */
pBuf = create_iconlabel(NULL, pWindow->dst, NULL, WF_FREE_THEME);
@@ -1439,13 +1440,13 @@
}
#endif
- if(can_unit_paradrop(pFocus_Unit) && pTile->known &&
- !(is_ocean(pTile->terrain) && is_ground_unit(pFocus_Unit)) &&
- !(is_sailing_unit(pFocus_Unit) && (!is_ocean(pTile->terrain) || !pCity))
&&
+ if(can_unit_paradrop(pFocus_Unit) && client_tile_get_known(ptile) &&
+ !(is_ocean(ptile->terrain) && is_ground_unit(pFocus_Unit)) &&
+ !(is_sailing_unit(pFocus_Unit) && (!is_ocean(ptile->terrain) || !pCity))
&&
!(((pCity && pplayers_non_attack(game.player_ptr, city_owner(pCity)))
- || is_non_attack_unit_tile(pTile, game.player_ptr))) &&
+ || is_non_attack_unit_tile(ptile, game.player_ptr))) &&
(unit_type(pFocus_Unit)->paratroopers_range >=
- real_map_distance(pFocus_Unit->x, pFocus_Unit->y, x, y))) {
+ real_map_distance(pFocus_Unit->tile, ptile))) {
create_active_iconlabel(pBuf, pWindow->dst, pStr, _("Paradrop here"),
paradrop_here_callback);
@@ -1485,15 +1486,15 @@
#define ADV_NUM_SEEN 15
- pDefender = (pFocus_Unit ? get_defender(pFocus_Unit, x, y) : NULL);
- pAttacker = (pFocus_Unit ? get_attacker(pFocus_Unit, x, y) : NULL);
+ pDefender = (pFocus_Unit ? get_defender(pFocus_Unit, ptile) : NULL);
+ pAttacker = (pFocus_Unit ? get_attacker(pFocus_Unit, ptile) : NULL);
for(i=0; i<n; i++) {
- pUnit = unit_list_get(&pTile->units, i);
+ pUnit = unit_list_get(ptile->units, i);
if (pUnit == pFocus_Unit) {
continue;
}
pUnitType = unit_type(pUnit);
- if(pUnit->owner == game.player_idx) {
+ if(pUnit->owner == game.player_ptr) {
my_snprintf(cBuf, sizeof(cBuf),
_("Activate %s (%d / %d) %s (%d,%d,%d) %s"),
pUnit->veteran ? _("Veteran") : "" ,
@@ -1530,11 +1531,11 @@
}
if (pAttacker && pAttacker == pUnit) {
- pStr->fgcol = *(get_game_colorRGB(COLOR_STD_RED));
+ pStr->fgcol = *(get_game_colorRGB(COLOR_OVERVIEW_ENEMY_UNIT));
reset = TRUE;
} else {
if (pDefender && pDefender == pUnit) {
- pStr->fgcol = *(get_game_colorRGB(COLOR_STD_GROUND));
+ pStr->fgcol = *(get_game_colorRGB(COLOR_OVERVIEW_MY_UNIT));
reset = TRUE;
}
}
@@ -1604,11 +1605,11 @@
else
{ /* n == 1 */
/* one unit - give orders */
- pUnit = unit_list_get(&pTile->units, 0);
+ pUnit = unit_list_get(ptile->units, 0);
pUnitType = unit_type(pUnit);
if (pUnit != pFocus_Unit) {
- if ((pCity && pCity->owner == game.player_idx) ||
- (pUnit->owner == game.player_idx))
+ if ((pCity && pCity->owner == game.player_ptr) ||
+ (pUnit->owner == game.player_ptr))
{
my_snprintf(cBuf, sizeof(cBuf),
_("Activate %s (%d / %d) %s (%d,%d,%d) %s"),
@@ -1673,7 +1674,7 @@
create_active_iconlabel(pBuf, pWindow->dst, pStr,
cBuf, unit_help_callback);
set_wstate(pBuf , FC_WS_NORMAL);
- add_to_gui_list(MAX_ID - pUnit->type, pBuf);
+ add_to_gui_list(MAX_ID - pUnit->type->index, pBuf);
w = MAX(w, pBuf->size.w);
units_h += pBuf->size.h;
@@ -1684,14 +1685,14 @@
}
/* ---------- */
- w += (DOUBLE_FRAME_WH + 2);
+ w += (DOUBLE_FRAME_WH + adj_size(2));
h += units_h;
- put_window_near_map_tile(pWindow, w, h, x, y);
+ put_window_near_map_tile(pWindow, w, h, ptile);
resize_window(pWindow, NULL, NULL, w, h);
- w -= (DOUBLE_FRAME_WH + 2);
+ w -= (DOUBLE_FRAME_WH + adj_size(2));
if (pAdvanced_Terrain_Dlg->pScroll)
{
@@ -1712,12 +1713,12 @@
pBuf = pBuf->prev;
pBuf->size.x = pWindow->size.x + FRAME_WH + 1;
- pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 2;
+ pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(2);
pBuf->size.w = w;
h = pBuf->size.h;
- area.x = 10;
- area.h = 2;
+ area.x = adj_size(10);
+ area.h = adj_size(2);
pBuf = pBuf->prev;
while(pBuf)
@@ -1739,7 +1740,7 @@
pBuf->theme = create_surf(w , h , SDL_SWSURFACE);
area.y = pBuf->size.h / 2 - 1;
- area.w = pBuf->size.w - 20;
+ area.w = pBuf->size.w - adj_size(20);
SDL_FillRect(pBuf->theme, &area, 64);
SDL_SetColorKey(pBuf->theme, SDL_SRCCOLORKEY|SDL_RLEACCEL, 0x0);
@@ -1845,16 +1846,16 @@
pCaravan_Dlg = MALLOC(sizeof(struct SMALL_DLG));
is_unit_move_blocked = TRUE;
- h = WINDOW_TILE_HIGH + 3 + FRAME_WH;
+ h = WINDOW_TILE_HIGH + adj_size(3) + FRAME_WH;
my_snprintf(cBuf, sizeof(cBuf), _("Your caravan has arrived at %s"),
pDestcity->name);
/* window */
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 10, 10, WF_DRAW_THEME_TRANSPARENT);
+ pWindow = create_window(NULL, pStr, adj_size(10), adj_size(10),
WF_DRAW_THEME_TRANSPARENT);
pWindow->action = caravan_dlg_window_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -1928,7 +1929,7 @@
auto_center_on_focus_unit();
put_window_near_map_tile(pWindow,
- w + DOUBLE_FRAME_WH, h, pUnit->x, pUnit->y);
+ w + DOUBLE_FRAME_WH, h, pUnit->tile);
resize_window(pWindow, NULL, NULL, pWindow->size.w, h);
/* setup widget size and start position */
@@ -1936,7 +1937,7 @@
pBuf = pWindow->prev;
setup_vertical_widgets_position(1,
pWindow->size.x + FRAME_WH,
- pWindow->size.y + WINDOW_TILE_HIGH + 2, w, 0,
+ pWindow->size.y + WINDOW_TILE_HIGH + adj_size(2), w, 0,
pCaravan_Dlg->pBeginWidgetList, pBuf);
/* --------------------- */
/* redraw */
@@ -1949,11 +1950,19 @@
Is there currently a caravan dialog open? This is important if there
can be only one such dialog at a time; otherwise return FALSE.
**************************************************************************/
-bool caravan_dialog_is_open(void)
+bool caravan_dialog_is_open(int *unit_id, int *city_id)
{
return pCaravan_Dlg != NULL;
}
+/****************************************************************
+ Updates caravan dialog
+****************************************************************/
+void caravan_dialog_update(void)
+{
+ /* PORT ME */
+}
+
/* ====================================================================== */
/* ============================ DIPLOMAT DIALOG ========================= */
/* ====================================================================== */
@@ -2137,15 +2146,15 @@
pDiplomat_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
- pStr = create_str16_from_char(_("Select Advance to Steal"), 12);
+ pStr = create_str16_from_char(_("Select Advance to Steal"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(get_locked_buffer(), pStr, 10, 10, 0);
+ pWindow = create_window(get_locked_buffer(), pStr, adj_size(10),
adj_size(10), 0);
unlock_buffer();
pWindow->action = spy_steal_dlg_window_callback;
set_wstate(pWindow , FC_WS_NORMAL);
- w = MAX(0, pWindow->size.w + 8);
+ w = MAX(0, pWindow->size.w + adj_size(8));
add_to_gui_list(ID_CARAVAN_DLG_WINDOW, pWindow);
pDiplomat_Dlg->pEndWidgetList = pWindow;
@@ -2154,7 +2163,7 @@
pBuf = create_themeicon(pTheme->Small_CANCEL_Icon, pWindow->dst,
WF_DRAW_THEME_TRANSPARENT);
- w += pBuf->size.w + 10;
+ w += pBuf->size.w + adj_size(10);
pBuf->action = exit_spy_steal_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
@@ -2164,9 +2173,9 @@
count++; /* count + at Spy's Discretion */
/* max col - 104 is steal tech widget width */
- max_col = (Main.screen->w - DOUBLE_FRAME_WH - 2) / 104;
+ max_col = (Main.screen->w - DOUBLE_FRAME_WH - adj_size(2)) / adj_size(104);
/* max row - 204 is steal tech widget height */
- max_row = (Main.screen->h - (WINDOW_TILE_HIGH + 1 + 2 + FRAME_WH)) / 204;
+ max_row = (Main.screen->h - (WINDOW_TILE_HIGH + adj_size(1 + 2) + FRAME_WH))
/ adj_size(204);
/* make space on screen for scrollbar */
if (max_col * max_row < count) {
@@ -2176,10 +2185,10 @@
if (count < max_col + 1) {
col = count;
} else {
- if (count < max_col + 3) {
- col = max_col - 2;
+ if (count < max_col + adj_size(3)) {
+ col = max_col - adj_size(2);
} else {
- if (count < max_col + 5) {
+ if (count < max_col + adj_size(5)) {
col = max_col - 1;
} else {
col = max_col;
@@ -2187,7 +2196,7 @@
}
}
- pStr = create_string16(NULL, 0, 10);
+ pStr = create_string16(NULL, 0, adj_font(10));
pStr->style |= (TTF_STYLE_BOLD | SF_CENTER);
count = 0;
@@ -2250,8 +2259,8 @@
count = 1;
}
- w = MAX(w, (col * pBuf->size.w + 2 + DOUBLE_FRAME_WH + i));
- h = WINDOW_TILE_HIGH + 1 + count * pBuf->size.h + 2 + FRAME_WH;
+ w = MAX(w, (col * pBuf->size.w + adj_size(2) + DOUBLE_FRAME_WH + i));
+ h = WINDOW_TILE_HIGH + 1 + count * pBuf->size.h + adj_size(2) + FRAME_WH;
pWindow->size.x = (Main.screen->w - w) / 2;
pWindow->size.y = (Main.screen->h - h) / 2;
@@ -2264,7 +2273,7 @@
/* exit button */
pBuf = pWindow->prev;
- pBuf->size.x = pWindow->size.x + pWindow->size.w-pBuf->size.w-FRAME_WH-1;
+ pBuf->size.x = pWindow->size.x + pWindow->size.w - pBuf->size.w - FRAME_WH -
1;
pBuf->size.y = pWindow->size.y + 1;
setup_vertical_widgets_position(col, pWindow->size.x + FRAME_WH + 1,
@@ -2332,7 +2341,7 @@
popdown_diplomat_dialog();
- if(pUnit && pCity && !same_pos(pUnit->x, pUnit->y, pCity->x, pCity->y)) {
+ if(pUnit && pCity && !same_pos(pUnit->tile, pCity->tile)) {
request_diplomat_action(DIPLOMAT_MOVE, pUnit->id, pCity->id, 0);
}
process_diplomat_arrival(NULL, 0);
@@ -2401,7 +2410,7 @@
Popup a dialog giving a diplomatic unit some options when moving into
the target tile.
**************************************************************************/
-void popup_diplomat_dialog(struct unit *pUnit, int target_x, int target_y)
+void popup_diplomat_dialog(struct unit *pUnit, struct tile *ptile)
{
struct GUI *pWindow = NULL, *pBuf = NULL;
SDL_String16 *pStr;
@@ -2415,36 +2424,36 @@
}
is_unit_move_blocked = TRUE;
- pCity = tile_get_city(target_x, target_y);
+ pCity = tile_get_city(ptile);
spy = unit_flag(pUnit, F_SPY);
pDiplomat_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
- h = WINDOW_TILE_HIGH + 3 + FRAME_WH;
+ h = WINDOW_TILE_HIGH + adj_size(3) + FRAME_WH;
/* window */
if (pCity)
{
if(spy) {
- pStr = create_str16_from_char(_("Choose Your Spy's Strategy") , 12);
+ pStr = create_str16_from_char(_("Choose Your Spy's Strategy") ,
adj_font(12));
}
else
{
- pStr = create_str16_from_char(_("Choose Your Diplomat's Strategy"), 12);
+ pStr = create_str16_from_char(_("Choose Your Diplomat's Strategy"),
adj_font(12));
}
}
else
{
- pStr = create_str16_from_char(_("Subvert Enemy Unit"), 12);
+ pStr = create_str16_from_char(_("Subvert Enemy Unit"), adj_font(12));
}
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 10, 10, WF_DRAW_THEME_TRANSPARENT);
+ pWindow = create_window(NULL, pStr, adj_size(10), adj_size(10),
WF_DRAW_THEME_TRANSPARENT);
pWindow->action = diplomat_dlg_window_callback;
set_wstate(pWindow, FC_WS_NORMAL);
- w = MAX(w, pWindow->size.w + 8);
+ w = MAX(w, pWindow->size.w + adj_size(8));
add_to_gui_list(ID_CARAVAN_DLG_WINDOW, pWindow);
pDiplomat_Dlg->pEndWidgetList = pWindow;
@@ -2455,7 +2464,7 @@
/* Spy/Diplomat acting against a city */
/* -------------- */
- if (diplomat_can_do_action(pUnit, DIPLOMAT_EMBASSY, target_x, target_y))
+ if (diplomat_can_do_action(pUnit, DIPLOMAT_EMBASSY, ptile))
{
create_active_iconlabel(pBuf, pWindow->dst, pStr,
@@ -2471,7 +2480,7 @@
}
/* ---------- */
- if (diplomat_can_do_action(pUnit, DIPLOMAT_INVESTIGATE, target_x,
target_y)) {
+ if (diplomat_can_do_action(pUnit, DIPLOMAT_INVESTIGATE, ptile)) {
create_active_iconlabel(pBuf, pWindow->dst, pStr,
_("Investigate City"),
@@ -2486,7 +2495,7 @@
}
/* ---------- */
- if (spy && diplomat_can_do_action(pUnit, SPY_POISON, target_x, target_y)) {
+ if (spy && diplomat_can_do_action(pUnit, SPY_POISON, ptile)) {
create_active_iconlabel(pBuf, pWindow->dst, pStr,
_("Poison City"), spy_poison_callback);
@@ -2500,7 +2509,7 @@
h += pBuf->size.h;
}
/* ---------- */
- if (diplomat_can_do_action(pUnit, DIPLOMAT_SABOTAGE, target_x, target_y)) {
+ if (diplomat_can_do_action(pUnit, DIPLOMAT_SABOTAGE, ptile)) {
create_active_iconlabel(pBuf, pWindow->dst, pStr,
_("Sabotage City"),
@@ -2516,7 +2525,7 @@
}
/* ---------- */
- if (diplomat_can_do_action(pUnit, DIPLOMAT_STEAL, target_x, target_y)) {
+ if (diplomat_can_do_action(pUnit, DIPLOMAT_STEAL, ptile)) {
create_active_iconlabel(pBuf, pWindow->dst, pStr,
_("Steal Technology"),
@@ -2531,7 +2540,7 @@
}
/* ---------- */
- if (diplomat_can_do_action(pUnit, DIPLOMAT_INCITE, target_x, target_y)) {
+ if (diplomat_can_do_action(pUnit, DIPLOMAT_INCITE, ptile)) {
create_active_iconlabel(pBuf, pWindow->dst, pStr,
_("Incite a Revolt"), diplomat_incite_callback);
@@ -2545,7 +2554,7 @@
}
/* ---------- */
- if (diplomat_can_do_action(pUnit, DIPLOMAT_MOVE, target_x, target_y)) {
+ if (diplomat_can_do_action(pUnit, DIPLOMAT_MOVE, ptile)) {
create_active_iconlabel(pBuf, pWindow->dst, pStr,
_("Keep moving"), diplomat_keep_moving_callback);
@@ -2561,10 +2570,10 @@
}
else
{
- if((pTunit=unit_list_get(&map_get_tile(target_x, target_y)->units, 0))){
+ if((pTunit=unit_list_get(ptile->units, 0))){
/* Spy/Diplomat acting against a unit */
/* ---------- */
- if (diplomat_can_do_action(pUnit, DIPLOMAT_BRIBE, target_x, target_y)) {
+ if (diplomat_can_do_action(pUnit, DIPLOMAT_BRIBE, ptile)) {
create_active_iconlabel(pBuf, pWindow->dst, pStr,
_("Bribe Enemy Unit"), diplomat_bribe_callback);
@@ -2579,7 +2588,7 @@
}
/* ---------- */
- if (diplomat_can_do_action(pUnit, SPY_SABOTAGE_UNIT, target_x,
target_y)) {
+ if (diplomat_can_do_action(pUnit, SPY_SABOTAGE_UNIT, ptile)) {
create_active_iconlabel(pBuf, pWindow->dst, pStr,
_("Sabotage Enemy Unit"), spy_sabotage_unit_callback);
@@ -2616,7 +2625,7 @@
auto_center_on_focus_unit();
put_window_near_map_tile(pWindow,
- w + DOUBLE_FRAME_WH, h, pUnit->x, pUnit->y);
+ w + DOUBLE_FRAME_WH, h, pUnit->tile);
resize_window(pWindow, NULL, NULL, pWindow->size.w, h);
/* setup widget size and start position */
@@ -2624,7 +2633,7 @@
pBuf = pWindow->prev;
setup_vertical_widgets_position(1,
pWindow->size.x + FRAME_WH,
- pWindow->size.y + WINDOW_TILE_HIGH + 2, w, 0,
+ pWindow->size.y + WINDOW_TILE_HIGH + adj_size(2), w, 0,
pDiplomat_Dlg->pBeginWidgetList, pBuf);
/* --------------------- */
@@ -2635,15 +2644,6 @@
}
-/**************************************************************************
- Return whether a diplomat dialog is open. This is important if there
- can be only one such dialog at a time; otherwise return FALSE.
-**************************************************************************/
-bool diplomat_dialog_is_open(void)
-{
- return pDiplomat_Dlg != NULL;
-}
-
/* ====================================================================== */
/* ============================ SABOTAGE DIALOG ========================= */
/* ====================================================================== */
@@ -2698,11 +2698,11 @@
pCont->id0 = pCity->id;
pCont->id1 = pUnit->id;/* spy id */
- pStr = create_str16_from_char(_("Select Improvement to Sabotage") , 12);
+ pStr = create_str16_from_char(_("Select Improvement to Sabotage") ,
adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
pWindow = create_window(get_locked_buffer(),
- pStr, 10, 10, WF_DRAW_THEME_TRANSPARENT);
+ pStr, adj_size(10), adj_size(10), WF_DRAW_THEME_TRANSPARENT);
unlock_buffer();
pWindow->action = advanced_terrain_window_dlg_callback;
@@ -2715,7 +2715,7 @@
/* exit button */
pBuf = create_themeicon(pTheme->Small_CANCEL_Icon, pWindow->dst,
WF_DRAW_THEME_TRANSPARENT);
- w += pBuf->size.w + 10;
+ w += pBuf->size.w + adj_size(10);
pBuf->action = exit_advanced_terrain_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
@@ -2812,7 +2812,7 @@
h += imp_h;
auto_center_on_focus_unit();
- put_window_near_map_tile(pWindow, w, h, pUnit->x, pUnit->y);
+ put_window_near_map_tile(pWindow, w, h, pUnit->tile);
resize_window(pWindow, NULL, NULL, w, h);
w -= DOUBLE_FRAME_WH;
@@ -2829,19 +2829,19 @@
/* exit button */
pBuf = pWindow->prev;
- pBuf->size.x = pWindow->size.x + pWindow->size.w-pBuf->size.w-FRAME_WH-1;
+ pBuf->size.x = pWindow->size.x + pWindow->size.w - pBuf->size.w - FRAME_WH -
1;
pBuf->size.y = pWindow->size.y + 1;
/* Production sabotage */
pBuf = pBuf->prev;
pBuf->size.x = pWindow->size.x + FRAME_WH;
- pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 2;
+ pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(2);
pBuf->size.w = w;
h = pBuf->size.h;
- area.x = 10;
- area.h = 2;
+ area.x = adj_size(10);
+ area.h = adj_size(2);
pBuf = pBuf->prev;
while(pBuf)
@@ -2863,7 +2863,7 @@
pBuf->theme = create_surf(w, h, SDL_SWSURFACE);
area.y = pBuf->size.h / 2 - 1;
- area.w = pBuf->size.w - 20;
+ area.w = pBuf->size.w - adj_size(20);
SDL_FillRect(pBuf->theme , &area, 64);
SDL_SetColorKey(pBuf->theme, SDL_SRCCOLORKEY|SDL_RLEACCEL, 0x0);
@@ -2971,20 +2971,20 @@
is_unit_move_blocked = TRUE;
pIncite_Dlg = MALLOC(sizeof(struct SMALL_DLG));
- h = WINDOW_TILE_HIGH + 3 + FRAME_WH;
+ h = WINDOW_TILE_HIGH + adj_size(3) + FRAME_WH;
/* window */
- pStr = create_str16_from_char(_("Incite a Revolt!"), 12);
+ pStr = create_str16_from_char(_("Incite a Revolt!"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
pWindow = create_window(get_locked_buffer(),
- pStr, 10, 10, WF_DRAW_THEME_TRANSPARENT);
+ pStr, adj_size(10), adj_size(10),
WF_DRAW_THEME_TRANSPARENT);
unlock_buffer();
pWindow->action = incite_dlg_window_callback;
set_wstate(pWindow, FC_WS_NORMAL);
- w = MAX(w, pWindow->size.w + 8);
+ w = MAX(w, pWindow->size.w + adj_size(8));
add_to_gui_list(ID_INCITE_DLG_WINDOW, pWindow);
pIncite_Dlg->pEndWidgetList = pWindow;
@@ -2994,7 +2994,7 @@
/* exit button */
pBuf = create_themeicon(pTheme->Small_CANCEL_Icon, pWindow->dst,
WF_DRAW_THEME_TRANSPARENT);
- w += pBuf->size.w + 10;
+ w += pBuf->size.w + adj_size(10);
pBuf->action = exit_incite_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
@@ -3061,7 +3061,7 @@
/* exit button */
pBuf = create_themeicon(pTheme->Small_CANCEL_Icon, pWindow->dst,
WF_DRAW_THEME_TRANSPARENT);
- w += pBuf->size.w + 10;
+ w += pBuf->size.w + adj_size(10);
pBuf->action = exit_incite_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
@@ -3101,7 +3101,7 @@
auto_center_on_focus_unit();
put_window_near_map_tile(pWindow,
- w + DOUBLE_FRAME_WH, h, pCity->x, pCity->y);
+ w + DOUBLE_FRAME_WH, h, pCity->tile);
resize_window(pWindow, NULL, NULL, pWindow->size.w, h);
/* setup widget size and start position */
@@ -3110,14 +3110,14 @@
if (exit)
{/* exit button */
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + pWindow->size.w-pBuf->size.w-FRAME_WH-1;
+ pBuf->size.x = pWindow->size.x + pWindow->size.w - pBuf->size.w - FRAME_WH
- 1;
pBuf->size.y = pWindow->size.y + 1;
}
pBuf = pBuf->prev;
setup_vertical_widgets_position(1,
pWindow->size.x + FRAME_WH,
- pWindow->size.y + WINDOW_TILE_HIGH + 2, w, 0,
+ pWindow->size.y + WINDOW_TILE_HIGH + adj_size(2), w, 0,
pIncite_Dlg->pBeginWidgetList, pBuf);
/* --------------------- */
@@ -3199,20 +3199,20 @@
is_unit_move_blocked = TRUE;
pBribe_Dlg = MALLOC(sizeof(struct SMALL_DLG));
- h = WINDOW_TILE_HIGH + 3 + FRAME_WH;
+ h = WINDOW_TILE_HIGH + adj_size(3) + FRAME_WH;
/* window */
- pStr = create_str16_from_char(_("Bribe Enemy Unit"), 12);
+ pStr = create_str16_from_char(_("Bribe Enemy Unit"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
pWindow = create_window(get_locked_buffer(),
- pStr, 10, 10, WF_DRAW_THEME_TRANSPARENT);
+ pStr, adj_size(10), adj_size(10),
WF_DRAW_THEME_TRANSPARENT);
unlock_buffer();
pWindow->action = bribe_dlg_window_callback;
set_wstate(pWindow, FC_WS_NORMAL);
- w = MAX(w, pWindow->size.w + 8);
+ w = MAX(w, pWindow->size.w + adj_size(8));
add_to_gui_list(ID_BRIBE_DLG_WINDOW, pWindow);
pBribe_Dlg->pEndWidgetList = pWindow;
@@ -3255,7 +3255,7 @@
/* exit button */
pBuf = create_themeicon(pTheme->Small_CANCEL_Icon, pWindow->dst,
WF_DRAW_THEME_TRANSPARENT);
- w += pBuf->size.w + 10;
+ w += pBuf->size.w + adj_size(10);
pBuf->action = exit_bribe_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
@@ -3294,7 +3294,7 @@
auto_center_on_focus_unit();
put_window_near_map_tile(pWindow,
- w + DOUBLE_FRAME_WH, h, pDiplomatUnit->x, pDiplomatUnit->y);
+ w + DOUBLE_FRAME_WH, h, pDiplomatUnit->tile);
resize_window(pWindow, NULL, NULL, pWindow->size.w, h);
/* setup widget size and start position */
@@ -3310,7 +3310,7 @@
pBuf = pBuf->prev;
setup_vertical_widgets_position(1,
pWindow->size.x + FRAME_WH,
- pWindow->size.y + WINDOW_TILE_HIGH + 2, w, 0,
+ pWindow->size.y + WINDOW_TILE_HIGH + adj_size(2), w, 0,
pBribe_Dlg->pBeginWidgetList, pBuf);
/* --------------------- */
@@ -3372,11 +3372,11 @@
pillage.
**************************************************************************/
void popup_pillage_dialog(struct unit *pUnit,
- enum tile_special_type may_pillage)
+ bv_special may_pillage)
{
struct GUI *pWindow = NULL, *pBuf = NULL;
SDL_String16 *pStr;
- enum tile_special_type what;
+ enum tile_special_type what, prereq;
int w = 0, h;
if (pPillage_Dlg) {
@@ -3386,13 +3386,13 @@
is_unit_move_blocked = TRUE;
pPillage_Dlg = MALLOC(sizeof(struct SMALL_DLG));
- h = WINDOW_TILE_HIGH + 3 + FRAME_WH;
+ h = WINDOW_TILE_HIGH + adj_size(3) + FRAME_WH;
/* window */
- pStr = create_str16_from_char(_("What To Pillage") , 12);
+ pStr = create_str16_from_char(_("What To Pillage") , adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr , 10, 10, WF_DRAW_THEME_TRANSPARENT);
+ pWindow = create_window(NULL, pStr , adj_size(10), adj_size(10),
WF_DRAW_THEME_TRANSPARENT);
pWindow->action = pillage_window_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -3405,7 +3405,7 @@
/* exit button */
pBuf = create_themeicon(pTheme->Small_CANCEL_Icon, pWindow->dst,
WF_DRAW_THEME_TRANSPARENT);
- w += pBuf->size.w + 10;
+ w += pBuf->size.w + adj_size(10);
pBuf->action = exit_pillage_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
@@ -3413,8 +3413,12 @@
add_to_gui_list(ID_PILLAGE_DLG_EXIT_BUTTON, pBuf);
/* ---------- */
- while (may_pillage != S_NO_SPECIAL) {
- what = get_preferred_pillage(may_pillage);
+ while ((what = get_preferred_pillage(may_pillage)) != S_LAST) {
+
+ bv_special what_bv;
+
+ BV_CLR_ALL(what_bv);
+ BV_SET(what_bv, what);
create_active_iconlabel(pBuf, pWindow->dst, pStr,
(char *) get_special_name(what), pillage_callback);
@@ -3426,7 +3430,11 @@
w = MAX(w, pBuf->size.w);
h += pBuf->size.h;
- may_pillage &= (~(what | get_infrastructure_prereq(what)));
+ clear_special(&may_pillage, what);
+ prereq = get_infrastructure_prereq(what);
+ if (prereq != S_LAST) {
+ clear_special(&may_pillage, prereq);
+ }
}
pPillage_Dlg->pBeginWidgetList = pBuf;
@@ -3436,7 +3444,7 @@
pWindow->size.h = h;
put_window_near_map_tile(pWindow,
- w + DOUBLE_FRAME_WH, h, pUnit->x, pUnit->y);
+ w + DOUBLE_FRAME_WH, h, pUnit->tile);
resize_window(pWindow, NULL, NULL, pWindow->size.w, h);
/* setup widget size and start position */
@@ -3450,7 +3458,7 @@
pBuf = pBuf->prev;
setup_vertical_widgets_position(1,
pWindow->size.x + FRAME_WH,
- pWindow->size.y + WINDOW_TILE_HIGH + 2, w, 0,
+ pWindow->size.y + WINDOW_TILE_HIGH + adj_size(2), w, 0,
pPillage_Dlg->pBeginWidgetList, pBuf);
/* --------------------- */
@@ -3554,18 +3562,18 @@
/* create ok button */
pOK_Button =
create_themeicon_button_from_chars(pTheme->Small_OK_Icon,
- Main.gui, _("Revolution!"), 10, 0);
+ Main.gui, _("Revolution!"), adj_font(10), 0);
/* create cancel button */
pCancel_Button =
create_themeicon_button_from_chars(pTheme->Small_CANCEL_Icon,
- Main.gui, _("Cancel"), 10, 0);
+ Main.gui, _("Cancel"), adj_font(10), 0);
/* correct sizes */
pCancel_Button->size.w += 6;
/* create text label */
- pStr = create_str16_from_char(_("You say you wanna revolution?"), 10);
+ pStr = create_str16_from_char(_("You say you wanna revolution?"),
adj_font(10));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pStr->fgcol.r = 255;
pStr->fgcol.g = 255;
@@ -3573,17 +3581,17 @@
pLabel = create_iconlabel(NULL, Main.gui, pStr, 0);
/* create window */
- pStr = create_str16_from_char(_("REVOLUTION!"), 12);
+ pStr = create_str16_from_char(_("REVOLUTION!"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- if ((pOK_Button->size.w + pCancel_Button->size.w + 30) >
- pLabel->size.w + 20) {
- ww = pOK_Button->size.w + pCancel_Button->size.w + 30;
+ if ((pOK_Button->size.w + pCancel_Button->size.w + adj_size(30)) >
+ pLabel->size.w + adj_size(20)) {
+ ww = pOK_Button->size.w + pCancel_Button->size.w + adj_size(30);
} else {
- ww = pLabel->size.w + 20;
+ ww = pLabel->size.w + adj_size(20);
}
pWindow = create_window(Main.gui, pStr, ww,
- pOK_Button->size.h + pLabel->size.h + WINDOW_TILE_HIGH + 25, 0);
+ pOK_Button->size.h + pLabel->size.h + WINDOW_TILE_HIGH + adj_size(25),
0);
/* set actions */
pWindow->action = move_revolution_dlg_callback;
@@ -3600,15 +3608,15 @@
pWindow->size.x = (Main.screen->w - pWindow->size.w) / 2;
pWindow->size.y = (Main.screen->h - pWindow->size.h) / 2;
- pOK_Button->size.x = pWindow->size.x + 10;
+ pOK_Button->size.x = pWindow->size.x + adj_size(10);
pOK_Button->size.y = pWindow->size.y + pWindow->size.h -
- pOK_Button->size.h - 10;
+ pOK_Button->size.h - adj_size(10);
pCancel_Button->size.y = pOK_Button->size.y;
pCancel_Button->size.x = pWindow->size.x + pWindow->size.w -
- pCancel_Button->size.w - 10;
+ pCancel_Button->size.w - adj_size(10);
pLabel->size.x = pWindow->size.x;
- pLabel->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 5;
+ pLabel->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(5);
/* create window background */
pLogo = get_logo_gfx();
@@ -3656,8 +3664,8 @@
static int nations_dialog_callback(struct GUI *pWindow);
static int nation_button_callback(struct GUI *pNation);
-static int start_callback(struct GUI *pStart_Button);
-static int disconnect_callback(struct GUI *pButton);
+static int races_dialog_ok_callback(struct GUI *pStart_Button);
+static int races_dialog_cancel_callback(struct GUI *pButton);
static int next_name_callback(struct GUI *pNext_Button);
static int prev_name_callback(struct GUI *pPrev_Button);
static int change_sex_callback(struct GUI *pSex);
@@ -3678,7 +3686,7 @@
/**************************************************************************
...
**************************************************************************/
-static int start_callback(struct GUI *pStart_Button)
+static int races_dialog_ok_callback(struct GUI *pStart_Button)
{
struct NAT *pSetup = (struct NAT *)(pNationDlg->pEndWidgetList->data.ptr);
char *pStr = convert_to_chars(pSetup->pName_Edit->string16->text);
@@ -3693,11 +3701,14 @@
return (-1);
}
- dsend_packet_nation_select_req(&aconnection, pSetup->nation,
+ dsend_packet_nation_select_req(&aconnection, races_player->player_no,
pSetup->nation,
pSetup->leader_sex, pStr,
pSetup->nation_city_style);
FREE(pStr);
+ popdown_races_dialog();
+ flush_dirty();
+
return -1;
}
@@ -3732,7 +3743,7 @@
{
int dim;
struct NAT *pSetup = (struct NAT *)(pNationDlg->pEndWidgetList->data.ptr);
- struct leader *leaders = get_nation_leaders(pSetup->nation, &dim);
+ struct leader *leaders =
get_nation_leaders(get_nation_by_idx(pSetup->nation), &dim);
pSetup->selected_leader++;
@@ -3780,7 +3791,7 @@
{
int dim;
struct NAT *pSetup = (struct NAT *)(pNationDlg->pEndWidgetList->data.ptr);
- struct leader *leaders = get_nation_leaders(pSetup->nation, &dim);
+ struct leader *leaders =
get_nation_leaders(get_nation_by_idx(pSetup->nation), &dim);
pSetup->selected_leader--;
@@ -3824,10 +3835,10 @@
/**************************************************************************
...
**************************************************************************/
-static int disconnect_callback(struct GUI *pButton)
+static int races_dialog_cancel_callback(struct GUI *pButton)
{
popdown_races_dialog();
- disconnect_from_server();
+ flush_dirty();
return -1;
}
@@ -3901,7 +3912,7 @@
change_nation_label();
enable(MAX_ID - 1000 - pSetup->nation_city_style);
- pSetup->nation_city_style = get_nation_city_style(pSetup->nation);
+ pSetup->nation_city_style =
get_nation_city_style(get_nation_by_idx(pSetup->nation));
disable(MAX_ID - 1000 - pSetup->nation_city_style);
select_random_leader(pSetup->nation);
@@ -3924,10 +3935,10 @@
pHelpDlg = MALLOC(sizeof(struct SMALL_DLG));
- pStr = create_str16_from_char("Nation's Legend", 12);
+ pStr = create_str16_from_char("Nation's Legend", adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 10, 10, 0);
+ pWindow = create_window(NULL, pStr, adj_size(10), adj_size(10), 0);
pWindow->action = help_dlg_callback;
w = pWindow->size.w;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -3936,7 +3947,7 @@
add_to_gui_list(ID_WINDOW, pWindow);
pCancel = create_themeicon_button_from_chars(pTheme->CANCEL_Icon,
- pWindow->dst, _("Cancel"), 14, 0);
+ pWindow->dst, _("Cancel"), adj_font(14), 0);
pCancel->action = cancel_help_dlg_callback;
set_wstate(pCancel, FC_WS_NORMAL);
pCancel->key = SDLK_ESCAPE;
@@ -3952,25 +3963,25 @@
}
if (pNation->legend && *(pNation->legend) != '\0') {
- pStr = create_str16_from_char(pNation->legend, 12);
+ pStr = create_str16_from_char(pNation->legend, adj_font(12));
} else {
- pStr = create_str16_from_char("SORRY... NO INFO", 12);
+ pStr = create_str16_from_char("SORRY... NO INFO", adj_font(12));
}
- pStr->fgcol = *get_game_colorRGB(COLOR_STD_WHITE);
- pText = create_text_surf_smaller_that_w(pStr, Main.screen->w - 20);
+ pStr->fgcol = (SDL_Color){255, 255, 255, 255};
+ pText = create_text_surf_smaller_that_w(pStr, Main.screen->w -
adj_size(20));
- copy_chars_to_string16(pStr, pNation->name_plural);
+ copy_chars_to_string16(pStr, Q_(pNation->name_plural));
pText2 = create_text_surf_from_str16(pStr);
FREESTRING16(pStr);
/* create window background */
- w = MAX(w, pText2->w + 20);
- w = MAX(w, pText->w + 20);
- w = MAX(w, pCancel->size.w + 20);
- h = WINDOW_TILE_HIGH + 10 + pText2->h + 10 + pText->h + 10 +
- pCancel->size.h + 10 + FRAME_WH;
+ w = MAX(w, pText2->w + adj_size(20));
+ w = MAX(w, pText->w + adj_size(20));
+ w = MAX(w, pCancel->size.w + adj_size(20));
+ h = WINDOW_TILE_HIGH + adj_size(10) + pText2->h + adj_size(10) + pText->h
+ + adj_size(10) + pCancel->size.h + adj_size(10) + FRAME_WH;
pWindow->size.x = (pWindow->dst->w - w) / 2;
pWindow->size.y = (pWindow->dst->h - h) / 2;
@@ -3978,10 +3989,10 @@
resize_window(pWindow, NULL,
get_game_colorRGB(COLOR_STD_BACKGROUND_BROWN), w, h);
- area.x = 10;
- area.y = WINDOW_TILE_HIGH + 10;
+ area.x = adj_size(10);
+ area.y = WINDOW_TILE_HIGH + adj_size(10);
SDL_BlitSurface(pText2, NULL, pWindow->theme, &area);
- area.y += (pText2->h + 10);
+ area.y += (pText2->h + adj_size(10));
FREESURFACE(pText2);
SDL_BlitSurface(pText, NULL, pWindow->theme, &area);
@@ -3989,7 +4000,7 @@
pCancel->size.x = pWindow->size.x + (pWindow->size.w - pCancel->size.w) /
2;
pCancel->size.y = pWindow->size.y +
- pWindow->size.h - pCancel->size.h - 10 - FRAME_WH;
+ pWindow->size.h - pCancel->size.h - adj_size(10) - FRAME_WH;
/* redraw */
redraw_group(pCancel, pWindow, 0);
@@ -4016,8 +4027,9 @@
struct GUI *pLabel = pSetup->pName_Edit->next;
struct nation_type *pNation = get_nation_by_idx(pSetup->nation);
- pTmp_Surf = make_flag_surface_smaler(GET_SURF(pNation->flag_sprite));
- pTmp_Surf_zoomed = ZoomSurface(pTmp_Surf, 5.0, 5.0, 1);
+ pTmp_Surf = make_flag_surface_smaler(GET_SURF(get_nation_flag_sprite(tileset,
+ get_nation_by_idx(pSetup->nation))));
+ pTmp_Surf_zoomed = ZoomSurface(pTmp_Surf, 1.0, 1.0, 1);
SDL_SetColorKey(pTmp_Surf_zoomed, SDL_SRCCOLORKEY|SDL_RLEACCEL,
getpixel(pTmp_Surf_zoomed, pTmp_Surf_zoomed->w - 1,
pTmp_Surf_zoomed->h - 1));
@@ -4025,7 +4037,7 @@
FREESURFACE(pLabel->theme);
pLabel->theme = pTmp_Surf_zoomed;
- copy_chars_to_string16(pLabel->string16, pNation->name_plural);
+ copy_chars_to_string16(pLabel->string16, Q_(pNation->name_plural));
remake_label_size(pLabel);
@@ -4042,7 +4054,7 @@
{
int dim;
struct NAT *pSetup = (struct NAT *)(pNationDlg->pEndWidgetList->data.ptr);
- struct leader *leaders = get_nation_leaders(nation, &dim);
+ struct leader *leaders = get_nation_leaders(get_nation_by_idx(nation), &dim);
pSetup->selected_leader = myrand(dim);
@@ -4070,32 +4082,47 @@
}
+static int get_playable_nation_count() {
+
+ int playable_nation_count = 0;
+
+ nations_iterate(pnation) {
+ if (pnation->is_playable && !pnation->player && pnation->is_available)
+ ++playable_nation_count;
+ } nations_iterate_end;
+
+ return playable_nation_count;
+
+}
+
/**************************************************************************
Popup the nation selection dialog.
**************************************************************************/
-void popup_races_dialog(void)
+void popup_races_dialog(struct player *pplayer)
{
struct GUI *pWindow, *pWidget = NULL, *pBuf, *pLast_City_Style;
SDL_String16 *pStr;
- int i, len = 0;
- int w = 10, h = 10;
+ int len = 0;
+ int w = adj_size(10), h = adj_size(10);
SDL_Surface *pTmp_Surf, *pTmp_Surf_zoomed = NULL;
SDL_Surface *pMain_Bg, *pText_Name, *pText_Class;
SDL_Color color = {255,255,255,128};
SDL_Rect dst;
struct NAT *pSetup;
- #define TARGETS_ROW 4
- #define TARGETS_COL 3
+ #define TARGETS_ROW 5
+ #define TARGETS_COL 1
if (pNationDlg) {
return;
}
+ races_player = pplayer;
+
pNationDlg = MALLOC(sizeof(struct ADVANCED_DLG));
/* create window widget */
- pStr = create_str16_from_char(_("What nation will you be?"), 12);
+ pStr = create_str16_from_char(_("What nation will you be?"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
pWindow = create_window(NULL, pStr, w, h, WF_FREE_DATA);
@@ -4110,53 +4137,47 @@
/* create nations list */
/* Create Imprv Background Icon */
- pTmp_Surf = create_surf(96, 96, SDL_SWSURFACE);
+ pTmp_Surf = create_surf(adj_size(96*2), adj_size(64), SDL_SWSURFACE);
pMain_Bg = SDL_DisplayFormatAlpha(pTmp_Surf);
SDL_FillRect(pMain_Bg, NULL, SDL_MapRGBA(pMain_Bg->format, color.r,
color.g, color.b, color.unused));
putframe(pMain_Bg, 0, 0, pMain_Bg->w - 1, pMain_Bg->h - 1, 0xFF000000);
FREESURFACE(pTmp_Surf);
- pStr = create_string16(NULL, 0, 12);
+ pStr = create_string16(NULL, 0, adj_font(12));
pStr->style |= (SF_CENTER|TTF_STYLE_BOLD);
pStr->render = 3;
pStr->bgcol = color;
/* fill list */
pText_Class = NULL;
- for (i = 0; i < game.control.playable_nation_count; i++) {
- struct nation_type *pNation = get_nation_by_idx(i);
+ nations_iterate(pNation) {
- pTmp_Surf = make_flag_surface_smaler(GET_SURF(pNation->flag_sprite));
- pTmp_Surf_zoomed = ZoomSurface(pTmp_Surf, 3.0, 3.0, 1);
- SDL_SetColorKey(pTmp_Surf_zoomed, SDL_SRCCOLORKEY,
- getpixel(pTmp_Surf_zoomed, pTmp_Surf_zoomed->w - 1,
- pTmp_Surf_zoomed->h - 1));
- SDL_SetAlpha(pTmp_Surf_zoomed, 0x0, 0x0);
- FREESURFACE(pTmp_Surf);
+ pTmp_Surf_zoomed = adj_surf(GET_SURF(get_nation_flag_sprite(tileset,
pNation)));
pTmp_Surf = crop_rect_from_surface(pMain_Bg, NULL);
- copy_chars_to_string16(pStr, pNation->name_plural);
- change_ptsize16(pStr, 12);
- pText_Name = create_text_surf_smaller_that_w(pStr, pTmp_Surf->w - 4);
+ copy_chars_to_string16(pStr, Q_(pNation->name_plural));
+ change_ptsize16(pStr, adj_font(12));
+ pText_Name = create_text_surf_smaller_that_w(pStr, pTmp_Surf->w -
adj_size(4));
SDL_SetAlpha(pText_Name, 0x0, 0x0);
- if (pNation->category && *(pNation->category) != '\0') {
- copy_chars_to_string16(pStr, pNation->category);
- change_ptsize16(pStr, 10);
- pText_Class = create_text_surf_smaller_that_w(pStr, pTmp_Surf->w - 4);
+#if 0
+ if (pNation->legend && *(pNation->legend) != '\0') {
+ copy_chars_to_string16(pStr, pNation->legend);
+ change_ptsize16(pStr, adj_font(10));
+ pText_Class = create_text_surf_smaller_that_w(pStr, pTmp_Surf->w -
adj_size(4));
SDL_SetAlpha(pText_Class, 0x0, 0x0);
}
+#endif
dst.x = (pTmp_Surf->w - pTmp_Surf_zoomed->w) / 2;
len = pTmp_Surf_zoomed->h +
- 10 + pText_Name->h + (pText_Class ? pText_Class->h : 0);
+ adj_size(10) + pText_Name->h + (pText_Class ? pText_Class->h : 0);
dst.y = (pTmp_Surf->h - len) / 2;
SDL_BlitSurface(pTmp_Surf_zoomed, NULL, pTmp_Surf, &dst);
- dst.y += (pTmp_Surf_zoomed->h + 10);
- FREESURFACE(pTmp_Surf_zoomed);
+ dst.y += (pTmp_Surf_zoomed->h + adj_size(10));
dst.x = (pTmp_Surf->w - pText_Name->w) / 2;
SDL_BlitSurface(pText_Name, NULL, pTmp_Surf, &dst);
@@ -4179,13 +4200,13 @@
w = MAX(w, pWidget->size.w);
h = MAX(h, pWidget->size.h);
- add_to_gui_list(MAX_ID - i, pWidget);
+ add_to_gui_list(MAX_ID - pNation->index, pWidget);
- if(i > (TARGETS_ROW * TARGETS_COL - 1)) {
+ if (pNation->index > (TARGETS_ROW * TARGETS_COL - 1)) {
set_wflag(pWidget, WF_HIDDEN);
}
- }
+ } nations_iterate_end;
FREESURFACE(pMain_Bg);
@@ -4193,7 +4214,7 @@
pNationDlg->pBeginActiveWidgetList = pWidget;
pNationDlg->pBeginWidgetList = pWidget;
- if(game.control.playable_nation_count > TARGETS_ROW * TARGETS_COL) {
+ if(get_playable_nation_count() > TARGETS_ROW * TARGETS_COL) {
pNationDlg->pActiveWidgetList = pNationDlg->pEndActiveWidgetList;
create_vertical_scrollbar(pNationDlg,
TARGETS_COL, TARGETS_ROW, TRUE, TRUE);
@@ -4203,20 +4224,15 @@
/* nation name */
- pSetup->nation = myrand(game.control.playable_nation_count);
- pSetup->nation_city_style = get_nation_city_style(pSetup->nation);
+ pSetup->nation = myrand(get_playable_nation_count());
+ pSetup->nation_city_style =
get_nation_city_style(get_nation_by_idx(pSetup->nation));
- copy_chars_to_string16(pStr, get_nation_by_idx(pSetup->nation)->name_plural);
- change_ptsize16(pStr, 36);
+ copy_chars_to_string16(pStr,
Q_(get_nation_by_idx(pSetup->nation)->name_plural));
+ change_ptsize16(pStr, adj_font(24));
pStr->render = 2;
pStr->fgcol = color;
- pTmp_Surf = make_flag_surface_smaler(
- GET_SURF(get_nation_by_idx(pSetup->nation)->flag_sprite));
- pTmp_Surf_zoomed = ZoomSurface(pTmp_Surf, 5.0, 5.0, 1);
- SDL_SetColorKey(pTmp_Surf_zoomed, SDL_SRCCOLORKEY|SDL_RLEACCEL,
- getpixel(pTmp_Surf_zoomed, pTmp_Surf_zoomed->w - 1,
- pTmp_Surf_zoomed->h - 1));
- FREESURFACE(pTmp_Surf);
+
+ pTmp_Surf_zoomed = adj_surf(GET_SURF(get_nation_flag_sprite(tileset,
get_nation_by_idx(pSetup->nation))));
pWidget = create_iconlabel(pTmp_Surf_zoomed, pWindow->dst, pStr,
(WF_ICON_ABOVE_TEXT|WF_ICON_CENTER|WF_FREE_GFX));
@@ -4225,8 +4241,8 @@
/* create leader name edit */
pWidget = create_edit_from_unichars(NULL, pWindow->dst,
- NULL, 0, 16, 200, 0);
- pWidget->size.h = 30;
+ NULL, 0, adj_font(16),
adj_size(200), 0);
+ pWidget->size.h = adj_size(24);
set_wstate(pWidget, FC_WS_NORMAL);
add_to_gui_list(ID_NATION_WIZARD_LEADER_NAME_EDIT, pWidget);
@@ -4252,10 +4268,10 @@
/* change sex button */
- pWidget = create_icon_button_from_chars(NULL, pWindow->dst, _("Male"), 14,
0);
+ pWidget = create_icon_button_from_chars(NULL, pWindow->dst, _("Male"),
adj_font(14), 0);
pWidget->action = change_sex_callback;
- pWidget->size.w = 100;
- pWidget->size.h = 22;
+ pWidget->size.w = adj_size(100);
+ pWidget->size.h = adj_size(22);
set_wstate(pWidget, FC_WS_NORMAL);
pSetup->pChange_Sex = pWidget;
@@ -4263,10 +4279,10 @@
add_to_gui_list(ID_NATION_WIZARD_CHANGE_SEX_BUTTON, pWidget);
/* ---------------------------------------------------------- */
- i = 0;
+ int i = 0;
while (i < game.control.styles_count) {
- if (city_styles[i].techreq == A_NONE) {
- pWidget = create_icon2(GET_SURF(sprites.city.tile[i][2]),
+ if (!city_style_has_requirements(&city_styles[i])) {
+ pWidget = create_icon2(adj_surf(GET_SURF(get_sample_city_sprite(tileset,
i))),
pWindow->dst, WF_DRAW_THEME_TRANSPARENT);
pWidget->action = city_style_callback;
@@ -4281,17 +4297,17 @@
i++;
}
- len += 3;
+ len += adj_size(3);
for (; (i < game.control.styles_count && i < 64); i++) {
- if (city_styles[i].techreq == A_NONE) {
- pWidget = create_icon2(GET_SURF(sprites.city.tile[i][2]),
+ if (!city_style_has_requirements(&city_styles[i])) {
+ pWidget = create_icon2(adj_surf(GET_SURF(get_sample_city_sprite(tileset,
i))),
pWindow->dst, WF_DRAW_THEME_TRANSPARENT);
pWidget->action = city_style_callback;
if (i != pSetup->nation_city_style) {
set_wstate(pWidget, FC_WS_NORMAL);
}
- len += (pWidget->size.w + 3);
+ len += (pWidget->size.w + adj_size(3));
add_to_gui_list(MAX_ID - 1000 - i, pWidget);
}
}
@@ -4300,8 +4316,8 @@
/* create disconnection button */
pWidget = create_themeicon_button_from_chars(pTheme->BACK_Icon, pWindow->dst,
- _("Disconnect"), 12, 0);
- pWidget->action = disconnect_callback;
+ _("Cancel"), adj_font(12), 0);
+ pWidget->action = races_dialog_cancel_callback;
set_wstate(pWidget, FC_WS_NORMAL);
add_to_gui_list(ID_NATION_WIZARD_DISCONNECT_BUTTON, pWidget);
@@ -4309,10 +4325,10 @@
/* create start button */
pWidget =
create_themeicon_button_from_chars(pTheme->FORWARD_Icon, pWindow->dst,
- _("Start"), 12, WF_ICON_CENTER_RIGHT);
- pWidget->action = start_callback;
+ _("OK"), adj_font(12), WF_ICON_CENTER_RIGHT);
+ pWidget->action = races_dialog_ok_callback;
- pWidget->size.w += 60;
+ pWidget->size.w += adj_size(60);
set_wstate(pWidget, FC_WS_NORMAL);
add_to_gui_list(ID_NATION_WIZARD_START_BUTTON, pWidget);
pWidget->size.w = MAX(pWidget->size.w, pWidget->next->size.w);
@@ -4322,11 +4338,11 @@
/* ---------------------------------------------------------- */
- pWindow->size.x = (Main.screen->w - 640) / 2;
- pWindow->size.y = (Main.screen->h - 480) / 2;
+ pWindow->size.x = (Main.screen->w - adj_size(640)) / 2;
+ pWindow->size.y = (Main.screen->h - adj_size(480)) / 2;
pMain_Bg = get_logo_gfx();
- if(resize_window(pWindow, pMain_Bg, NULL, 640, 480)) {
+ if(resize_window(pWindow, pMain_Bg, NULL, adj_size(640), adj_size(480))) {
FREESURFACE(pMain_Bg);
}
@@ -4335,7 +4351,7 @@
h = pNationDlg->pEndActiveWidgetList->size.h * TARGETS_ROW;
i = (pWindow->size.h - WINDOW_TILE_HIGH - h) / 2;
setup_vertical_widgets_position(TARGETS_COL,
- pWindow->size.x + FRAME_WH + 10,
+ pWindow->size.x + FRAME_WH + adj_size(10),
pWindow->size.y + WINDOW_TILE_HIGH + i,
0, 0, pNationDlg->pBeginActiveWidgetList,
pNationDlg->pEndActiveWidgetList);
@@ -4345,12 +4361,12 @@
w = pNationDlg->pEndActiveWidgetList->size.w * TARGETS_COL;
setup_vertical_scrollbar_area(pNationDlg->pScroll,
- pWindow->size.x + FRAME_WH + w + 12,
+ pWindow->size.x + FRAME_WH + w + adj_size(12),
pWindow->size.y + WINDOW_TILE_HIGH + i, h, FALSE);
- area.x = FRAME_WH + w + 11;
+ area.x = FRAME_WH + w + adj_size(11);
area.y = WINDOW_TILE_HIGH + i;
- area.w = pNationDlg->pScroll->pUp_Left_Button->size.w + 2;
+ area.w = pNationDlg->pScroll->pUp_Left_Button->size.w + adj_size(2);
area.h = h;
SDL_FillRectAlpha(pWindow->theme, &area, &color);
putframe(pWindow->theme, area.x, area.y - 1,
@@ -4360,7 +4376,7 @@
/* Sellected Nation Name */
pBuf->size.x = pWindow->size.x + pWindow->size.w / 2 +
(pWindow->size.w/2 - pBuf->size.w) / 2;
- pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 50;
+ pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(50);
/* Leader Name Edit */
pBuf = pBuf->prev;
@@ -4382,19 +4398,19 @@
pBuf = pBuf->prev;
pBuf->size.x = pWindow->size.x + pWindow->size.w / 2 +
(pWindow->size.w/2 - pBuf->size.w) / 2;
- pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + 20;
+ pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + adj_size(20);
/* First City Style Button */
pBuf = pBuf->prev;
pBuf->size.x = pWindow->size.x + pWindow->size.w / 2 +
(pWindow->size.w/2 - len) / 2;
- pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + 20;
+ pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + adj_size(20);
/* Rest City Style Buttons */
if (pBuf != pLast_City_Style) {
do {
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 3;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(3);
pBuf->size.y = pBuf->next->size.y;
} while (pLast_City_Style != pBuf);
}
@@ -4403,12 +4419,12 @@
pBuf = pBuf->prev;
pBuf->size.x = pWindow->size.x + pWindow->size.w / 2 +
(pWindow->size.w/2 - pBuf->size.w) / 2;
- pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + 20;
+ pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + adj_size(20);
/* Start Button */
pBuf = pBuf->prev;
pBuf->size.x = pBuf->next->size.x;
- pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + 10;
+ pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + adj_size(10);
/* -------------------------------------------------------------------- */
@@ -4417,7 +4433,6 @@
redraw_group(pNationDlg->pBeginWidgetList, pWindow, 0);
flush_rect(pWindow->size);
-
}
/**************************************************************************
@@ -4440,30 +4455,35 @@
In the nation selection dialog, make already-taken nations unavailable.
This information is contained in the packet_nations_used packet.
**************************************************************************/
-void races_toggles_set_sensitive(bool *nations_used)
+void races_toggles_set_sensitive()
{
- struct NAT *pSetup = (struct NAT *)(pNationDlg->pEndWidgetList->data.ptr);
- Nation_type_id nation;
+ struct NAT *pSetup;
bool change = FALSE;
struct GUI *pNat;
- for (nation = 0; nation < game.control.playable_nation_count; nation++) {
- if (nations_used[nation]) {
- freelog(LOG_DEBUG," [%d]: %d = %s", nation, nations_used[nation],
+ if (!pNationDlg)
+ return;
+
+ pSetup = (struct NAT *)(pNationDlg->pEndWidgetList->data.ptr);
+
+ nations_iterate(nation) {
+
+ if (!nation->is_available || nation->player) {
+ freelog(LOG_DEBUG," [%d]: %d = %s", nation->index,
(!nation->is_available || nation->player),
get_nation_name(nation));
- pNat = get_widget_pointer_form_main_list(MAX_ID - nation);
+ pNat = get_widget_pointer_form_main_list(MAX_ID - nation->index);
set_wstate(pNat, FC_WS_DISABLED);
- if (nation == pSetup->nation) {
+ if (nation->index == pSetup->nation) {
change = TRUE;
}
}
- }
+ } nations_iterate_end;
if (change) {
do {
- pSetup->nation = myrand(game.control.playable_nation_count);
+ pSetup->nation = myrand(get_playable_nation_count());
pNat = get_widget_pointer_form_main_list(MAX_ID - pSetup->nation);
} while(get_wstate(pNat) == FC_WS_DISABLED);
if (get_wstate(pSetup->pName_Edit) == FC_WS_PRESSED) {
@@ -4472,7 +4492,7 @@
}
change_nation_label();
enable(MAX_ID - 1000 - pSetup->nation_city_style);
- pSetup->nation_city_style = get_nation_city_style(pSetup->nation);
+ pSetup->nation_city_style =
get_nation_city_style(get_nation_by_idx(pSetup->nation));
disable(MAX_ID - 1000 - pSetup->nation_city_style);
select_random_leader(pSetup->nation);
}
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/dialogs.h
devel/client/gui-sdl/dialogs.h
--- devel_distclean/client/gui-sdl/dialogs.h 2005-10-17 17:15:35.000000000
+0200
+++ devel/client/gui-sdl/dialogs.h 2005-11-15 06:52:44.000000000 +0100
@@ -28,11 +28,12 @@
struct GUI;
-void popup_advanced_terrain_dialog(int x , int y);
+void popup_advanced_terrain_dialog(struct tile *ptile);
const char *sdl_map_get_tile_info_text(struct tile *pTile);
const char *sdl_get_tile_defense_info_text(struct tile *pTile);
void put_window_near_map_tile(struct GUI *pWindow,
- int window_width, int window_height, int x, int y);
+ int window_width, int window_height, struct tile *ptile);
void popup_unit_upgrade_dlg(struct unit *pUnit, bool city);
+void popup_revolution_dialog(void);
#endif /* FC__DIALOGS_H */
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/diplodlg.c
devel/client/gui-sdl/diplodlg.c
--- devel_distclean/client/gui-sdl/diplodlg.c 2005-10-18 00:31:09.000000000
+0200
+++ devel/client/gui-sdl/diplodlg.c 2005-11-15 06:52:44.000000000 +0100
@@ -40,6 +40,8 @@
#include "gui_stuff.h"
#include "mapview.h"
#include "colors.h"
+#include "log.h"
+#include "dialogs_g.h"
#include "diplodlg.h"
@@ -170,11 +172,11 @@
}
}
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
(WF_FREE_DATA|WF_DRAW_TEXT_LABEL_WITH_SPACE|WF_DRAW_THEME_TRANSPARENT));
- if(giver != game.player_idx) {
+ if(giver != game.info.player_idx) {
pBuf->string16->style |= SF_CENTER_RIGHT;
}
@@ -186,13 +188,13 @@
pBuf->action = remove_clause_callback;
set_wstate(pBuf, FC_WS_NORMAL);
- pBuf->size.w = pWindow->size.w - 24 - (scroll ? 0 : len);
+ pBuf->size.w = pWindow->size.w - adj_size(24) - (scroll ? 0 : len);
redraw_all = add_widget_to_vertical_scroll_widget_list(pClauses_Dlg,
pBuf, pClauses_Dlg->pBeginWidgetList,
FALSE,
- pWindow->size.x + 12,
- pClauses_Dlg->pScroll->pUp_Left_Button->size.y + 2);
+ pWindow->size.x + adj_size(12),
+ pClauses_Dlg->pScroll->pUp_Left_Button->size.y + adj_size(2));
/* find if there was scrollbar shown */
if(scroll && pClauses_Dlg->pActiveWidgetList != NULL) {
@@ -468,11 +470,11 @@
pCont->id0 = pPlayer0->player_no;
pCont->id1 = pPlayer1->player_no;
- hh = WINDOW_TILE_HIGH + 2;
- pStr = create_str16_from_char(get_nation_name(pPlayer0->nation), 12);
+ hh = WINDOW_TILE_HIGH + adj_size(2);
+ pStr = create_str16_from_char(get_nation_name(pPlayer0->nation),
adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(pMainWindow->dst, pStr, 100, 100, WF_FREE_DATA);
+ pWindow = create_window(pMainWindow->dst, pStr, adj_size(100),
adj_size(100), WF_FREE_DATA);
pWindow->action = dipomatic_window_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -489,7 +491,7 @@
if (game.player_ptr == pPlayer0 && type != DS_ALLIANCE) {
pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,
- _("Pacts"), 12, WF_DRAW_THEME_TRANSPARENT);
+ _("Pacts"), adj_font(12), WF_DRAW_THEME_TRANSPARENT);
pBuf->string16->fgcol = color_t;
width = pBuf->size.w;
height = pBuf->size.h;
@@ -515,7 +517,7 @@
my_snprintf(cBuf, sizeof(cBuf), " %s", Q_("?diplomatic_state:Peace"));
pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,
- cBuf, 12, (WF_DRAW_THEME_TRANSPARENT|WF_DRAW_TEXT_LABEL_WITH_SPACE));
+ cBuf, adj_font(12),
(WF_DRAW_THEME_TRANSPARENT|WF_DRAW_TEXT_LABEL_WITH_SPACE));
pBuf->string16->fgcol = color;
width = MAX(width, pBuf->size.w);
height = MAX(height, pBuf->size.h);
@@ -530,7 +532,7 @@
my_snprintf(cBuf, sizeof(cBuf), " %s",
Q_("?diplomatic_state:Alliance"));
pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,
- cBuf, 12, (WF_DRAW_THEME_TRANSPARENT|WF_DRAW_TEXT_LABEL_WITH_SPACE));
+ cBuf, adj_font(12),
(WF_DRAW_THEME_TRANSPARENT|WF_DRAW_TEXT_LABEL_WITH_SPACE));
pBuf->string16->fgcol = color;
width = MAX(width, pBuf->size.w);
height = MAX(height, pBuf->size.h);
@@ -547,7 +549,7 @@
if (!gives_shared_vision(pPlayer0, pPlayer1)) {
pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,
- _("Give shared vision"), 12,
+ _("Give shared vision"), adj_font(12),
(WF_DRAW_THEME_TRANSPARENT|WF_DRAW_TEXT_LABEL_WITH_SPACE));
pBuf->string16->fgcol = color;
width = MAX(width, pBuf->size.w);
@@ -561,7 +563,7 @@
/* ---------------------------- */
/* you can't give maps if you give shared vision */
pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,
- _("Maps"), 12, WF_DRAW_THEME_TRANSPARENT);
+ _("Maps"), adj_font(12), WF_DRAW_THEME_TRANSPARENT);
pBuf->string16->fgcol = color_t;
width = MAX(width, pBuf->size.w);
height = MAX(height, pBuf->size.h);
@@ -572,7 +574,7 @@
my_snprintf(cBuf, sizeof(cBuf), " %s", _("World map"));
pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,
- cBuf, 12, (WF_DRAW_THEME_TRANSPARENT|WF_DRAW_TEXT_LABEL_WITH_SPACE));
+ cBuf, adj_font(12),
(WF_DRAW_THEME_TRANSPARENT|WF_DRAW_TEXT_LABEL_WITH_SPACE));
pBuf->string16->fgcol = color;
width = MAX(width, pBuf->size.w);
height = MAX(height, pBuf->size.h);
@@ -586,7 +588,7 @@
my_snprintf(cBuf, sizeof(cBuf), " %s", _("Sea map"));
pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,
- cBuf, 12, (WF_DRAW_THEME_TRANSPARENT|WF_DRAW_TEXT_LABEL_WITH_SPACE));
+ cBuf, adj_font(12),
(WF_DRAW_THEME_TRANSPARENT|WF_DRAW_TEXT_LABEL_WITH_SPACE));
pBuf->string16->fgcol = color;
width = MAX(width, pBuf->size.w);
height = MAX(height, pBuf->size.h);
@@ -602,7 +604,7 @@
my_snprintf(cBuf, sizeof(cBuf), _("Gold(max %d)"),
pPlayer0->economic.gold);
pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,
- cBuf, 12, WF_DRAW_THEME_TRANSPARENT);
+ cBuf, adj_font(12), WF_DRAW_THEME_TRANSPARENT);
pBuf->string16->fgcol = color_t;
width = MAX(width, pBuf->size.w);
height = MAX(height, pBuf->size.h);
@@ -610,7 +612,7 @@
count++;
pBuf = create_edit(NULL, pWindow->dst,
- create_str16_from_char("0", 10), 0,
+ create_str16_from_char("0", adj_font(10)), 0,
(WF_DRAW_THEME_TRANSPARENT|WF_FREE_STRING));
pBuf->data.cont = pCont;
pBuf->action = gold_callback;
@@ -634,7 +636,7 @@
get_invention(pPlayer1, i) == TECH_REACHABLE)) {
pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,
- _("Advances"), 12, WF_DRAW_THEME_TRANSPARENT);
+ _("Advances"), adj_font(12), WF_DRAW_THEME_TRANSPARENT);
pBuf->string16->fgcol = color_t;
width = MAX(width, pBuf->size.w);
height = MAX(height, pBuf->size.h);
@@ -643,7 +645,7 @@
my_snprintf(cBuf, sizeof(cBuf), " %s", advances[i].name);
- pBuf = create_iconlabel_from_chars(NULL, pWindow->dst, cBuf, 12,
+ pBuf = create_iconlabel_from_chars(NULL, pWindow->dst, cBuf,
adj_font(12),
(WF_DRAW_THEME_TRANSPARENT|WF_DRAW_TEXT_LABEL_WITH_SPACE));
pBuf->string16->fgcol = color;
width = MAX(width, pBuf->size.w);
@@ -668,7 +670,7 @@
my_snprintf(cBuf, sizeof(cBuf), " %s", advances[i].name);
- pBuf = create_iconlabel_from_chars(NULL, pWindow->dst, cBuf, 12,
+ pBuf = create_iconlabel_from_chars(NULL, pWindow->dst, cBuf,
adj_font(12),
(WF_DRAW_THEME_TRANSPARENT|WF_DRAW_TEXT_LABEL_WITH_SPACE));
pBuf->string16->fgcol = color;
width = MAX(width, pBuf->size.w);
@@ -693,7 +695,7 @@
- Kris Bubendorfer
*****************************************************************/
{
- int i = 0, j = 0, n = city_list_size(&pPlayer0->cities);
+ int i = 0, j = 0, n = city_list_size(pPlayer0->cities);
struct city **city_list_ptrs;
if (n > 0) {
@@ -712,7 +714,7 @@
if(i > 0) {
pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,
- _("Cities"), 12, WF_DRAW_THEME_TRANSPARENT);
+ _("Cities"), adj_font(12), WF_DRAW_THEME_TRANSPARENT);
pBuf->string16->fgcol = color_t;
pBuf->string16->style &= ~SF_CENTER;
width = MAX(width, pBuf->size.w);
@@ -725,7 +727,7 @@
for (j = 0; j < i; j++) {
my_snprintf(cBuf, sizeof(cBuf), " %s", city_list_ptrs[j]->name);
- pBuf = create_iconlabel_from_chars(NULL, pWindow->dst, cBuf, 12,
+ pBuf = create_iconlabel_from_chars(NULL, pWindow->dst, cBuf,
adj_font(12),
(WF_DRAW_THEME_TRANSPARENT|WF_DRAW_TEXT_LABEL_WITH_SPACE));
pBuf->string16->fgcol = color;
width = MAX(width, pBuf->size.w);
@@ -748,7 +750,7 @@
pDlg->pEndActiveWidgetList = pWindow->prev;
pDlg->pScroll = NULL;
- hh = (Main.screen->h - 100 - WINDOW_TILE_HIGH - 4 - FRAME_WH);
+ hh = (Main.screen->h - adj_size(100) - WINDOW_TILE_HIGH - adj_size(4) -
FRAME_WH);
ww = hh < (count * height);
if(ww) {
@@ -767,13 +769,13 @@
} while(pBuf != pDlg->pBeginActiveWidgetList);
}
- ww = MAX(width + DOUBLE_FRAME_WH + 4 + scroll_w, 150);
- hh = Main.screen->h - 100;
+ ww = MAX(width + DOUBLE_FRAME_WH + adj_size(4) + scroll_w, adj_size(150));
+ hh = Main.screen->h - adj_size(100);
if(L_R) {
- pWindow->size.x = pMainWindow->size.x + pMainWindow->size.w + 20;
+ pWindow->size.x = pMainWindow->size.x + pMainWindow->size.w + adj_size(20);
} else {
- pWindow->size.x = pMainWindow->size.x - 20 - ww;
+ pWindow->size.x = pMainWindow->size.x - adj_size(20) - ww;
}
pWindow->size.y = (Main.screen->h - hh) / 2;
@@ -781,7 +783,7 @@
get_game_colorRGB(COLOR_STD_BACKGROUND_BROWN), ww, hh);
setup_vertical_widgets_position(1,
- pWindow->size.x + FRAME_WH + 2, pWindow->size.y + WINDOW_TILE_HIGH + 2,
+ pWindow->size.x + FRAME_WH + adj_size(2), pWindow->size.y +
WINDOW_TILE_HIGH + adj_size(2),
width, height, pDlg->pBeginActiveWidgetList,
pDlg->pEndActiveWidgetList);
if(pDlg->pScroll) {
@@ -801,7 +803,7 @@
void handle_diplomacy_init_meeting(int counterpart, int initiated_from)
{
if(!pClauses_Dlg) {
- struct player *pPlayer0 = &game.players[game.player_idx];
+ struct player *pPlayer0 = &game.players[game.info.player_idx];
struct player *pPlayer1 = &game.players[counterpart];
struct CONTAINER *pCont = MALLOC(sizeof(struct CONTAINER));
int hh, ww = 0;
@@ -823,11 +825,11 @@
my_snprintf(cBuf, sizeof(cBuf), _("Diplomacy meeting"));
- hh = WINDOW_TILE_HIGH + 2;
- pStr = create_str16_from_char(cBuf, 12);
+ hh = WINDOW_TILE_HIGH + adj_size(2);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 100, 100, 0);
+ pWindow = create_window(NULL, pStr, adj_size(100), adj_size(100), 0);
pWindow->action = dipomatic_window_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -838,7 +840,7 @@
/* ============================================================= */
- pStr = create_str16_from_char(get_nation_name(pPlayer0->nation), 12);
+ pStr = create_str16_from_char(get_nation_name(pPlayer0->nation),
adj_font(12));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pStr->fgcol = color;
@@ -855,7 +857,7 @@
add_to_gui_list(ID_ICON, pBuf);
- pStr = create_str16_from_char(get_nation_name(pPlayer1->nation), 12);
+ pStr = create_str16_from_char(get_nation_name(pPlayer1->nation),
adj_font(12));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pStr->fgcol = color;
@@ -874,7 +876,7 @@
pBuf = create_themeicon(pTheme->CANCEL_PACT_Icon, pWindow->dst,
(WF_WIDGET_HAS_INFO_LABEL|WF_FREE_STRING|WF_DRAW_THEME_TRANSPARENT));
- pBuf->string16 = create_str16_from_char(_("Cancel meeting"), 12);
+ pBuf->string16 = create_str16_from_char(_("Cancel meeting"), adj_font(12));
pBuf->action = cancel_meeting_callback;
pBuf->data.cont = pCont;
@@ -886,7 +888,7 @@
(WF_FREE_DATA|WF_WIDGET_HAS_INFO_LABEL|
WF_FREE_STRING|WF_DRAW_THEME_TRANSPARENT));
- pBuf->string16 = create_str16_from_char(_("Accept treaty"), 12);
+ pBuf->string16 = create_str16_from_char(_("Accept treaty"), adj_font(12));
pBuf->action = accept_treaty_callback;
pBuf->data.cont = pCont;
@@ -901,8 +903,8 @@
hide_scrollbar(pClauses_Dlg->pScroll);
/* ============================================================= */
- ww = 250;
- hh = 300;
+ ww = adj_size(250);
+ hh = adj_size(300);
pWindow->size.x = (Main.screen->w - ww) / 2;
pWindow->size.y = (Main.screen->h - hh) / 2;
@@ -911,26 +913,26 @@
get_game_colorRGB(COLOR_STD_BACKGROUND_BROWN), ww, hh);
pBuf = pWindow->prev;
- pBuf->size.x = pWindow->size.x + 20;
- pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 10;
+ pBuf->size.x = pWindow->size.x + adj_size(20);
+ pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(10);
- dst.y = WINDOW_TILE_HIGH + 10 + pBuf->size.h + 10;
- dst.x = 10;
- dst.w = pWindow->size.w - 20;
+ dst.y = WINDOW_TILE_HIGH + adj_size(10) + pBuf->size.h + adj_size(10);
+ dst.x = adj_size(10);
+ dst.w = pWindow->size.w - adj_size(20);
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + pWindow->size.w - pBuf->size.w - 20;
- pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 10;
+ pBuf->size.x = pWindow->size.x + pWindow->size.w - pBuf->size.w -
adj_size(20);
+ pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(10);
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + (pWindow->size.w - (2 * pBuf->size.w +
40)) / 2;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.w - 20;
+ pBuf->size.x = pWindow->size.x + (pWindow->size.w - (2 * pBuf->size.w +
adj_size(40))) / 2;
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.w -
adj_size(20);
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 40;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.w - 20;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(40);
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.w -
adj_size(20);
- dst.h = (pWindow->size.h - pBuf->size.w - 30) - dst.y;
+ dst.h = (pWindow->size.h - pBuf->size.w - adj_size(30)) - dst.y;
/* ============================================================= */
color.unused = 136;
@@ -1077,10 +1079,10 @@
my_snprintf(cBuf, sizeof(cBuf),
_("%s incident !"), get_nation_name(pPlayer->nation));
hh = WINDOW_TILE_HIGH + 2;
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 100, 100, 0);
+ pWindow = create_window(NULL, pStr, adj_size(100), adj_size(100), 0);
pWindow->action = sdip_window_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -1093,7 +1095,7 @@
/* label */
my_snprintf(cBuf, sizeof(cBuf), _("Shall we declare WAR on them?"));
- pStr = create_str16_from_char(cBuf, 14);
+ pStr = create_str16_from_char(cBuf, adj_font(14));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pStr->fgcol.r = 255;
pStr->fgcol.g = 255;
@@ -1102,11 +1104,11 @@
pText = create_text_surf_from_str16(pStr);
FREESTRING16(pStr);
ww = MAX(ww, pText->w);
- hh += pText->h + 10;
+ hh += pText->h + adj_size(10);
pBuf = create_themeicon_button_from_chars(pTheme->CANCEL_Icon,
- pWindow->dst, _("No"), 12, 0);
+ pWindow->dst, _("No"), adj_font(12), 0);
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
pBuf->action = cancel_sdip_dlg_callback;
@@ -1117,7 +1119,7 @@
add_to_gui_list(ID_BUTTON, pBuf);
pBuf = create_themeicon_button_from_chars(pTheme->OK_Icon, pWindow->dst,
- _("Yes"), 12, 0);
+ _("Yes"), adj_font(12), 0);
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
pBuf->action = cancel_pact_dlg_callback;
@@ -1127,17 +1129,17 @@
add_to_gui_list(ID_BUTTON, pBuf);
pBuf->size.w = MAX(pBuf->next->size.w, pBuf->size.w);
pBuf->next->size.w = pBuf->size.w;
- ww = MAX(ww , 2 * pBuf->size.w + 20);
+ ww = MAX(ww , 2 * pBuf->size.w + adj_size(20));
pSDip_Dlg->pBeginWidgetList = pBuf;
/* setup window size and start position */
- ww += 10;
+ ww += adj_size(10);
pBuf = pWindow->prev;
ww += DOUBLE_FRAME_WH;
- hh += FRAME_WH + 5;
+ hh += FRAME_WH + adj_size(5);
pWindow->size.x = (Main.screen->w - ww) / 2;
pWindow->size.y = (Main.screen->h - hh) / 2;
@@ -1148,9 +1150,9 @@
/* setup rest of widgets */
/* label */
dst.x = FRAME_WH + (pWindow->size.w - DOUBLE_FRAME_WH - pText->w) / 2;
- dst.y = WINDOW_TILE_HIGH + 5;
+ dst.y = WINDOW_TILE_HIGH + adj_size(5);
SDL_BlitSurface(pText, NULL, pWindow->theme, &dst);
- dst.y += pText->h + 5;
+ dst.y += pText->h + adj_size(5);
FREESURFACE(pText);
/* no */
@@ -1160,11 +1162,11 @@
/* yes */
pBuf = pBuf->prev;
pBuf->size.x = pWindow->size.x +
- (pWindow->size.w - DOUBLE_FRAME_WH - (2 * pBuf->size.w + 20)) / 2;
+ (pWindow->size.w - DOUBLE_FRAME_WH - (2 * pBuf->size.w +
adj_size(20))) / 2;
pBuf->size.y = pWindow->size.y + dst.y;
/* no */
- pBuf->next->size.x = pBuf->size.x + pBuf->size.w + 20;
+ pBuf->next->size.x = pBuf->size.x + pBuf->size.w + adj_size(20);
/* ================================================== */
/* redraw */
@@ -1205,11 +1207,11 @@
pSDip_Dlg = MALLOC(sizeof(struct SMALL_DLG));
my_snprintf(cBuf, sizeof(cBuf), _("Foreign Minister"));
- hh = WINDOW_TILE_HIGH + 2;
- pStr = create_str16_from_char(cBuf, 12);
+ hh = WINDOW_TILE_HIGH + adj_size(2);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 100, 100, 0);
+ pWindow = create_window(NULL, pStr, adj_size(100), adj_size(100), 0);
pWindow->action = sdip_window_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -1223,7 +1225,7 @@
my_snprintf(cBuf, sizeof(cBuf), _("Sir!, %s ambassador has arrived\n"
"What are your wishes?"), get_nation_name(pPlayer->nation));
- pStr = create_str16_from_char(cBuf, 14);
+ pStr = create_str16_from_char(cBuf, adj_font(14));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pStr->fgcol.r = 255;
pStr->fgcol.g = 255;
@@ -1232,7 +1234,7 @@
pText = create_text_surf_from_str16(pStr);
FREESTRING16(pStr);
ww = MAX(ww , pText->w);
- hh += pText->h + 15;
+ hh += pText->h + adj_size(15);
if(type != DS_WAR && can_client_issue_orders()) {
@@ -1244,7 +1246,7 @@
/* cancel treaty */
pBuf = create_themeicon_button_from_chars(pTheme->UNITS2_Icon,
- pWindow->dst, cBuf, 12, 0);
+ pWindow->dst, cBuf, adj_font(12), 0);
pBuf->action = cancel_pact_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
@@ -1262,7 +1264,7 @@
if(shared) {
/* shared vision */
pBuf = create_themeicon_button_from_chars(pTheme->UNITS2_Icon,
pWindow->dst,
- _("Withdraw vision"), 12, 0);
+ _("Withdraw vision"),
adj_font(12), 0);
pBuf->action = withdraw_vision_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
@@ -1279,7 +1281,7 @@
/* meet */
pBuf = create_themeicon_button_from_chars(pTheme->PLAYERS_Icon,
pWindow->dst,
- _("Call Diplomatic Meeting"), 12,
0);
+ _("Call Diplomatic Meeting"),
adj_font(12), 0);
pBuf->action = call_meeting_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
@@ -1293,7 +1295,7 @@
button_h = MAX(button_h , pBuf->size.h);
pBuf = create_themeicon_button_from_chars(pTheme->CANCEL_Icon,
- pWindow->dst, _("Send him back"), 12, 0);
+ pWindow->dst, _("Send him back"), adj_font(12), 0);
pBuf->action = cancel_sdip_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
@@ -1302,17 +1304,17 @@
button_w = MAX(button_w , pBuf->size.w);
button_h = MAX(button_h , pBuf->size.h);
- button_h += 4;
- ww = MAX(ww, button_w + 20);
+ button_h += adj_size(4);
+ ww = MAX(ww, button_w + adj_size(20));
if(type != DS_WAR) {
if(shared) {
- hh += 4 * (button_h + 10);
+ hh += 4 * (button_h + adj_size(10));
} else {
- hh += 3 * (button_h + 10);
+ hh += 3 * (button_h + adj_size(10));
}
} else {
- hh += 2 * (button_h + 10);
+ hh += 2 * (button_h + adj_size(10));
}
add_to_gui_list(ID_BUTTON, pBuf);
@@ -1321,12 +1323,12 @@
pSDip_Dlg->pBeginWidgetList = pBuf;
/* setup window size and start position */
- ww += 10;
+ ww += adj_size(10);
pBuf = pWindow->prev;
ww += DOUBLE_FRAME_WH;
- hh += FRAME_WH + 5;
+ hh += FRAME_WH + adj_size(5);
pWindow->size.x = (Main.screen->w - ww) / 2;
pWindow->size.y = (Main.screen->h - hh) / 2;
@@ -1337,9 +1339,9 @@
/* setup rest of widgets */
/* label */
dst.x = FRAME_WH + (pWindow->size.w - DOUBLE_FRAME_WH - pText->w) / 2;
- dst.y = WINDOW_TILE_HIGH + 5;
+ dst.y = WINDOW_TILE_HIGH + adj_size(5);
SDL_BlitSurface(pText, NULL, pWindow->theme, &dst);
- dst.y += pText->h + 15;
+ dst.y += pText->h + adj_size(15);
FREESURFACE(pText);
pBuf = pWindow;
@@ -1358,7 +1360,7 @@
pBuf = pBuf->prev;
pBuf->size.w = button_w;
pBuf->size.h = button_h;
- pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + 10;
+ pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + adj_size(10);
pBuf->size.x = pBuf->next->size.x;
}
@@ -1366,7 +1368,7 @@
pBuf = pBuf->prev;
pBuf->size.w = button_w;
pBuf->size.h = button_h;
- pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + 10;
+ pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + adj_size(10);
pBuf->size.x = pBuf->next->size.x;
} else {
@@ -1385,7 +1387,7 @@
pBuf = pBuf->prev;
pBuf->size.w = button_w;
pBuf->size.h = button_h;
- pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + 10;
+ pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + adj_size(10);
pBuf->size.x = pBuf->next->size.x;
/* ================================================== */
@@ -1396,3 +1398,22 @@
flush_dirty();
}
}
+
+/****************************************************************
+ Returns id of a diplomat currently handled in diplomat dialog
+*****************************************************************/
+int diplomat_handled_in_diplomat_dialog(void)
+{
+ /* PORTME */
+ freelog(LOG_NORMAL, "PORT ME: diplomat_handled_in diplomat_dialog()");
+ return -1;
+}
+
+/****************************************************************
+ Closes the diplomat dialog
+****************************************************************/
+void close_diplomat_dialog(void)
+{
+ /* PORTME */
+ freelog(LOG_NORMAL, "PORT ME: close_diplomat_dialog()");
+}
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/finddlg.c
devel/client/gui-sdl/finddlg.c
--- devel_distclean/client/gui-sdl/finddlg.c 2005-10-18 00:31:09.000000000
+0200
+++ devel/client/gui-sdl/finddlg.c 2005-11-15 06:52:44.000000000 +0100
@@ -64,7 +64,7 @@
popdown_find_dialog();
- center_tile_mapcanvas(orginal_x, orginal_y);
+ center_tile_mapcanvas(map_pos_to_tile(orginal_x, orginal_y));
flush_dirty();
return -1;
@@ -74,7 +74,7 @@
{
struct city *pCity = pWidget->data.city;
if(pCity) {
- center_tile_mapcanvas(pCity->x, pCity->y);
+ center_tile_mapcanvas(pCity->tile);
if(Main.event.button.button == SDL_BUTTON_RIGHT) {
popdown_find_dialog();
}
@@ -106,30 +106,32 @@
SDL_Surface *pLogo = NULL;
SDL_String16 *pStr;
char cBuf[128];
- int i, n = 0, w = 0, h, owner = 0xffff, units_h = 0, orginal_x, orginal_y;
+ int i, n = 0, w = 0, h, /*owner = 0xffff,*/ units_h = 0;
+ struct player *owner = NULL;
+ struct tile *original;
bool mouse = (Main.event.type == SDL_MOUSEBUTTONDOWN);
/* check that there are any cities to find */
h = 0;
i = 0;
while(!h && i<game.info.nplayers) {
- h = city_list_size(&game.players[i++].cities);
+ h = city_list_size(game.players[i++].cities);
}
if (pFind_City_Dlg && !h) {
return;
}
- h = WINDOW_TILE_HIGH + 3 + FRAME_WH;
+ h = WINDOW_TILE_HIGH + adj_size(3) + FRAME_WH;
- canvas_to_map_pos(&orginal_x, &orginal_y, Main.map->w/2, Main.map->h/2);
+ original = canvas_pos_to_tile(Main.map->w/2, Main.map->h/2);
pFind_City_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
- pStr = create_str16_from_char(_("Find City") , 12);
+ pStr = create_str16_from_char(_("Find City") , adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 10, 10, WF_DRAW_THEME_TRANSPARENT);
+ pWindow = create_window(NULL, pStr, adj_size(10), adj_size(10),
WF_DRAW_THEME_TRANSPARENT);
pWindow->action = find_city_window_dlg_callback;
set_wstate(pWindow , FC_WS_NORMAL);
@@ -141,13 +143,13 @@
/* exit button */
pBuf = create_themeicon(pTheme->Small_CANCEL_Icon, pWindow->dst,
(WF_DRAW_THEME_TRANSPARENT|WF_FREE_DATA));
- w += pBuf->size.w + 10;
+ w += pBuf->size.w + adj_size(10);
pBuf->action = exit_find_city_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
pBuf->data.cont = MALLOC(sizeof(struct CONTAINER));
- pBuf->data.cont->id0 = orginal_x;
- pBuf->data.cont->id1 = orginal_y;
+ pBuf->data.cont->id0 = original->x;
+ pBuf->data.cont->id1 = original->y;
add_to_gui_list(ID_TERRAIN_ADV_DLG_EXIT_BUTTON, pBuf);
/* ---------- */
@@ -157,12 +159,12 @@
my_snprintf(cBuf , sizeof(cBuf), "%s (%d)",pCity->name, pCity->size);
- pStr = create_str16_from_char(cBuf , 10);
+ pStr = create_str16_from_char(cBuf , adj_font(10));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
if(pCity->owner != owner) {
- pLogo = GET_SURF(get_nation_by_idx(
- get_player(pCity->owner)->nation)->flag_sprite);
+ pLogo = GET_SURF(get_nation_flag_sprite(tileset,
+ get_player(pCity->owner->player_no)->nation));
pLogo = make_flag_surface_smaler(pLogo);
}
@@ -176,7 +178,7 @@
pBuf->string16->style &= ~SF_CENTER;
pBuf->string16->fgcol =
- *(get_game_colorRGB(player_color(get_player(pCity->owner))));
+ *(get_player_color(tileset, city_owner(pCity))->color);
pBuf->string16->render = 3;
pBuf->string16->bgcol.unused = 128;
@@ -214,7 +216,7 @@
n = units_h;
w += n;
- units_h = 20 * pBuf->size.h + WINDOW_TILE_HIGH + 3 + FRAME_WH;
+ units_h = 20 * pBuf->size.h + WINDOW_TILE_HIGH + adj_size(3) + FRAME_WH;
} else {
units_h = h;
@@ -227,15 +229,15 @@
h = units_h;
if(!mouse) {
- pWindow->size.x = 10;
+ pWindow->size.x = adj_size(10);
pWindow->size.y = (pWindow->dst->h - h) / 2;
} else {
pWindow->size.x = ((Main.event.motion.x + w < pWindow->dst->w) ?
- (Main.event.motion.x + 10) : (pWindow->dst->w - w - 10));
+ (Main.event.motion.x + adj_size(10)) : (pWindow->dst->w -
w - adj_size(10)));
pWindow->size.y =
- ((Main.event.motion.y - (WINDOW_TILE_HIGH + 2) + h < pWindow->dst->h) ?
- (Main.event.motion.y - (WINDOW_TILE_HIGH + 2)) :
- (pWindow->dst->h - h - 10));
+ ((Main.event.motion.y - (WINDOW_TILE_HIGH + adj_size(2)) + h <
pWindow->dst->h) ?
+ (Main.event.motion.y - (WINDOW_TILE_HIGH + adj_size(2))) :
+ (pWindow->dst->h - h - adj_size(10)));
}
@@ -257,7 +259,7 @@
/* cities */
pBuf = pBuf->prev;
setup_vertical_widgets_position(1,
- pWindow->size.x + FRAME_WH, pWindow->size.y + WINDOW_TILE_HIGH + 2,
+ pWindow->size.x + FRAME_WH, pWindow->size.y + WINDOW_TILE_HIGH +
adj_size(2),
w, 0, pFind_City_Dlg->pBeginActiveWidgetList, pBuf);
if (pFind_City_Dlg->pScroll)
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/gotodlg.c
devel/client/gui-sdl/gotodlg.c
--- devel_distclean/client/gui-sdl/gotodlg.c 2005-10-18 16:09:59.000000000
+0200
+++ devel/client/gui-sdl/gotodlg.c 2005-11-15 06:52:44.000000000 +0100
@@ -44,6 +44,7 @@
#include "gui_zoom.h"
#include "gui_tilespec.h"
#include "mapview.h"
+#include "goto.h"
#include "gotodlg.h"
@@ -80,7 +81,7 @@
struct unit *pUnit = get_unit_in_focus();
if (pUnit) {
if(GOTO) {
- send_goto_tile(pUnit, pDestcity->x, pDestcity->y);
+ send_goto_tile(pUnit, pDestcity->tile);
} else {
request_unit_airlift(pUnit, pDestcity);
}
@@ -101,7 +102,8 @@
SDL_Surface *pLogo = NULL;
SDL_String16 *pStr;
char cBuf[128];
- int i, n = 0, owner = 0xffff;
+ int i, n = 0/*, owner = 0xffff*/;
+ struct player *owner = NULL;
if(pGotoDlg->pEndActiveWidgetList) {
pAdd_Dock = pGotoDlg->pEndActiveWidgetList->next;
@@ -123,7 +125,7 @@
city_list_iterate(game.players[i].cities, pCity) {
/* FIXME: should use unit_can_airlift_to(). */
- if (!GOTO && !pcity->airlift) {
+ if (!GOTO && !pCity->airlift) {
continue;
}
@@ -133,8 +135,8 @@
pStr->style |= TTF_STYLE_BOLD;
if(pCity->owner != owner) {
- pLogo = GET_SURF(get_nation_by_idx(
- get_player(pCity->owner)->nation)->flag_sprite);
+ pLogo = GET_SURF(get_nation_flag_sprite(tileset,
+ get_player(pCity->owner->player_no)->nation));
pLogo = make_flag_surface_smaler(pLogo);
}
@@ -147,7 +149,7 @@
}
pBuf->string16->fgcol =
- *(get_game_colorRGB(player_color(get_player(pCity->owner))));
+ *(get_player_color(tileset, city_owner(pCity))->color);
pBuf->string16->render = 3;
pBuf->string16->bgcol.unused = 128;
pBuf->action = goto_city_callback;
@@ -192,7 +194,7 @@
pGotoDlg->pEndWidgetList->size.x + FRAME_WH + 1,
pGotoDlg->pEndWidgetList->size.y + WINDOW_TILE_HIGH + 1,
pGotoDlg->pScroll->pUp_Left_Button->size.x -
- pGotoDlg->pEndWidgetList->size.x - FRAME_WH - 2,
+ pGotoDlg->pEndWidgetList->size.x - FRAME_WH -
adj_size(2),
0, pGotoDlg->pBeginActiveWidgetList, pGotoDlg->pEndActiveWidgetList);
} else {
@@ -224,10 +226,10 @@
pGotoDlg = MALLOC(sizeof(struct ADVANCED_DLG));
- pStr = create_str16_from_char(_("Select destination"), 12);
+ pStr = create_str16_from_char(_("Select destination"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 10, 10, WF_DRAW_THEME_TRANSPARENT);
+ pWindow = create_window(NULL, pStr, adj_size(10), adj_size(10),
WF_DRAW_THEME_TRANSPARENT);
pWindow->action = goto_dialog_window_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -243,21 +245,21 @@
pBuf->action = exit_goto_dialog_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
- w += (pBuf->size.w + 10);
+ w += (pBuf->size.w + adj_size(10));
add_to_gui_list(ID_BUTTON, pBuf);
col = 0;
/* --------------------------------------------- */
for(i = 0; i < game.info.nplayers; i++) {
- if(i != game.player_idx
+ if(i != game.info.player_idx
&& pplayer_get_diplstate(
game.player_ptr, &game.players[i])->type == DS_NO_CONTACT) {
continue;
}
pFlag = make_flag_surface_smaler(
- GET_SURF(get_nation_by_idx(game.players[i].nation)->flag_sprite));
+ GET_SURF(get_nation_flag_sprite(tileset, game.players[i].nation)));
if (pFlag->w > 15 || pFlag->h > 15) {
float zoom = (float)(MAX(pFlag->w, pFlag->h)) / 15;
@@ -277,7 +279,7 @@
set_new_checkbox_theme(pBuf, pEnabled, pDisabled);
pBuf->string16 = create_str16_from_char(
- get_nation_by_idx(game.players[i].nation)->name, 12);
+ game.players[i].nation->name, adj_font(12));
pBuf->string16->style &= ~SF_CENTER;
set_wstate(pBuf, FC_WS_NORMAL);
@@ -294,16 +296,16 @@
create_vertical_scrollbar(pGotoDlg, 1, 17, TRUE, TRUE);
hide_scrollbar(pGotoDlg->pScroll);
- w = MAX(w, 300);
- h = 300;
+ w = MAX(w, adj_size(300));
+ h = adj_size(300);
pWindow->size.x = (Main.screen->w - w) / 2;
pWindow->size.y = (Main.screen->h - h) / 2;
resize_window(pWindow, NULL, NULL, w, h);
- col = (col + 10) / 11;
- w = col * pBuf->size.w + (col - 1) * 5 + 10;
+ col = (col + adj_size(10)) / adj_size(11);
+ w = col * pBuf->size.w + (col - 1) * 5 + adj_size(10);
h = pWindow->size.h - WINDOW_TILE_HIGH - 1 - FRAME_WH;
pFlag = ResizeSurface(pTheme->Block, w, h, 1);
@@ -322,17 +324,17 @@
/* nations buttons */
pBuf = pBuf->prev;
i = 0;
- w = pWindow->size.x + block_x + 5;
- h = pWindow->size.y + WINDOW_TILE_HIGH + 6;
+ w = pWindow->size.x + block_x + adj_size(5);
+ h = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(6);
while(pBuf) {
pBuf->size.x = w;
pBuf->size.y = h;
if(!((i + 1) % col)) {
- h += pBuf->size.h + 5;
- w = pWindow->size.x + block_x + 5;
+ h += pBuf->size.h + adj_size(5);
+ w = pWindow->size.x + block_x + adj_size(5);
} else {
- w += pBuf->size.w + 5;
+ w += pBuf->size.w + adj_size(5);
}
if(pBuf == pGotoDlg->pBeginWidgetList) {
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/graphics.c
devel/client/gui-sdl/graphics.c
--- devel_distclean/client/gui-sdl/graphics.c 2005-10-17 16:03:33.000000000
+0200
+++ devel/client/gui-sdl/graphics.c 2005-11-15 06:52:44.000000000 +0100
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
@@ -57,6 +58,8 @@
#include "gui_zoom.h"
#include "gui_main.h"
#include "gui_string.h"
+#include "gui_dither.h"
+#include "gui_tilespec.h"
#ifdef HAVE_MMX1
#include "mmx.h"
@@ -64,14 +67,14 @@
/* ------------------------------ */
-#include "goto_cursor.xbm"
-#include "goto_cursor_mask.xbm"
-#include "drop_cursor.xbm"
-#include "drop_cursor_mask.xbm"
-#include "nuke_cursor.xbm"
-#include "nuke_cursor_mask.xbm"
-#include "patrol_cursor.xbm"
-#include "patrol_cursor_mask.xbm"
+#include "cursors/goto_cursor.xbm"
+#include "cursors/goto_cursor_mask.xbm"
+#include "cursors/drop_cursor.xbm"
+#include "cursors/drop_cursor_mask.xbm"
+#include "cursors/nuke_cursor.xbm"
+#include "cursors/nuke_cursor_mask.xbm"
+#include "cursors/patrol_cursor.xbm"
+#include "cursors/patrol_cursor_mask.xbm"
struct main Main;
@@ -426,7 +429,13 @@
{
*ptr++ = var;
},{
- *(Uint32 *)ptr = color;
+ #ifndef ARM_WINCE
+ *(Uint32 *)ptr = color; /* this statement causes an exception on */
+ ptr += 2; /* StrongARM-PDA so use alternative */
+ #else
+ *ptr++ = var;
+ *ptr++ = var;
+ #endif
ptr += 2;
}, lenght);
#else
@@ -614,7 +623,7 @@
x1 = y;
}
- lng = x1 - x0;
+ lng = (x1 - x0) + 1;
if (!lng) return;
@@ -806,7 +815,7 @@
}
if ((y1 >= 0) && (y1 < pDest->h)) { /* botton line */
- put_hline(pDest, y1, x0, x1 + 1, color);
+ put_hline(pDest, y1, x0, x1, color);
}
if ((x0 >= 0) && (x0 < pDest->w)) {
@@ -835,9 +844,6 @@
Main.rects_count = 0;
Main.guis_count = 0;
- Main.map_canvas.surf = Main.map;
- mapview.store = &Main.map_canvas;
-
if (SDL_WasInit(SDL_INIT_AUDIO)) {
error = (SDL_InitSubSystem(iFlags) < 0);
} else {
@@ -897,7 +903,7 @@
"640 x 480 16 bpp SW"));
Main.screen = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE);
- } else /* set video mode */
+ } else { /* set video mode */
if ((Main.screen = SDL_SetVideoMode(iWidth, iHeight,
iDepth, iFlags)) == NULL) {
freelog(LOG_ERROR, _("Unable to set this resolution: "
@@ -907,15 +913,8 @@
exit(-30);
}
-
freelog(LOG_DEBUG, _("Setting resolution to: %d x %d %d bpp"),
iWidth, iHeight, iDepth);
-
- mapview.width = iWidth;
- mapview.height = iHeight;
- if (tileset_tile_width(tileset) > 0) {
- mapview.tile_width = (iWidth - 1) / tileset_tile_width(tileset) + 1;
- mapview.tile_height = (iHeight - 1) / tileset_tile_height(tileset) + 1;
}
FREESURFACE(Main.map);
@@ -3474,23 +3473,6 @@
/**************************************************************************
...
**************************************************************************/
-SDL_Surface * get_city_gfx(void)
-{
- SDL_Surface *pCity_Surf;
- struct sprite *pSpr = load_sprite(tileset, "theme.city");
-
- pCity_Surf = (pSpr ? GET_SURF(pSpr) : NULL);
- assert(pCity_Surf != NULL);
-
- pSpr->psurface = NULL;
- unload_sprite(tileset, "theme.city");
-
- return pCity_Surf;
-}
-
-/**************************************************************************
- ...
-**************************************************************************/
void draw_intro_gfx(void)
{
SDL_Surface *pIntro = get_intro_gfx();
@@ -3605,6 +3587,9 @@
return result;
}
+/****************************************************************************
+ Find the dimensions of the sprite.
+****************************************************************************/
void get_sprite_dimensions(struct sprite *sprite, int *width, int *height)
{
*width = GET_SURF(sprite)->w;
@@ -3625,8 +3610,6 @@
struct sprite *mask,
int mask_offset_x, int mask_offset_y)
{
- /* FIXME: this needs to be able to crop from a mask - equivalent to the
- * code currently in gui_dither.c. */
SDL_Rect src_rect =
{ (Sint16) x, (Sint16) y, (Uint16) width, (Uint16) height };
SDL_Surface *pNew, *pTmp =
@@ -3646,6 +3629,19 @@
FREESURFACE(pTmp);
}
+ if (mask) {
+ SDL_Surface *pDest = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
+ pNew->format->BitsPerPixel, pNew->format->Rmask, pNew->format->Gmask,
+ pNew->format->Bmask, pNew->format->Amask);
+
+ SDL_FillRect(pDest, NULL, pNew->format->colorkey);
+ SDL_SetColorKey(pDest, SDL_SRCCOLORKEY, pNew->format->colorkey);
+
+ dither_surface(pNew, mask->psurface, pDest, x - mask_offset_x, y -
mask_offset_y);
+
+ return ctor_sprite(pDest);
+ }
+
return ctor_sprite(pNew);
}
@@ -3760,7 +3756,6 @@
void free_sprite(struct sprite *s)
{
FREESURFACE(GET_SURF(s));
- /*s->psurface=NULL;*/
free(s);
}
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/graphics.h
devel/client/gui-sdl/graphics.h
--- devel_distclean/client/gui-sdl/graphics.h 2005-10-17 16:03:33.000000000
+0200
+++ devel/client/gui-sdl/graphics.h 2005-11-15 06:52:44.000000000 +0100
@@ -26,6 +26,8 @@
#include "graphics_g.h"
+#include "gui_main.h"
+
#define RECT_LIMIT 80
/* #define HAVE_MMX1 */
@@ -170,6 +172,13 @@
#define GET_SURF(m_sprite) (m_sprite->psurface)
+/* shrink surface on 320x240 screen*/
+#ifdef SMALL_SCREEN
+#define adj_surf(surf) ZoomSurface(surf, 0.5, 0.5, 0)
+#else
+#define adj_surf(surf) surf
+#endif
+
struct canvas {
SDL_Surface *surf;
};
@@ -239,7 +248,6 @@
SDL_Surface *get_logo_gfx(void);
SDL_Surface *get_intro_gfx(void);
-SDL_Surface *get_city_gfx(void);
void draw_intro_gfx(void);
SDL_Surface *make_flag_surface_smaler(SDL_Surface *pSrc);
diff -u -r -b -B -X devel/diff_ignore
devel_distclean/client/gui-sdl/gui_dither.c devel/client/gui-sdl/gui_dither.c
--- devel_distclean/client/gui-sdl/gui_dither.c 2005-10-17 16:03:33.000000000
+0200
+++ devel/client/gui-sdl/gui_dither.c 2005-11-15 06:52:44.000000000 +0100
@@ -26,14 +26,132 @@
#include <stdlib.h>
#include <SDL/SDL.h>
+#include <SDL/SDL_endian.h>
#include "tilespec.h"
#include "graphics.h"
+#include "log.h"
#include "gui_dither.h"
/**************************************************************************
...
**************************************************************************/
+static void dither_surface8(SDL_Surface * pDither, SDL_Surface * pMask,
+ SDL_Surface * pDest,
+ int mask_offset_x, int mask_offset_y)
+{
+ int row, col;
+
+ Uint8 *pDither_Pixel = (Uint8 *)pDither->pixels;
+ Uint8 *pDest_Pixel = (Uint8 *)pDest->pixels;
+ Uint8 *pMask_Pixel = NULL;
+
+ for (row = 0; row < pDither->h; row++) {
+
+ pMask_Pixel = (Uint8 *)pMask->pixels
+ + pMask->w * (row + mask_offset_y)
+ + mask_offset_x;
+
+ for (col = 0; col < pDither->w; col++) {
+ if (*pMask_Pixel != pMask->format->colorkey) {
+ *pDest_Pixel = *pDither_Pixel;
+ }
+
+ pDither_Pixel++; pDest_Pixel++; pMask_Pixel++;
+ }
+ }
+}
+
+static void dither_surface16(SDL_Surface * pDither, SDL_Surface * pMask,
+ SDL_Surface * pDest,
+ int mask_offset_x, int mask_offset_y)
+{
+ int row, col;
+
+ Uint16 *pDither_Pixel = (Uint16 *)pDither->pixels;
+ Uint16 *pDest_Pixel = (Uint16 *)pDest->pixels;
+ Uint16 *pMask_Pixel = NULL;
+
+ for (row = 0; row < pDither->h; row++) {
+
+ pMask_Pixel = (Uint16 *)pMask->pixels
+ + pMask->w * (row + mask_offset_y)
+ + mask_offset_x;
+
+ for (col = 0; col < pDither->w; col++) {
+ if (*pMask_Pixel != pMask->format->colorkey) {
+ *pDest_Pixel = *pDither_Pixel;
+ }
+
+ pDither_Pixel++; pDest_Pixel++; pMask_Pixel++;
+ }
+ }
+}
+
+static void dither_surface24(SDL_Surface * pDither, SDL_Surface * pMask,
+ SDL_Surface * pDest,
+ int mask_offset_x, int mask_offset_y)
+{
+ /* IMPLEMENT ME */
+ SDL_BlitSurface(pDither, NULL, pDest, NULL);
+}
+
+static void dither_surface32(SDL_Surface * pDither, SDL_Surface * pMask,
+ SDL_Surface * pDest,
+ int mask_offset_x, int mask_offset_y)
+{
+ int row, col;
+
+ Uint32 *pDither_Pixel = (Uint32 *)pDither->pixels;
+ Uint32 *pDest_Pixel = (Uint32 *)pDest->pixels;
+ Uint32 *pMask_Pixel = NULL;
+
+ for (row = 0; row < pDither->h; row++) {
+
+ pMask_Pixel = (Uint32 *)pMask->pixels
+ + pMask->w * (row + mask_offset_y)
+ + mask_offset_x;
+
+ for (col = 0; col < pDither->w; col++) {
+ if (*pMask_Pixel != pMask->format->colorkey) {
+ *pDest_Pixel = *pDither_Pixel;
+ }
+
+ pDither_Pixel++; pDest_Pixel++; pMask_Pixel++;
+ }
+ }
+}
+
+void dither_surface(SDL_Surface * pDither, SDL_Surface * pMask,
+ SDL_Surface * pDest,
+ int mask_offset_x, int mask_offset_y)
+{
+ int Bpp = pDither->format->BytesPerPixel;
+
+ lock_surf(pDither);
+ lock_surf(pMask);
+ lock_surf(pDest);
+ if (Bpp > 1) {
+ if (Bpp > 2) {
+ if (Bpp > 3) {
+ dither_surface32(pDither, pMask, pDest, mask_offset_x, mask_offset_y);
+ } else {
+ dither_surface24(pDither, pMask, pDest, mask_offset_x, mask_offset_y);
+ }
+ } else {
+ dither_surface16(pDither, pMask, pDest, mask_offset_x, mask_offset_y);
+ }
+ } else {
+ dither_surface8(pDither, pMask, pDest, mask_offset_x, mask_offset_y);
+ }
+ unlock_surf(pDither);
+ unlock_surf(pMask);
+ unlock_surf(pDest);
+}
+
+/**************************************************************************
+ ...
+**************************************************************************/
static void dither_north8(SDL_Surface * pDither, SDL_Surface * pMask,
SDL_Surface * pDest)
{
diff -u -r -b -B -X devel/diff_ignore
devel_distclean/client/gui-sdl/gui_dither.h devel/client/gui-sdl/gui_dither.h
--- devel_distclean/client/gui-sdl/gui_dither.h 2005-10-15 23:27:27.000000000
+0200
+++ devel/client/gui-sdl/gui_dither.h 2005-11-15 06:52:44.000000000 +0100
@@ -22,6 +22,10 @@
#ifndef FC__GUI_DITHER_H
#define FC__GUI_DITHER_H
+void dither_surface(SDL_Surface * pDither, SDL_Surface * pMask,
+ SDL_Surface * pDest,
+ int mask_offset_x, int mask_offset_y);
+
void dither_north(SDL_Surface *pDither,
SDL_Surface *pMask, SDL_Surface *pDest);
void dither_south(SDL_Surface *pDither,
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/gui_id.h
devel/client/gui-sdl/gui_id.h
--- devel_distclean/client/gui-sdl/gui_id.h 2005-10-15 23:27:27.000000000
+0200
+++ devel/client/gui-sdl/gui_id.h 2005-11-15 06:52:44.000000000 +0100
@@ -130,6 +130,7 @@
ID_UNITS_WINDOW,
ID_TOGGLE_UNITS_WINDOW_BUTTON,
ID_MINI_MAP_WINDOW,
+ ID_TOGGLE_MINIMAP_MODE,
ID_TOGGLE_MAP_WINDOW_BUTTON,
ID_UNIT_ORDER_BUILD_CITY,
ID_UNIT_ORDER_BUILD_WONDER,
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/gui_main.c
devel/client/gui-sdl/gui_main.c
--- devel_distclean/client/gui-sdl/gui_main.c 2005-10-18 00:31:09.000000000
+0200
+++ devel/client/gui-sdl/gui_main.c 2005-11-15 06:52:44.000000000 +0100
@@ -36,12 +36,14 @@
#include <unistd.h>
#endif
-#ifdef WIN32_NATIVE
+#ifdef HAVE_WINSOCK
#include <winsock.h>
#endif
#include <SDL/SDL.h>
+#include "gui_main.h"
+
#include "fcintl.h"
#include "fciconv.h"
#include "log.h"
@@ -57,6 +59,7 @@
#include "gui_string.h"
#include "gui_stuff.h" /* gui */
#include "gui_id.h"
+#include "gui_zoom.h"
#include "chatline.h"
#include "civclient.h"
@@ -68,6 +71,7 @@
#include "dialogs.h"
#include "gotodlg.h"
#include "graphics.h"
+#include "fciconv.h"
#include "timing.h"
@@ -87,14 +91,12 @@
#include "repodlgs.h"
-#include "gui_main.h"
-
-/*#include "freeciv.ico"*/
-
#define UNITS_TIMER_INTERVAL 128 /* milliseconds */
#define MAP_SCROLL_TIMER_INTERVAL 384
const char *client_string = "gui-sdl";
+const char * const gui_character_encoding = "UTF-8";
+const bool gui_use_transliteration = FALSE;
Uint32 SDL_Client_Flags = 0;
Uint32 widget_info_counter = 0;
@@ -111,6 +113,8 @@
bool do_focus_animation = TRUE;
SDL_Cursor **pAnimCursor = NULL;
bool do_cursor_animation = TRUE;
+int city_names_font_size = 12;
+int city_productions_font_size = 12;
/* ================================ Private ============================ */
static SDL_Cursor **pStoreAnimCursor = NULL;
@@ -122,6 +126,17 @@
static SDL_Event *pAnim_User_Event = NULL;
static SDL_Event *pInfo_User_Event = NULL;
static SDL_Event *pMap_Scroll_User_Event = NULL;
+
+/* for panning feature */
+#ifdef SMALL_SCREEN
+static bool do_panning = FALSE;
+#else
+static bool do_panning = FALSE;
+#endif
+static bool is_panning = FALSE;
+static int last_x = 0;
+static int last_y = 0;
+
static void print_usage(const char *argv0);
static void parse_options(int argc, char **argv);
static void game_focused_unit_anim(void);
@@ -151,8 +166,8 @@
void set_city_names_font_sizes(int my_city_names_font_size,
int my_city_productions_font_size)
{
- freelog(LOG_ERROR, "Unimplemented set_city_names_font_sizes.");
- /* PORTME */
+ city_names_font_size = my_city_names_font_size;
+ city_productions_font_size = my_city_productions_font_size;
}
/**************************************************************************
@@ -218,9 +233,9 @@
struct unit *pUnit;
struct city *pCity;
if((pUnit = get_unit_in_focus()) != NULL &&
- (pCity = map_get_tile(pUnit->x, pUnit->y)->city) != NULL &&
+ (pCity = pUnit->tile->city) != NULL &&
city_owner(pCity) == game.player_ptr) {
- popup_city_dialog(pCity, FALSE);
+ popup_city_dialog(pCity);
} else {
disable_focus_animation();
key_end_turn();
@@ -249,7 +264,7 @@
popdown_meswin_dialog();
/* copy_chars_to_string16(pWidget->string16, _("Show Log
(F10)")); */
} else {
- popup_meswin_dialog();
+ popup_meswin_dialog(true);
/* copy_chars_to_string16(pWidget->string16, _("Hide Log
(F10)")); */
}
flush_dirty();
@@ -293,8 +308,32 @@
if ((pWidget = MainWidgetListScaner(pButtonEvent->x, pButtonEvent->y)) !=
NULL) {
return widget_pressed_action(pWidget);
} else {
+ if (do_panning && (get_client_state() == CLIENT_GAME_RUNNING_STATE)) {
+ if (pButtonEvent->button == SDL_BUTTON_LEFT) {
+ last_x = pButtonEvent->x;
+ last_y = pButtonEvent->y;
+ }
+ } else {
button_down_on_map(pButtonEvent);
}
+ }
+ return ID_ERROR;
+}
+
+static Uint16 main_mouse_button_up_handler(SDL_MouseButtonEvent *pButtonEvent,
void *pData)
+{
+ if (do_panning && (get_client_state() == CLIENT_GAME_RUNNING_STATE)) {
+ if (is_panning) {
+ is_panning = FALSE;
+ } else {
+ static struct GUI *pWidget;
+ if ((pWidget = MainWidgetListScaner(pButtonEvent->x, pButtonEvent->y))
!= NULL) {
+ return ID_ERROR;
+ } else {
+ button_down_on_map(pButtonEvent);
+ }
+ }
+ }
return ID_ERROR;
}
@@ -307,6 +346,58 @@
{
static struct GUI *pWidget;
+ if (do_panning && (get_client_state() == CLIENT_GAME_RUNNING_STATE)) {
+ int dir = 0;
+
+ if (pMotionEvent->state & SDL_BUTTON_LEFT) {
+
+ is_panning = true;
+
+ if (pMotionEvent->x > last_x + 17) {
+ last_x = pMotionEvent->x;
+ dir = 1;
+ } else if (pMotionEvent->x < last_x - 17) {
+ last_x = pMotionEvent->x;
+ dir = 2;
+ }
+
+ if (pMotionEvent->y > last_y + 17) {
+ last_y = pMotionEvent->y;
+ dir |= 4;
+ } else if (pMotionEvent->y < last_y - 17) {
+ last_y = pMotionEvent->y;
+ dir |= 8;
+ }
+
+ switch (dir) {
+ case 1:
+ scroll_mapview(DIR8_EAST);
+ break;
+ case (1 | 4):
+ scroll_mapview(DIR8_SOUTHEAST);
+ break;
+ case (4):
+ scroll_mapview(DIR8_SOUTH);
+ break;
+ case (4 | 2):
+ scroll_mapview(DIR8_SOUTHWEST);
+ break;
+ case (2):
+ scroll_mapview(DIR8_WEST);
+ break;
+ case (2 | 8):
+ scroll_mapview(DIR8_NORTHWEST);
+ break;
+ case (8):
+ scroll_mapview(DIR8_NORTH);
+ break;
+ case (8 | 1):
+ scroll_mapview(DIR8_NORTHEAST);
+ break;
+ }
+ }
+ }
+
if(draw_goto_patrol_lines) {
update_line(pMotionEvent->x, pMotionEvent->y);
}
@@ -407,13 +498,13 @@
if (get_client_state() == CLIENT_GAME_RUNNING_STATE) {
- if (game.player_ptr->is_connected && game.player_ptr->is_alive
- && !game.player_ptr->turn_done) {
+ if (game.player_ptr && game.player_ptr->is_connected &&
game.player_ptr->is_alive
+ && !game.player_ptr->phase_done) {
int i, is_waiting, is_moving;
for (i = 0, is_waiting = 0, is_moving = 0; i < game.info.nplayers; i++)
if (game.players[i].is_alive && game.players[i].is_connected) {
- if (game.players[i].turn_done) {
+ if (game.players[i].phase_done) {
is_waiting++;
} else {
is_moving++;
@@ -425,18 +516,16 @@
}
}
- if(tileset_is_isometric(tileset) && do_focus_animation &&
pAnim->num_tiles_focused_unit) {
- real_blink_active_unit();
- } else {
+ if(do_focus_animation) {
blink_active_unit();
}
if (flip) {
update_timeout_label();
- if (seconds_to_turndone > 0) {
- seconds_to_turndone--;
+ if (get_seconds_to_turndone() > 0) {
+ set_seconds_to_turndone(get_seconds_to_turndone() - 1);
} else {
- seconds_to_turndone = 0;
+ set_seconds_to_turndone(0);
}
}
@@ -712,8 +801,6 @@
SDL_Surface *pBgd, *pTmp;
Uint32 iSDL_Flags;
- init_character_encodings(INTERNAL_ENCODING);
-
SDL_Client_Flags = 0;
iSDL_Flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE;
@@ -726,7 +813,7 @@
SDL_VideoDriverName(device, sizeof(device)));
/* create splash screen */
- pBgd = load_surf(datafilename("misc/intro.png"));
+ pBgd = adj_surf(load_surf(datafilename("misc/intro.png")));
if(pBgd && SDL_GetVideoInfo()->wm_available) {
set_video_mode(pBgd->w, pBgd->h, SDL_SWSURFACE | SDL_ANYFORMAT |
SDL_RESIZABLE);
@@ -755,17 +842,16 @@
}
/* create label beackground */
- pTmp = create_surf(350, 50, SDL_SWSURFACE);
+ pTmp = create_surf(adj_size(350), adj_size(50), SDL_SWSURFACE);
pBgd = SDL_DisplayFormatAlpha(pTmp);
FREESURFACE(pTmp);
SDL_FillRect(pBgd, NULL, SDL_MapRGBA(pBgd->format, 255, 255, 255, 128));
- putframe(pBgd, 0, 0, pBgd->w - 1, pBgd->h - 1, 0xFF000000);
+ putframe(pBgd, 0, 0, pBgd->w - 1, pBgd->h - 1, SDL_MapRGB(pBgd->format, 0,
0, 0));
SDL_SetAlpha(pBgd, 0x0, 0x0);
-
pInit_String = create_iconlabel(pBgd, Main.gui,
- create_str16_from_char(_("Initializing Client"), 20),
+ create_str16_from_char(_("Initializing Client"), adj_font(20)),
WF_ICON_CENTER|WF_FREE_THEME);
pInit_String->string16->style |= SF_CENTER;
@@ -845,34 +931,53 @@
draw_city_names = FALSE;
draw_city_productions = FALSE;
is_unit_move_blocked = FALSE;
+
SDL_Client_Flags |= (CF_DRAW_PLAYERS_NEUTRAL_STATUS|
CF_DRAW_PLAYERS_WAR_STATUS|
CF_DRAW_PLAYERS_CEASEFIRE_STATUS|
CF_DRAW_PLAYERS_PEACE_STATUS|
- CF_DRAW_PLAYERS_ALLIANCE_STATUS|
- CF_CIV3_CITY_TEXT_STYLE|
- CF_DRAW_MAP_DITHER);
-
- tileset_load_tiles(tileset);
+ CF_DRAW_PLAYERS_ALLIANCE_STATUS);
load_cursors();
tilespec_setup_theme();
tilespec_setup_anim();
+ tilespec_setup_city_gfx();
tilespec_setup_city_icons();
- finish_loading_sprites();
+
+ tileset_load_tiles(tileset);
clear_double_messages_call();
create_units_order_widgets();
setup_auxiliary_tech_icons();
- unload_unused_graphics();
if((SDL_Client_Flags & CF_TOGGLED_FULLSCREEN) == CF_TOGGLED_FULLSCREEN) {
+ #ifdef SMALL_SCREEN
+ #ifdef UNDER_CE
+ /* set 320x240 fullscreen */
+ set_video_mode(320, 240, SDL_SWSURFACE | SDL_ANYFORMAT |
SDL_FULLSCREEN);
+ #else
+ /* small screen on desktop -> don't set 320x240 fullscreen mode */
+ set_video_mode(320, 240, SDL_SWSURFACE | SDL_ANYFORMAT |
SDL_RESIZABLE);
+ #endif
+ #else
set_video_mode(800, 600, SDL_SWSURFACE | SDL_ANYFORMAT | SDL_FULLSCREEN);
SDL_Client_Flags &= ~CF_TOGGLED_FULLSCREEN;
+ #endif
+
} else {
+
+ #ifdef SMALL_SCREEN
+ #ifdef UNDER_CE
+ set_video_mode(320, 240, SDL_SWSURFACE | SDL_ANYFORMAT);
+ #else
+ set_video_mode(320, 240, SDL_SWSURFACE | SDL_ANYFORMAT | SDL_RESIZABLE);
+ #endif
+ #else
set_video_mode(640, 480, SDL_SWSURFACE | SDL_ANYFORMAT | SDL_RESIZABLE);
+ #endif
+
#if 0
/*
* call this for other that X enviroments - currently not supported.
@@ -884,29 +989,32 @@
/* SDL_WM_SetCaption("SDLClient of Freeciv", "FreeCiv"); */
draw_intro_gfx();
-
- mapview.tile_width = (mapview.width - 1)
- / tileset_tile_width(tileset) + 1;
- mapview.tile_height = (mapview.height - 1)
- / tileset_tile_height(tileset) + 1;
-
flush_all();
/* this need correct Main.screen size */
+ init_mapcanvas_and_overview();
Init_MapView();
+
+ #ifndef SMALL_SCREEN
init_options_button();
+ #endif
+
set_new_order_widgets_dest_buffers();
set_client_state(CLIENT_PRE_GAME_STATE);
/* Main game loop */
gui_event_loop(NULL, NULL, main_key_down_handler, main_key_up_handler,
- main_mouse_button_down_handler, NULL,
+ main_mouse_button_down_handler, main_mouse_button_up_handler,
main_mouse_motion_handler);
+ #if defined UNDER_CE && defined SMALL_SCREEN
+ /* change back to window mode to restore the title bar */
+ set_video_mode(320, 240, SDL_SWSURFACE | SDL_ANYFORMAT);
+ #endif
+
free_auxiliary_tech_icons();
- tilespec_unload_theme();
- tilespec_free_city_icons();
+
tilespec_free_anim();
unload_cursors();
free_font_system();
@@ -938,7 +1046,6 @@
**************************************************************************/
void disable_focus_animation(void)
{
- pAnim_User_Event->user.code = EVENT_ERROR;
SDL_Client_Flags &= ~CF_FOCUS_ANIMATION;
}
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/gui_main.h
devel/client/gui-sdl/gui_main.h
--- devel_distclean/client/gui-sdl/gui_main.h 2005-10-16 21:49:00.000000000
+0200
+++ devel/client/gui-sdl/gui_main.h 2005-11-15 06:52:44.000000000 +0100
@@ -24,6 +24,9 @@
#include "gui_main_g.h"
+/* enable this to adjust sizes for 320x240 resolution */
+/*#define SMALL_SCREEN*/
+
/* #define DEBUG_SDL */
/* SDL client Flags */
@@ -43,8 +46,6 @@
#define CF_CITY_STATUS_SPECIAL (1<<12)
#define CF_CHANGE_TAXRATE_LUX_BLOCK (1<<13)
#define CF_CHANGE_TAXRATE_SCI_BLOCK (1<<14)
-#define CF_CIV3_CITY_TEXT_STYLE (1<<15)
-#define CF_DRAW_MAP_DITHER (1<<16)
#define CF_DRAW_CITY_GRID (1<<17)
#define CF_DRAW_CITY_WORKER_GRID (1<<18)
#define CF_DRAW_PLAYERS_WAR_STATUS (1<<19)
@@ -62,6 +63,8 @@
extern bool RCTRL;
extern bool LALT;
extern bool do_focus_animation;
+extern int city_names_font_size;
+extern int city_productions_font_size;
void force_exit_from_event_loop(void);
void add_autoconnect_to_timer(void);
@@ -80,4 +83,11 @@
Uint16 (*mouse_button_up_handler)(SDL_MouseButtonEvent *pButtonEvent,
void *pData),
Uint16 (*mouse_motion_handler)(SDL_MouseMotionEvent *pMotionEvent,
void *pData));
+/* shrink sizes for 320x240 screen */
+#ifdef SMALL_SCREEN
+ #define adj_size(size) (size) / 2
+#else
+ #define adj_size(size) (size)
+#endif
+
#endif /* FC__GUI_MAIN_H */
diff -u -r -b -B -X devel/diff_ignore
devel_distclean/client/gui-sdl/gui_string.c devel/client/gui-sdl/gui_string.c
--- devel_distclean/client/gui-sdl/gui_string.c 2005-10-15 23:27:27.000000000
+0200
+++ devel/client/gui-sdl/gui_string.c 2005-11-15 06:52:44.000000000 +0100
@@ -40,7 +40,7 @@
#include "gui_string.h"
#define DEFAULT_PTSIZE 18
-#define FONT_NAME "stdfont.ttf"
+#define FONT_NAME "fonts/Vera.ttf"
/* =================================================== */
@@ -59,6 +59,35 @@
static SDL_Surface *create_str16_surf(SDL_String16 * pString);
static SDL_Surface *create_str16_multi_surf(SDL_String16 * pString);
+/**************************************************************************
+ ...
+**************************************************************************/
+#ifdef SMALL_SCREEN
+int adj_font(int size) {
+ switch(size) {
+ case 24:
+ return 12;
+ case 20:
+ return 12;
+ case 16:
+ return 10;
+ case 14:
+ return 8;
+ case 13:
+ return 8;
+ case 12:
+ return 8;
+ case 11:
+ return 7;
+ case 10:
+ return 7;
+ case 8:
+ return 6;
+ default:
+ return size;
+ }
+}
+#endif
/**************************************************************************
...
@@ -594,9 +623,12 @@
if(!pFont_with_FullPath) {
char *path = datafilename(FONT_NAME);
if(!path) {
+ path = datafilename("stdfont.ttf");
+ if (!path) {
die(_("Couldn't find stdfont.ttf file. Please link/copy/move any"
"unicode ttf font to data dir as stdfont.ttf"));
}
+ }
pFont_with_FullPath = mystrdup(path);
assert(pFont_with_FullPath != NULL);
}
diff -u -r -b -B -X devel/diff_ignore
devel_distclean/client/gui-sdl/gui_string.h devel/client/gui-sdl/gui_string.h
--- devel_distclean/client/gui-sdl/gui_string.h 2005-10-15 23:27:27.000000000
+0200
+++ devel/client/gui-sdl/gui_string.h 2005-11-15 06:52:44.000000000 +0100
@@ -64,7 +64,15 @@
void unload_font(Uint16 ptsize);
void free_font_system(void);
+/* adjust font sizes on 320x240 screen */
+#ifdef SMALL_SCREEN
+ int adj_font(int size);
+#else
+ #define adj_font(size) size
+#endif
+
#define str16len(pString16) str16size(pString16).w
+#define str16height(pString16) str16size(pString16).h
/*
* here we use ordinary free( ... ) becouse check is made
diff -u -r -b -B -X devel/diff_ignore
devel_distclean/client/gui-sdl/gui_stuff.c devel/client/gui-sdl/gui_stuff.c
--- devel_distclean/client/gui-sdl/gui_stuff.c 2005-10-16 21:48:59.000000000
+0200
+++ devel/client/gui-sdl/gui_stuff.c 2005-11-15 06:52:44.000000000 +0100
@@ -42,6 +42,7 @@
#include "gui_tilespec.h"
#include "gui_main.h"
#include "mapview.h"
+#include "log.h"
#include "gui_id.h"
#include "gui_stuff.h"
@@ -131,8 +132,8 @@
static void correct_size_bcgnd_surf(SDL_Surface * pTheme,
Uint16 * pWidth, Uint16 * pHigh)
{
- *pWidth = MAX(*pWidth, 2 * (pTheme->w / 16));
- *pHigh = MAX(*pHigh, 2 * (pTheme->h / 16));
+ *pWidth = MAX(*pWidth, 2 * (pTheme->w / adj_size(16)));
+ *pHigh = MAX(*pHigh, 2 * (pTheme->h / adj_size(16)));
}
/**************************************************************************
@@ -690,25 +691,25 @@
color.unused = 150;
- pBcgd = create_filled_surface(pText->w + 10, pText->h + 6, SDL_SWSURFACE,
+ pBcgd = create_filled_surface(pText->w + adj_size(10), pText->h +
adj_size(6), SDL_SWSURFACE,
get_game_colorRGB(COLOR_STD_QUICK_INFO));
/* callculate start position */
- if (pWidget->size.y - pBcgd->h - 6 < 0) {
- pInfo_Area->y = pWidget->size.y + pWidget->size.h + 3;
+ if (pWidget->size.y - pBcgd->h - adj_size(6) < 0) {
+ pInfo_Area->y = pWidget->size.y + pWidget->size.h + adj_size(3);
} else {
- pInfo_Area->y = pWidget->size.y - pBcgd->h - 5;
+ pInfo_Area->y = pWidget->size.y - pBcgd->h - adj_size(5);
}
- if (pWidget->size.x + pBcgd->w + 5 > Main.screen->w) {
- pInfo_Area->x = pWidget->size.x - pBcgd->w - 5;
+ if (pWidget->size.x + pBcgd->w + adj_size(5) > Main.screen->w) {
+ pInfo_Area->x = pWidget->size.x - pBcgd->w - adj_size(5);
} else {
- pInfo_Area->x = pWidget->size.x + 3;
+ pInfo_Area->x = pWidget->size.x + adj_size(3);
}
- pInfo_Area->w = pBcgd->w + 2;
- pInfo_Area->h = pBcgd->h + 2;
+ pInfo_Area->w = pBcgd->w + adj_size(2);
+ pInfo_Area->h = pBcgd->h + adj_size(2);
/* draw theme and text */
dest = *pInfo_Area;
@@ -719,24 +720,24 @@
SDL_FillRect(Main.gui, &dest ,
SDL_MapRGBA(Main.gui->format, color.r, color.g, color.b, color.unused));
*/
- dest.x += 5;
- dest.y += 3;
+ dest.x += adj_size(5);
+ dest.y += adj_size(3);
SDL_BlitSurface(pText, NULL, Main.screen, &dest);
/* draw frame */
putline(Main.screen, pInfo_Area->x + 1, pInfo_Area->y,
- pInfo_Area->x + pInfo_Area->w - 2, pInfo_Area->y, 0x0);
+ pInfo_Area->x + pInfo_Area->w - adj_size(2), pInfo_Area->y, 0x0);
putline(Main.screen, pInfo_Area->x, pInfo_Area->y + 1,
- pInfo_Area->x, pInfo_Area->y + pInfo_Area->h - 2, 0x0);
+ pInfo_Area->x, pInfo_Area->y + pInfo_Area->h - adj_size(2), 0x0);
- putline(Main.screen, pInfo_Area->x + 1, pInfo_Area->y + pInfo_Area->h - 2,
- pInfo_Area->x + pInfo_Area->w - 2,
- pInfo_Area->y + pInfo_Area->h - 2, 0x0);
+ putline(Main.screen, pInfo_Area->x + 1, pInfo_Area->y + pInfo_Area->h -
adj_size(2),
+ pInfo_Area->x + pInfo_Area->w - adj_size(2),
+ pInfo_Area->y + pInfo_Area->h - adj_size(2), 0x0);
putline(Main.screen, pInfo_Area->x + pInfo_Area->w - 1, pInfo_Area->y + 1,
pInfo_Area->x + pInfo_Area->w - 1,
- pInfo_Area->y + pInfo_Area->h - 2, 0x0);
+ pInfo_Area->y + pInfo_Area->h - adj_size(2), 0x0);
/*flush_rect(*pInfo_Area);*/
@@ -757,13 +758,16 @@
Widgets.
**************************************************************************/
struct GUI *get_widget_pointer_form_ID(const struct GUI *pGUI_List,
- Uint16 ID)
+ Uint16 ID, enum scan_direction direction)
{
while (pGUI_List) {
if (pGUI_List->ID == ID) {
return (struct GUI *) pGUI_List;
}
+ if (direction == SCAN_FORWARD)
pGUI_List = pGUI_List->next;
+ else
+ pGUI_List = pGUI_List->prev;
}
return NULL;
}
@@ -774,7 +778,7 @@
**************************************************************************/
struct GUI *get_widget_pointer_form_main_list(Uint16 ID)
{
- return get_widget_pointer_form_ID(pBeginMainWidgetList, ID);
+ return get_widget_pointer_form_ID(pBeginMainWidgetList, ID, SCAN_FORWARD);
}
/**************************************************************************
@@ -1058,6 +1062,9 @@
struct GUI *pBufWidget = NULL;
struct GUI *pTmpWidget = pEndGroupWidgetList;
+ if (!pEndGroupWidgetList)
+ return;
+
if (pBeginGroupWidgetList == pEndGroupWidgetList) {
del_widget_from_gui_list(pTmpWidget);
return;
@@ -1525,8 +1532,12 @@
} while (pBuf != pDlg->pBeginActiveWidgetList);
}
+ if (pDlg->pScroll->pScrollBar) {
return pDlg->pScroll->max - pDlg->pScroll->pScrollBar->size.h -
count * (float)step /
pDlg->pScroll->step;
+ } else {
+ return pDlg->pScroll->max - count * (float)step / pDlg->pScroll->step;
+ }
}
/**************************************************************************
@@ -1964,7 +1975,7 @@
set_wflag(pNew_Widget, WF_HIDDEN);
}
- if(pDlg->pActiveWidgetList) {
+ if(pDlg->pActiveWidgetList && pDlg->pScroll->pScrollBar) {
blit_entire_src(pDlg->pScroll->pScrollBar->gfx,
pDlg->pScroll->pScrollBar->dst,
pDlg->pScroll->pScrollBar->size.x,
@@ -2088,8 +2099,10 @@
pDlg->pScroll->count--;
if(pDlg->pActiveWidgetList) {
+ if (pDlg->pScroll->pScrollBar) {
pDlg->pScroll->pScrollBar->size.h = scrollbar_size(pDlg->pScroll);
}
+ }
} else { /* no scrollbar */
pBuf = pDlg->pBeginActiveWidgetList;
@@ -2142,7 +2155,7 @@
del_widget_from_gui_list(pWidget);
- if(pDlg->pScroll && pDlg->pActiveWidgetList) {
+ if(pDlg->pScroll && pDlg->pScroll->pScrollBar && pDlg->pActiveWidgetList) {
pDlg->pScroll->pScrollBar->size.y = get_position(pDlg);
}
@@ -2579,17 +2592,17 @@
Uint32 color;
SDL_Color RGB_Color = { 255, 255, 255, 128 };
SDL_Rect dest, src = get_smaller_surface_rect(pIcon);
- SDL_Surface *pTheme = create_surf((src.w + 4) * 4, src.h + 4,
+ SDL_Surface *pTheme = create_surf((src.w + adj_size(4)) * 4, src.h +
adj_size(4),
SDL_SWSURFACE);
- dest.x = 2;
+ dest.x = adj_size(2);
dest.y = (pTheme->h - src.h) / 2;
/* normal */
SDL_BlitSurface(pIcon, &src, pTheme, &dest);
/* sellected */
- dest.x += (src.w + 4);
+ dest.x += (src.w + adj_size(4));
SDL_BlitSurface(pIcon, &src, pTheme, &dest);
/* draw sellect frame */
color = SDL_MapRGB(pTheme->format, 254, 254, 254);
@@ -2597,18 +2610,18 @@
dest.y + src.h, color);
/* pressed */
- dest.x += (src.w + 4);
+ dest.x += (src.w + adj_size(4));
SDL_BlitSurface(pIcon, &src, pTheme, &dest);
/* draw sellect frame */
putframe(pTheme, dest.x - 1, dest.y - 1, dest.x + src.w,
dest.y + src.h, color);
/* draw press frame */
color = SDL_MapRGB(pTheme->format, 246, 254, 2);
- putframe(pTheme, dest.x - 2, dest.y - 2, dest.x + (src.w + 1),
+ putframe(pTheme, dest.x - adj_size(2), dest.y - adj_size(2), dest.x + (src.w
+ 1),
dest.y + (src.h + 1), color);
/* disabled */
- dest.x += (src.w + 4);
+ dest.x += (src.w + adj_size(4));
SDL_BlitSurface(pIcon, &src, pTheme, &dest);
dest.w = src.w;
dest.h = src.h;
@@ -2766,8 +2779,8 @@
FREESURFACE(pIcon_Widget->theme);
}
pIcon_Widget->theme = pNew_Theme;
- pIcon_Widget->size.w = pNew_Theme->w + 4;
- pIcon_Widget->size.h = pNew_Theme->h + 4;
+ pIcon_Widget->size.w = pNew_Theme->w + adj_size(4);
+ pIcon_Widget->size.h = pNew_Theme->h + adj_size(4);
}
}
@@ -2788,8 +2801,8 @@
pIcon_Widget->dst = pDest;
if (pIcon) {
- pIcon_Widget->size.w = pIcon->w + 4;
- pIcon_Widget->size.h = pIcon->h + 4;
+ pIcon_Widget->size.w = pIcon->w + adj_size(4);
+ pIcon_Widget->size.h = pIcon->h + adj_size(4);
}
return pIcon_Widget;
@@ -2830,28 +2843,28 @@
if (state == FC_WS_SELLECTED) {
putframe(pIcon->dst, dest.x + 1, dest.y + 1,
- dest.x + dest.w + 2, dest.y + dest.h + 2,
+ dest.x + dest.w + adj_size(2), dest.y + dest.h + adj_size(2),
SDL_MapRGB(pIcon->dst->format, 254, 254, 254));
}
if (state == FC_WS_PRESSED) {
putframe(pIcon->dst, dest.x + 1, dest.y + 1,
- dest.x + dest.w + 2, dest.y + dest.h + 2,
+ dest.x + dest.w + adj_size(2), dest.y + dest.h + adj_size(2),
SDL_MapRGB(pIcon->dst->format, 254, 254, 254));
putframe(pIcon->dst, dest.x, dest.y,
- dest.x + dest.w + 3, dest.y + dest.h + 3,
+ dest.x + dest.w + adj_size(3), dest.y + dest.h + adj_size(3),
SDL_MapRGB(pIcon->dst->format, 246, 254, 2));
}
if (state == FC_WS_DISABLED) {
+ SDL_Color c = *get_game_colorRGB(COLOR_STD_DISABLED);
putframe(pIcon->dst, dest.x + 1, dest.y + 1,
- dest.x + dest.w + 2, dest.y + dest.h + 2,
- get_game_color(COLOR_STD_DISABLED, pIcon->dst));
+ dest.x + dest.w + adj_size(2), dest.y + dest.h + adj_size(2),
+ SDL_MapRGBA(pIcon->dst->format, c.r, c.g, c.b, c.unused));
}
-
- dest.x += 2;
- dest.y += 2;
+ dest.x += adj_size(2);
+ dest.y += adj_size(2);
ret = SDL_BlitSurface(pIcon->theme, NULL, pIcon->dst, &dest);
if (ret) {
return ret;
@@ -2916,19 +2929,19 @@
if (pIcon) {
if (pStr) {
if ((flags & WF_ICON_UNDER_TEXT) || (flags & WF_ICON_ABOVE_TEXT)) {
- w = MAX(w, pIcon->w + 2);
- h = MAX(h, buf.h + pIcon->h + 4);
+ w = MAX(w, pIcon->w + adj_size(2));
+ h = MAX(h, buf.h + pIcon->h + adj_size(4));
} else {
- w = MAX(w, buf.w + pIcon->w + 20);
- h = MAX(h, pIcon->h + 2);
+ w = MAX(w, buf.w + pIcon->w + adj_size(20));
+ h = MAX(h, pIcon->h + adj_size(2));
}
} else {
- w = MAX(w, pIcon->w + 2);
- h = MAX(h, pIcon->h + 2);
+ w = MAX(w, pIcon->w + adj_size(2));
+ h = MAX(h, pIcon->h + adj_size(2));
}
} else {
- w += 10;
- h += 2;
+ w += adj_size(10);
+ h += adj_size(2);
}
correct_size_bcgnd_surf(pTheme->Button, &w, &h);
@@ -3426,10 +3439,10 @@
if (pString16) {
pEdit->string16->style |= SF_CENTER;
buf = str16size(pString16);
- buf.h += 4;
+ buf.h += adj_size(4);
}
- length = MAX(length, buf.w + 10);
+ length = MAX(length, buf.w + adj_size(10));
correct_size_bcgnd_surf(pTheme->Edit, &length, &buf.h);
@@ -3527,9 +3540,9 @@
rDest.x += (pEdit->w - pText->w) / 2;
} else {
if (pEdit_Widget->string16->style & SF_CENTER_RIGHT) {
- rDest.x += pEdit->w - pText->w - 5;
+ rDest.x += pEdit->w - pText->w - adj_size(5);
} else {
- rDest.x += 5; /* cennter left */
+ rDest.x += adj_size(5); /* cennter left */
}
}
@@ -3589,9 +3602,9 @@
/* move cursor right */
if (pEdt->pInputChain->next) {
- if (pEdt->InputChain_X >= (pEdt->pWidget->size.x + pEdt->pBg->w - 10)) {
+ if (pEdt->InputChain_X >= (pEdt->pWidget->size.x + pEdt->pBg->w -
adj_size(10))) {
pEdt->Start_X -= pEdt->pInputChain->pTsurf->w -
- (pEdt->pWidget->size.x + pEdt->pBg->w - 5 - pEdt->InputChain_X);
+ (pEdt->pWidget->size.x + pEdt->pBg->w - adj_size(5) -
pEdt->InputChain_X);
}
pEdt->pInputChain = pEdt->pInputChain->next;
@@ -3609,9 +3622,9 @@
if (pEdt->pInputChain->prev) {
pEdt->pInputChain = pEdt->pInputChain->prev;
if ((pEdt->InputChain_X <=
- (pEdt->pWidget->size.x + 9)) && (pEdt->Start_X != 5)) {
- if (pEdt->InputChain_X != (pEdt->pWidget->size.x + 5)) {
- pEdt->Start_X += (pEdt->pWidget->size.x - pEdt->InputChain_X + 5);
+ (pEdt->pWidget->size.x + adj_size(9))) && (pEdt->Start_X !=
adj_size(5))) {
+ if (pEdt->InputChain_X != (pEdt->pWidget->size.x + adj_size(5))) {
+ pEdt->Start_X += (pEdt->pWidget->size.x - pEdt->InputChain_X +
adj_size(5));
}
pEdt->Start_X += (pEdt->pInputChain->pTsurf->w);
@@ -3629,7 +3642,7 @@
/* move cursor to begin of chain (and edit field) */
pEdt->pInputChain = pEdt->pBeginTextChain;
Redraw = TRUE;
- pEdt->Start_X = 5;
+ pEdt->Start_X = adj_size(5);
}
break;
case SDLK_KP1:
@@ -3643,7 +3656,7 @@
Redraw = TRUE;
if (pEdt->pWidget->size.w - pEdt->Truelength < 0) {
- pEdt->Start_X = pEdt->pWidget->size.w - pEdt->Truelength - 5;
+ pEdt->Start_X = pEdt->pWidget->size.w - pEdt->Truelength -
adj_size(5);
}
}
break;
@@ -3653,9 +3666,9 @@
if (pEdt->pInputChain->prev) {
if ((pEdt->InputChain_X <=
- (pEdt->pWidget->size.x + 9)) && (pEdt->Start_X != 5)) {
- if (pEdt->InputChain_X != (pEdt->pWidget->size.x + 5)) {
- pEdt->Start_X += (pEdt->pWidget->size.x - pEdt->InputChain_X + 5);
+ (pEdt->pWidget->size.x + adj_size(9))) && (pEdt->Start_X !=
adj_size(5))) {
+ if (pEdt->InputChain_X != (pEdt->pWidget->size.x + adj_size(5))) {
+ pEdt->Start_X += (pEdt->pWidget->size.x - pEdt->InputChain_X +
adj_size(5));
}
pEdt->Start_X += (pEdt->pInputChain->prev->pTsurf->w);
}
@@ -3754,12 +3767,12 @@
pEdt->Truelength += pEdt->pInputChain->prev->pTsurf->w;
}
- if (pEdt->InputChain_X >= pEdt->pWidget->size.x + pEdt->pBg->w - 10) {
+ if (pEdt->InputChain_X >= pEdt->pWidget->size.x + pEdt->pBg->w -
adj_size(10)) {
if (pEdt->pInputChain == pEdt->pEndTextChain) {
- pEdt->Start_X = pEdt->pBg->w - 5 - pEdt->Truelength;
+ pEdt->Start_X = pEdt->pBg->w - adj_size(5) - pEdt->Truelength;
} else {
pEdt->Start_X -= pEdt->pInputChain->prev->pTsurf->w -
- (pEdt->pWidget->size.x + pEdt->pBg->w - 5 -
pEdt->InputChain_X);
+ (pEdt->pWidget->size.x + pEdt->pBg->w - adj_size(5) -
pEdt->InputChain_X);
}
}
@@ -3801,7 +3814,7 @@
pEdt.pWidget = pEdit_Widget;
pEdt.ChainLen = 0;
pEdt.Truelength = 0;
- pEdt.Start_X = 5;
+ pEdt.Start_X = adj_size(5);
pEdt.InputChain_X = 0;
pEdit_Widget->data.ptr = (void *)&pEdt;
@@ -4374,7 +4387,7 @@
if (pTitle) {
SDL_Rect size = str16size(pTitle);
- w = MAX(w, size.w + 10);
+ w = MAX(w, size.w + adj_size(10));
h = MAX(h, size.h);
h = MAX(h, WINDOW_TILE_HIGH + 1);
}
@@ -4508,7 +4521,7 @@
memcpy(pPixelArray, pPixel, (w - x) * sizeof(Uint8));
my_memset8(pPixel, (color & 0xFF), w - x);
- (Uint8 *)pPixelArray += (w - x);
+ pPixelArray = (Uint8 *)pPixelArray + (w - x);
}
/*left */
@@ -4524,7 +4537,7 @@
for (; y < h; y++) {
*(Uint8 *)pPixelArray = *pPixel;
*pPixel = (color & 0xFF);
- ((Uint8 *)pPixelArray)++;
+ pPixelArray = (Uint8 *)pPixelArray + 1;
pPixel += pitch;
}
@@ -4550,7 +4563,7 @@
my_memset8(pPixel, (color & 0xFF), w - x);
pPixel += (w - x) - 1;
- ((Uint8 *)pPixelArray) += (w - x);
+ pPixelArray = (Uint8 *)pPixelArray + (w - x);
x = w - 1;
} else {
@@ -4571,7 +4584,7 @@
for (; y > y0; y--) {
*(Uint8 *)pPixelArray = *pPixel;
*pPixel = (color & 0xFF);
- ((Uint8 *)pPixelArray)++;
+ pPixelArray = (Uint8 *)pPixelArray + 1;
pPixel -= pitch;
}
@@ -4598,7 +4611,7 @@
memcpy(pPixelArray, pPixel, (w - x) * sizeof(Uint16));
my_memset16(pPixel, (color & 0xFFFF), w - x);
- ((Uint16 *)pPixelArray) += (w - x);
+ pPixelArray = (Uint16 *)pPixelArray + (w - x);
}
/*left */
@@ -4614,7 +4627,7 @@
for (; y < h; y++) {
*(Uint16 *)pPixelArray = *pPixel;
*pPixel = (color & 0xFFFF);
- ((Uint16 *)pPixelArray)++;
+ pPixelArray = (Uint16 *)pPixelArray + 1;
pPixel += pitch;
}
@@ -4640,7 +4653,7 @@
my_memset16(pPixel, (color & 0xFFFF), w - x);
pPixel += (w - x) - 1;
- ((Uint16 *)pPixelArray) += (w - x);
+ pPixelArray = (Uint16 *)pPixelArray + (w - x);
x = w - 1;
} else {
@@ -4661,7 +4674,7 @@
for (; y > y0; y--) {
*(Uint16 *)pPixelArray = *pPixel;
*pPixel = (color & 0xFFFF);
- ((Uint16 *)pPixelArray)++;
+ pPixelArray = (Uint16 *)pPixelArray + 1;
pPixel -= pitch;
}
@@ -4690,7 +4703,7 @@
memcpy(pPixelArray, pPixel, size * sizeof(Uint8));
my_memset24(pPixel, (color & 0xFFFFFF), size);
- ((Uint8 *)pPixelArray) += size;
+ pPixelArray = (Uint8 *)pPixelArray + size;
}
/*left */
@@ -4706,7 +4719,7 @@
for (; y < h; y++) {
memmove(pPixelArray, pPixel, 3);
memmove(pPixel, &color, 3);
- ((Uint8 *)pPixelArray) += 3;
+ pPixelArray = (Uint8 *)pPixelArray + 3;
pPixel += pitch;
}
@@ -4733,7 +4746,7 @@
my_memset24(pPixel, (color & 0xFFFFFF), size);
pPixel += size - 3;
- ((Uint8 *)pPixelArray) += size;
+ pPixelArray = (Uint8 *)pPixelArray + size;
x = w - 1;
} else {
@@ -4754,7 +4767,7 @@
for (; y > y0; y--) {
memmove(pPixelArray, pPixel, 3);
memmove(pPixel, &color, 3);
- ((Uint8 *)pPixelArray) += 3;
+ pPixelArray = (Uint8 *)pPixelArray + 3;
pPixel -= pitch;
}
@@ -4781,7 +4794,7 @@
memcpy(pPixelArray, pPixel, (w - x) * sizeof(Uint32));
my_memset32(pPixel, color, w - x);
- ((Uint32 *)pPixelArray) += (w - x);
+ pPixelArray = (Uint32 *)pPixelArray + (w - x);
}
/*left */
@@ -4797,7 +4810,7 @@
for (; y < h; y++) {
*(Uint32 *)pPixelArray = *pPixel;
*pPixel = color;
- ((Uint32 *)pPixelArray)++;
+ pPixelArray = (Uint32 *)pPixelArray + 1;
pPixel += pitch;
}
@@ -4823,7 +4836,7 @@
my_memset32(pPixel, color, w - x);
pPixel += (w - x) - 1;
- ((Uint32 *)pPixelArray) += (w - x);
+ pPixelArray = (Uint32 *)pPixelArray + (w - x);
x = w - 1;
} else {
@@ -4844,7 +4857,7 @@
for (; y > y0; y--) {
*(Uint32 *)pPixelArray = *pPixel;
*pPixel = color;
- ((Uint32 *)pPixelArray)++;
+ pPixelArray = (Uint32 *)pPixelArray + 1;
pPixel -= pitch;
}
@@ -4923,7 +4936,7 @@
pPixel = (Uint8 *)pDest->pixels + (y * pDest->pitch) + x;
memcpy(pPixel, pPixelArray, (w - x) * sizeof(Uint8));
- ((Uint8 *)pPixelArray) += (w - x);
+ pPixelArray = (Uint8 *)pPixelArray + (w - x);
}
@@ -4939,7 +4952,7 @@
for (; y < h; y++) {
*pPixel = *(Uint8 *)pPixelArray;
- ((Uint8 *)pPixelArray)++;
+ pPixelArray = (Uint8 *)pPixelArray + 1;
pPixel += pitch;
}
@@ -4964,7 +4977,7 @@
memcpy(pPixel, pPixelArray, (w - x) * sizeof(Uint8));
pPixel += (w - x) - 1;
- ((Uint8 *)pPixelArray) += (w - x);
+ pPixelArray = (Uint8 *)pPixelArray + (w - x);
x = w - 1;
} else {
@@ -4984,7 +4997,7 @@
for (; y > y0; y--) {
*pPixel = *(Uint8 *)pPixelArray;
- ((Uint8 *)pPixelArray)++;
+ pPixelArray = (Uint8 *)pPixelArray + 1;
pPixel -= pitch;
}
@@ -5009,7 +5022,7 @@
pPixel = (Uint16 *)((Uint8 *)pDest->pixels + (y * pDest->pitch) + x *
2);
memcpy(pPixel, pPixelArray, (w - x) * sizeof(Uint16));
- ((Uint16 *)pPixelArray) += (w - x);
+ pPixelArray = (Uint16 *)pPixelArray + (w - x);
}
@@ -5025,7 +5038,7 @@
for (; y < h; y++) {
*pPixel = *(Uint16 *)pPixelArray;
- ((Uint16 *)pPixelArray)++;
+ pPixelArray = (Uint16 *)pPixelArray + 1;
pPixel += pitch;
}
@@ -5050,7 +5063,7 @@
memcpy(pPixel, pPixelArray, (w - x) * sizeof(Uint16));
pPixel += (w - x) - 1;
- ((Uint16 *)pPixelArray) += (w - x);
+ pPixelArray = (Uint16 *)pPixelArray + (w - x);
x = w - 1;
} else {
@@ -5070,7 +5083,7 @@
for (; y > y0; y--) {
*pPixel = *(Uint16 *)pPixelArray;
- ((Uint16 *)pPixelArray)++;
+ pPixelArray = (Uint16 *)pPixelArray + 1;
pPixel -= pitch;
}
@@ -5097,7 +5110,7 @@
pPixel = (Uint8 *)pDest->pixels + (y * pDest->pitch) + x * 3;
memcpy(pPixel, pPixelArray, size * sizeof(Uint8));
- ((Uint8 *)pPixelArray) += size;
+ pPixelArray = (Uint8 *)pPixelArray + size;
}
@@ -5113,7 +5126,7 @@
for (; y < h; y++) {
memmove(pPixel, pPixelArray, 3);
- ((Uint8 *)pPixelArray) += 3;
+ pPixelArray = (Uint8 *)pPixelArray + 3;
pPixel += pitch;
}
@@ -5138,7 +5151,7 @@
memcpy(pPixel, pPixelArray, size * sizeof(Uint8));
pPixel += size - 3;
- ((Uint8 *)pPixelArray) += size;
+ pPixelArray = (Uint8 *)pPixelArray + size;
x = w - 1;
} else {
@@ -5158,7 +5171,7 @@
for (; y > y0; y--) {
memmove(pPixel, pPixelArray, 3);
- ((Uint8 *)pPixelArray) += 3;
+ pPixelArray = (Uint8 *)pPixelArray + 3;
pPixel -= pitch;
}
@@ -5183,7 +5196,7 @@
pPixel = (Uint32 *)((Uint8 *)pDest->pixels + (y * pDest->pitch) + x *
4);
memcpy(pPixel, pPixelArray, (w - x) * sizeof(Uint32));
- ((Uint32 *)pPixelArray) += (w - x);
+ pPixelArray = (Uint32 *)pPixelArray + (w - x);
}
/*left */
@@ -5198,7 +5211,7 @@
for (; y < h; y++) {
*pPixel = *(Uint32 *)pPixelArray;
- ((Uint32 *)pPixelArray)++;
+ pPixelArray = (Uint32 *)pPixelArray + 1;
pPixel += pitch;
}
@@ -5223,7 +5236,7 @@
memcpy(pPixel, pPixelArray, (w - x) * sizeof(Uint32));
pPixel += (w - x) - 1;
- ((Uint32 *)pPixelArray) += (w - x);
+ pPixelArray = (Uint32 *)pPixelArray + (w - x);
x = w - 1;
} else {
@@ -5510,7 +5523,7 @@
Uint16 w = 0, h = 0, space;
if (flags & WF_DRAW_TEXT_LABEL_WITH_SPACE) {
- space = 10;
+ space = adj_size(10);
} else {
space = 0;
}
@@ -5540,13 +5553,13 @@
if (pText) {
if ((flags & WF_ICON_UNDER_TEXT) || (flags & WF_ICON_ABOVE_TEXT)) {
w = MAX(w, pIcon->w + space);
- h = MAX(h, buf.h + pIcon->h + 3);
+ h = MAX(h, buf.h + pIcon->h + adj_size(3));
} else {
if (flags & WF_ICON_CENTER) {
w = MAX(w, pIcon->w + space);
h = MAX(h, pIcon->h);
} else {
- w = MAX(w, buf.w + pIcon->w + 5 + space);
+ w = MAX(w, buf.w + pIcon->w + adj_size(5) + space);
h = MAX(h, pIcon->h);
}
}
@@ -5804,9 +5817,9 @@
x = (pLabel->size.w - pText->w) / 2;
} else {
if (pLabel->string16->style & SF_CENTER_RIGHT) {
- x = pLabel->size.w - pText->w - 5;
+ x = pLabel->size.w - pText->w - adj_size(5);
} else {
- x = 5;
+ x = adj_size(5);
}
}
@@ -5871,7 +5884,7 @@
flags = get_wflags(pLabel);
if (flags & WF_DRAW_TEXT_LABEL_WITH_SPACE) {
- space = 5;
+ space = adj_size(5);
} else {
space = 0;
}
@@ -5899,12 +5912,12 @@
if (flags & WF_ICON_ABOVE_TEXT) {
yI = 0;
- y = pLabel->theme->h + 3
- + (pLabel->size.h - (pLabel->theme->h + 3) - pText->h) / 2;
+ y = pLabel->theme->h + adj_size(3)
+ + (pLabel->size.h - (pLabel->theme->h + adj_size(3)) - pText->h) /
2;
} else {
if (flags & WF_ICON_UNDER_TEXT) {
- y = (pLabel->size.h - (pLabel->theme->h + 3) - pText->h) / 2;
- yI = y + pText->h + 3;
+ y = (pLabel->size.h - (pLabel->theme->h + adj_size(3)) - pText->h) /
2;
+ yI = y + pText->h + adj_size(3);
} else {
yI = (pLabel->size.h - pLabel->theme->h) / 2;
y = (pLabel->size.h - pText->h) / 2;
@@ -5950,15 +5963,15 @@
goto Alone;
} else { /* WF_ICON_CENTER_LEFT */
if (pLabel->string16->style & SF_CENTER) {
- x = space + pLabel->theme->w + 5 + ((pLabel->size.w -
+ x = space + pLabel->theme->w + adj_size(5) + ((pLabel->size.w -
(space +
- pLabel->theme->w + 5) -
+ pLabel->theme->w +
adj_size(5)) -
pText->w) / 2);
} else {
if (pLabel->string16->style & SF_CENTER_RIGHT) {
x = pLabel->size.w - pText->w - space;
} else {
- x = space + pLabel->theme->w + 5;
+ x = space + pLabel->theme->w + adj_size(5);
}
}
} /* WF_ICON_CENTER_LEFT */
diff -u -r -b -B -X devel/diff_ignore
devel_distclean/client/gui-sdl/gui_stuff.h devel/client/gui-sdl/gui_stuff.h
--- devel_distclean/client/gui-sdl/gui_stuff.h 2005-10-17 17:15:35.000000000
+0200
+++ devel/client/gui-sdl/gui_stuff.h 2005-11-15 06:52:44.000000000 +0100
@@ -25,10 +25,17 @@
#include "fc_types.h"
#include "gui_mem.h"
+#include "gui_main.h"
-#define WINDOW_TILE_HIGH 20
+#ifdef SMALL_SCREEN
+#define FRAME_WH 2
+#define WINDOW_TILE_HIGH 10
+#else
#define FRAME_WH 3
-#define DOUBLE_FRAME_WH 6
+#define WINDOW_TILE_HIGH 20
+#endif
+
+#define DOUBLE_FRAME_WH FRAME_WH * 2
#define STATE_MASK 0x03
#define TYPE_MASK 0x03FC
@@ -180,6 +187,11 @@
struct ScrollBar *pScroll;
};
+enum scan_direction {
+ SCAN_FORWARD,
+ SCAN_BACKWARD
+};
+
SDL_Surface *create_bcgnd_surf(SDL_Surface *pTheme, SDL_bool transp,
Uint8 state, Uint16 Width, Uint16 High);
@@ -205,7 +217,9 @@
SDL_keysym Key);
struct GUI *MainWidgetListKeyScaner(SDL_keysym Key);
-struct GUI *get_widget_pointer_form_ID(const struct GUI *pGUI_List, Uint16 ID);
+struct GUI *get_widget_pointer_form_ID(const struct GUI *pGUI_List, Uint16 ID,
+ enum scan_direction direction);
+
struct GUI *get_widget_pointer_form_main_list(Uint16 ID);
void widget_sellected_action(struct GUI *pWidget);
diff -u -r -b -B -X devel/diff_ignore
devel_distclean/client/gui-sdl/gui_tilespec.c
devel/client/gui-sdl/gui_tilespec.c
--- devel_distclean/client/gui-sdl/gui_tilespec.c 2005-10-17
16:03:33.000000000 +0200
+++ devel/client/gui-sdl/gui_tilespec.c 2005-11-15 06:52:44.000000000 +0100
@@ -39,28 +39,33 @@
#include "gui_main.h"
#include "graphics.h"
#include "gui_zoom.h"
+#include "game.h"
#include "gui_tilespec.h"
-extern SDL_Surface *pDitherMask;
-
-static struct {
- /* Each citizen type has up to MAX_NUM_CITIZEN_SPRITES different
- * sprites, as defined by the tileset. */
- int count;
- SDL_Surface *surface[MAX_NUM_CITIZEN_SPRITES];
- } citizen[NUM_TILES_CITIZEN];
-
-
-#define load_GUI_surface(pSpr, pStruct, pSurf, tag) \
-do { \
- pSpr = load_sprite(tileset, tag); \
+struct sprite* lookup_sprite_tag_alt(struct tileset *t,
+ const char *tag, const char *alt,
+ bool required, const char *what,
+ const char *name);
+
+#ifdef SMALL_SCREEN
+ #define load_GUI_surface(pSpr, pStruct, pSurf, tag) \
+ do { \
+ pSpr = lookup_sprite_tag_alt(tileset, tag, "", TRUE, "", ""); \
pStruct->pSurf = (pSpr ? GET_SURF(pSpr) : NULL); \
assert(pStruct->pSurf != NULL); \
+ pStruct->pSurf = ZoomSurface(pStruct->pSurf, 0.5, 0.5, 0); \
pSpr->psurface = NULL; \
- unload_sprite(tileset, tag); \
-} while(0)
-
+ } while(0)
+#else
+ #define load_GUI_surface(pSpr, pStruct, pSurf, tag) \
+ do { \
+ pSpr = lookup_sprite_tag_alt(tileset, tag, "", TRUE, "", ""); \
+ pStruct->pSurf = (pSpr ? GET_SURF(pSpr) : NULL); \
+ assert(pStruct->pSurf != NULL); \
+ pSpr->psurface = NULL; \
+ } while(0)
+#endif
#define load_theme_surface(pSpr, pSurf, tag) \
load_GUI_surface(pSpr, pTheme, pSurf, tag)
@@ -77,105 +82,6 @@
} \
} while(0)
-/**********************************************************************
- Returns a text name for the citizen, as used in the tileset.
-***********************************************************************/
-static const char *get_citizen_name(struct citizen_type citizen)
-{
- /* These strings are used in reading the tileset. Do not
- * translate. */
- switch (citizen) {
- case CITIZEN_ELVIS:
- return "entertainer";
- case CITIZEN_SCIENTIST:
- return "scientist";
- case CITIZEN_TAXMAN:
- return "tax_collector";
- case CITIZEN_HAPPY:
- return "happy";
- case CITIZEN_CONTENT:
- return "content";
- case CITIZEN_UNHAPPY:
- return "unhappy";
- case CITIZEN_ANGRY:
- return "angry";
- default:
- die("unknown citizen type %d", (int) citizen);
- }
- return NULL;
-}
-
-/*******************************************************************************
- * reload citizens "style" icons.
-
*******************************************************************************/
-static void real_reload_citizens_icons(int style)
-{
- char tag[64];
- char alt_buf[32] = ".";
- int i , j;
- struct sprite *pSpr = NULL;
-
- if (strcmp("generic" , city_styles[style].citizens_graphic_alt))
- {
- my_snprintf(alt_buf , sizeof(alt_buf) , ".%s_",
- city_styles[style].citizens_graphic_alt );
- }
-
- /* Load the citizen sprite graphics. */
- for (i = 0; i < NUM_TILES_CITIZEN; i++) {
-
- my_snprintf(tag, sizeof(tag), "citizen.%s_%s",
- city_styles[style].citizens_graphic , get_citizen_name(i));
-
-
- pSpr = load_sprite(tileset, tag);
- if(!pSpr) {
- freelog(LOG_DEBUG,"Can't find %s", tag);
- my_snprintf(tag, sizeof(tag), "citizen%s%s", alt_buf
,get_citizen_name(i));
- freelog(LOG_DEBUG,"Trying load alternative %s", tag);
- pSpr = load_sprite(tileset, tag);
- }
-
- FREESURFACE(citizen[i].surface[0]);
- citizen[i].surface[0] = (pSpr ? GET_SURF(pSpr) : NULL);
-
- if (citizen[i].surface[0]) {
- /* If this form exists, use it as the only sprite. This allows
- * backwards compatability with tilesets that use e.g.,
- * citizen.entertainer. */
- citizen[i].count = 1;
- pSpr->psurface = NULL;
- unload_sprite(tileset, tag);
- continue;
- }
- for (j = 0; j < MAX_NUM_CITIZEN_SPRITES; j++) {
- my_snprintf(tag, sizeof(tag), "citizen.%s_%s_%d",
- city_styles[style].citizens_graphic ,get_citizen_name(i) , j );
-
- pSpr = load_sprite(tileset, tag);
- if(!pSpr) {
- freelog(LOG_DEBUG,"Can't find %s", tag);
- my_snprintf(tag, sizeof(tag), "citizen%s%s_%d", alt_buf,
- get_citizen_name(i), j);
- freelog(LOG_DEBUG,"Trying load alternative %s", tag);
- pSpr = load_sprite(tileset, tag);
- }
-
- FREESURFACE(citizen[i].surface[j]);
- citizen[i].surface[j] = (pSpr ? GET_SURF(pSpr) : NULL);
- if (!citizen[i].surface[j]) {
- break;
- }
- pSpr->psurface = NULL;
- unload_sprite(tileset, tag);
- }
- citizen[i].count = j;
- assert(j > 0);
- }
-
-}
-
-
/*******************************************************************************
* reload small citizens "style" icons.
*******************************************************************************/
@@ -197,58 +103,91 @@
FREESURFACE(pIcons->pSpec_Sci); /* Scientist */
/* allocate icons */
- pIcons->pMale_Happy =
- ResizeSurface(get_citizen_surface(CITIZEN_HAPPY, 0), 15, 26, 1);
+ #ifdef SMALL_SCREEN
+ pIcons->pMale_Happy = ZoomSurface(get_citizen_surface(CITIZEN_HAPPY, 0),
0.5, 0.5, 0);
+ #else
+ pIcons->pMale_Happy = get_citizen_surface(CITIZEN_HAPPY, 0);
+ #endif
SDL_SetColorKey(pIcons->pMale_Happy , SDL_SRCCOLORKEY|SDL_RLEACCEL,
get_first_pixel(pIcons->pMale_Happy));
- pIcons->pFemale_Happy =
- ResizeSurface(get_citizen_surface(CITIZEN_HAPPY, 1), 15, 26, 1);
+ #ifdef SMALL_SCREEN
+ pIcons->pFemale_Happy = ZoomSurface(get_citizen_surface(CITIZEN_HAPPY, 1),
0.5, 0.5, 0);
+ #else
+ pIcons->pFemale_Happy = get_citizen_surface(CITIZEN_HAPPY, 1);
+ #endif
SDL_SetColorKey(pIcons->pFemale_Happy , SDL_SRCCOLORKEY|SDL_RLEACCEL,
get_first_pixel(pIcons->pFemale_Happy));
- pIcons->pMale_Content =
- ResizeSurface(get_citizen_surface(CITIZEN_CONTENT, 0), 15, 26, 1);
+ #ifdef SMALL_SCREEN
+ pIcons->pMale_Content = ZoomSurface(get_citizen_surface(CITIZEN_CONTENT, 0),
0.5, 0.5, 0);
+ #else
+ pIcons->pMale_Content = get_citizen_surface(CITIZEN_CONTENT, 0);
+ #endif
SDL_SetColorKey( pIcons->pMale_Content , SDL_SRCCOLORKEY|SDL_RLEACCEL,
get_first_pixel(pIcons->pMale_Content ));
- pIcons->pFemale_Content =
- ResizeSurface(get_citizen_surface(CITIZEN_CONTENT, 1), 15, 26, 1);
+ #ifdef SMALL_SCREEN
+ pIcons->pFemale_Content = ZoomSurface(get_citizen_surface(CITIZEN_CONTENT,
1), 0.5, 0.5, 0);
+ #else
+ pIcons->pFemale_Content = get_citizen_surface(CITIZEN_CONTENT, 1);
+ #endif
SDL_SetColorKey(pIcons->pFemale_Content, SDL_SRCCOLORKEY|SDL_RLEACCEL,
get_first_pixel(pIcons->pFemale_Content));
- pIcons->pMale_Unhappy =
- ResizeSurface(get_citizen_surface(CITIZEN_UNHAPPY, 0), 15, 26, 1);
+ #ifdef SMALL_SCREEN
+ pIcons->pMale_Unhappy = ZoomSurface(get_citizen_surface(CITIZEN_UNHAPPY, 0),
0.5, 0.5, 0);
+ #else
+ pIcons->pMale_Unhappy = get_citizen_surface(CITIZEN_UNHAPPY, 0);
+ #endif
SDL_SetColorKey(pIcons->pMale_Unhappy , SDL_SRCCOLORKEY|SDL_RLEACCEL ,
get_first_pixel(pIcons->pMale_Unhappy));
- pIcons->pFemale_Unhappy =
- ResizeSurface(get_citizen_surface(CITIZEN_UNHAPPY, 1), 15, 26, 1);
+ #ifdef SMALL_SCREEN
+ pIcons->pFemale_Unhappy = ZoomSurface(get_citizen_surface(CITIZEN_UNHAPPY,
1), 0.5, 0.5, 0);
+ #else
+ pIcons->pFemale_Unhappy = get_citizen_surface(CITIZEN_UNHAPPY, 1);
+ #endif
SDL_SetColorKey(pIcons->pFemale_Unhappy , SDL_SRCCOLORKEY|SDL_RLEACCEL,
get_first_pixel(pIcons->pFemale_Unhappy));
- pIcons->pMale_Angry =
- ResizeSurface(get_citizen_surface(CITIZEN_ANGRY, 0), 15, 26, 1);
+ #ifdef SMALL_SCREEN
+ pIcons->pMale_Angry = ZoomSurface(get_citizen_surface(CITIZEN_ANGRY, 0),
0.5, 0.5, 0);
+ #else
+ pIcons->pMale_Angry = get_citizen_surface(CITIZEN_ANGRY, 0);
+ #endif
SDL_SetColorKey(pIcons->pMale_Angry , SDL_SRCCOLORKEY|SDL_RLEACCEL ,
get_first_pixel(pIcons->pMale_Angry));
- pIcons->pFemale_Angry =
- ResizeSurface(get_citizen_surface(CITIZEN_ANGRY, 1), 15, 26, 1);
+ #ifdef SMALL_SCREEN
+ pIcons->pFemale_Angry = ZoomSurface(get_citizen_surface(CITIZEN_ANGRY, 1),
0.5, 0.5, 0);
+ #else
+ pIcons->pFemale_Angry = get_citizen_surface(CITIZEN_ANGRY, 1);
+ #endif
SDL_SetColorKey(pIcons->pFemale_Angry , SDL_SRCCOLORKEY|SDL_RLEACCEL,
get_first_pixel(pIcons->pFemale_Angry));
- pIcons->pSpec_Lux =
- ResizeSurface(get_citizen_surface(CITIZEN_ELVIS, 0), 15, 26, 1);
+ #ifdef SMALL_SCREEN
+ pIcons->pSpec_Lux = ZoomSurface(GET_SURF(get_tax_sprite(tileset, O_LUXURY)),
0.5, 0.5, 0);
+ #else
+ pIcons->pSpec_Lux = GET_SURF(get_tax_sprite(tileset, O_LUXURY));
+ #endif
SDL_SetColorKey(pIcons->pSpec_Lux , SDL_SRCCOLORKEY|SDL_RLEACCEL,
get_first_pixel(pIcons->pSpec_Lux));
- pIcons->pSpec_Tax =
- ResizeSurface(get_citizen_surface(CITIZEN_TAXMAN, 0), 15, 26, 1);
+ #ifdef SMALL_SCREEN
+ pIcons->pSpec_Tax = ZoomSurface(GET_SURF(get_tax_sprite(tileset, O_GOLD)),
0.5, 0.5, 0);
+ #else
+ pIcons->pSpec_Tax = GET_SURF(get_tax_sprite(tileset, O_GOLD));
+ #endif
SDL_SetColorKey(pIcons->pSpec_Tax, SDL_SRCCOLORKEY|SDL_RLEACCEL,
get_first_pixel(pIcons->pSpec_Tax));
- pIcons->pSpec_Sci =
- ResizeSurface(get_citizen_surface(CITIZEN_SCIENTIST, 0), 15, 26, 1);
+ #ifdef SMALL_SCREEN
+ pIcons->pSpec_Sci = ZoomSurface(GET_SURF(get_tax_sprite(tileset,
O_SCIENCE)), 0.5, 0.5, 0);
+ #else
+ pIcons->pSpec_Sci = GET_SURF(get_tax_sprite(tileset, O_SCIENCE));
+ #endif
SDL_SetColorKey(pIcons->pSpec_Sci, SDL_SRCCOLORKEY|SDL_RLEACCEL,
get_first_pixel(pIcons->pSpec_Sci));
@@ -264,18 +203,31 @@
***********************************************************************/
void reload_citizens_icons(int style)
{
- real_reload_citizens_icons(style);
reload_small_citizens_icons(style);
pIcons->style = style;
}
+/**************************************************************************
+ ...
+**************************************************************************/
+void tilespec_setup_city_gfx(void) {
+ struct sprite *pSpr = lookup_sprite_tag_alt(tileset, "theme.city", "", TRUE,
"", "");
+ pCity_Surf = (pSpr ? GET_SURF(pSpr) : NULL);
+
+ #ifdef SMALL_SCREEN
+ pCity_Surf = ZoomSurface(pCity_Surf, 0.5, 0.5, 0);
+ #endif
+
+ assert(pCity_Surf != NULL);
+}
+
/**********************************************************************
Set city icons sprite value; should only happen after
tileset_load_tiles(tileset).
***********************************************************************/
void tilespec_setup_city_icons(void)
{
- int i, j;
+
struct sprite *pSpr = NULL;
pIcons = ( struct City_Icon *)MALLOC( sizeof( struct City_Icon ));
@@ -323,13 +275,8 @@
putline(pIcons->pWorklist, 3, 2, 5, 2, 0xFF000000);
putline(pIcons->pWorklist, 3, 4, 7, 4, 0xFF000000);
putline(pIcons->pWorklist, 3, 6, 6, 6, 0xFF000000);
+
/* ================================================================= */
- /* clear all citizens icons pointer */
- for (i = 0; i < NUM_TILES_CITIZEN; i++) {
- for (j = 0; j < MAX_NUM_CITIZEN_SPRITES; j++) {
- citizen[i].surface[j] = NULL;
- }
- }
/* force reload citizens icons */
pIcons->style = 999;
@@ -396,7 +343,7 @@
pTheme = MALLOC(sizeof(struct Theme));
- if(!sprite_exists("theme.tech_tree")) {
+ if(!lookup_sprite_tag_alt(tileset, "theme.tech_tree", "", FALSE, "", "")) {
freelog(LOG_FATAL, "Your current tileset don't contains ""all"" GUI theme
graphic\n"
"Please use other tileset with ""full"" GUI graphic pack (use -t tileset
options)\n"
"If you don't have any tileset with SDLClient GUI theme then go to
freeciv\n"
@@ -500,22 +447,6 @@
/* ------------------------------ */
- /* Map Dithering */
-
- if (tileset_is_isometric(tileset))
- {
- pBuf = sprites.dither_tile;
- pDitherMask = GET_SURF(pBuf);
- pBuf->psurface = NULL;
- unload_sprite(tileset, "t.dither_tile");
- assert(pDitherMask != NULL);
- /* ------------------------------ */
- /* Map Borders */
- load_theme_surface(pBuf, NWEST_BORDER_Icon,
"theme.normal_border_iso_west");
- load_theme_surface(pBuf, NNORTH_BORDER_Icon,
"theme.normal_border_iso_north");
- load_theme_surface(pBuf, NSOUTH_BORDER_Icon,
"theme.normal_border_iso_south");
- load_theme_surface(pBuf, NEAST_BORDER_Icon,
"theme.normal_border_iso_east");
- }
return;
}
@@ -560,7 +491,7 @@
do { \
iter = 0; \
my_snprintf(cBuf , sizeof(cBuf), "%s_%d", Tag, iter); \
- while(sprite_exists(cBuf)) { \
+ while(lookup_sprite_tag_alt(tileset, cBuf, "", FALSE, "", "")) { \
iter++; \
my_snprintf(cBuf , sizeof(cBuf), "%s_%d", Tag, iter); \
} \
@@ -569,7 +500,7 @@
pAnim->Cursors.Type = CALLOC(num + 1, sizeof(SDL_Cursor *)); \
for( iter=0; iter<num; iter++) { \
my_snprintf(cBuf,sizeof(cBuf), "%s_%d", Tag, iter); \
- pSpr = load_sprite(tileset, cBuf); \
+ pSpr = lookup_sprite_tag_alt(tileset, cBuf, "", FALSE, "", ""); \
image = (pSpr ? GET_SURF(pSpr) : NULL); \
assert(image != NULL); \
if (center) { \
@@ -577,7 +508,6 @@
} else { \
pAnim->Cursors.Type[iter] = SurfaceToCursor(image, x, y); \
} \
- unload_sprite(tileset, cBuf); \
} \
} \
} while(0)
@@ -593,29 +523,6 @@
int i, num;
pAnim = MALLOC(sizeof(struct Animation));
- i = 0;
- my_snprintf(buf , sizeof(buf), "explode.iso_nuke_%d", i);
- while(sprite_exists(buf)) {
- i++;
- my_snprintf(buf , sizeof(buf), "explode.iso_nuke_%d", i);
- }
- pAnim->num_tiles_explode_nuke = i;
-
- /* focus unit animation */
- i = 0;
- my_snprintf(buf , sizeof(buf), "anim.focus_%d", i);
- while(sprite_exists(buf)) {
- i++;
- my_snprintf(buf , sizeof(buf), "anim.focus_%d", i);
- }
- pAnim->num_tiles_focused_unit = i;
-
- pAnim->Focus = CALLOC(pAnim->num_tiles_focused_unit, sizeof(SDL_Surface *));
- for( i=0; i<pAnim->num_tiles_focused_unit; i++) {
- my_snprintf(buf,sizeof(buf), "anim.focus_%d", i);
- load_GUI_surface(pSpr, pAnim, Focus[i], buf);
- }
-
/* load cursors */
load_cursor(i, num, pSpr, image, buf, Patrol, "anim.patrol_cursor", 0, 0,
TRUE);
load_cursor(i, num, pSpr, image, buf, Goto, "anim.goto_cursor", 0, 0, TRUE);
@@ -633,10 +540,6 @@
void tilespec_free_anim(void)
{
int i,j;
- for(i=0; i<pAnim->num_tiles_focused_unit; i++) {
- FREESURFACE(pAnim->Focus[i]);
- }
- FREE(pAnim->Focus);
for(i=0; pAnim->Cursors.Patrol[i]; i++) {
SDL_FreeCursor(pAnim->Cursors.Patrol[i]);
@@ -760,10 +663,6 @@
FREESURFACE(pTheme->OReturn_Icon);
FREESURFACE(pTheme->OAirLift_Icon);
- /* Map Dithering */
-
- FREESURFACE(pDitherMask);
-
/* Map Borders */
FREESURFACE(pTheme->NWEST_BORDER_Icon);
FREESURFACE(pTheme->NNORTH_BORDER_Icon);
@@ -778,49 +677,18 @@
Return a surface for the given citizen. The citizen's type is given,
as well as their index (in the range [0..pcity->size)).
**************************************************************************/
-SDL_Surface * get_citizen_surface(struct citizen_type type,
+SDL_Surface * get_citizen_surface(enum citizen_category type,
int citizen_index)
{
- assert(type >= 0 && type < NUM_TILES_CITIZEN);
- citizen_index %= sprites.citizen[type].count;
- return citizen[type].surface[citizen_index];
+ struct citizen_type ctype = {.type = type};
+
+ return GET_SURF(get_citizen_sprite(tileset, ctype, 0, NULL));
}
-void unload_unused_graphics(void)
+/**************************************************************************
+ ...
+**************************************************************************/
+SDL_Surface * get_city_gfx(void)
{
- unload_sprite(tileset, "treaty.disagree_thumb_down");
- unload_sprite(tileset, "treaty.agree_thumb_up");
- unload_sprite(tileset, "spaceship.solar_panels");
- unload_sprite(tileset, "spaceship.life_support");
- unload_sprite(tileset, "spaceship.habitation");
- unload_sprite(tileset, "spaceship.structural");
- unload_sprite(tileset, "spaceship.fuel");
- unload_sprite(tileset, "spaceship.propulsion");
- unload_sprite(tileset, "citizen.entertainer");
- unload_sprite(tileset, "citizen.scientist");
- unload_sprite(tileset, "citizen.tax_collector");
- unload_sprite(tileset, "citizen.content_0");
- unload_sprite(tileset, "citizen.content_1");
- unload_sprite(tileset, "citizen.happy_0");
- unload_sprite(tileset, "citizen.happy_1");
- unload_sprite(tileset, "citizen.unhappy_0");
- unload_sprite(tileset, "citizen.unhappy_1");
- unload_sprite(tileset, "citizen.angry_0");
- unload_sprite(tileset, "citizen.angry_1");
- unload_sprite(tileset, "s.right_arrow");
- if (sprite_exists("t.coast_color"))
- {
- unload_sprite(tileset, "t.coast_color");
- }
- unload_sprite(tileset, "upkeep.gold");
- unload_sprite(tileset, "upkeep.gold2");
- unload_sprite(tileset, "upkeep.food");
- unload_sprite(tileset, "upkeep.food2");
- unload_sprite(tileset, "upkeep.unhappy");
- unload_sprite(tileset, "upkeep.unhappy2");
- unload_sprite(tileset, "upkeep.shield");
- if (tileset_is_isometric(tileset) && sprite_exists("explode.iso_nuke"))
- {
- unload_sprite(tileset, "explode.iso_nuke");
- }
+ return pCity_Surf;
}
diff -u -r -b -B -X devel/diff_ignore
devel_distclean/client/gui-sdl/gui_tilespec.h
devel/client/gui-sdl/gui_tilespec.h
--- devel_distclean/client/gui-sdl/gui_tilespec.h 2005-10-15
23:27:27.000000000 +0200
+++ devel/client/gui-sdl/gui_tilespec.h 2005-11-15 06:52:44.000000000 +0100
@@ -139,7 +139,6 @@
};
struct Animation {
- SDL_Surface **Focus;
struct {
SDL_Cursor **Patrol;
SDL_Cursor **Goto;
@@ -149,8 +148,6 @@
SDL_Cursor **MapScroll[SCROLL_LAST];
} Cursors;
- int num_tiles_focused_unit;
- int num_tiles_explode_nuke;
} *pAnim;
void tilespec_setup_anim(void);
@@ -202,11 +199,13 @@
} *pIcons;
+SDL_Surface *pCity_Surf;
+
+void tilespec_setup_city_gfx(void);
void tilespec_setup_city_icons(void);
void tilespec_free_city_icons(void);
void reload_citizens_icons(int style);
-SDL_Surface * get_citizen_surface(struct citizen_type type,
+SDL_Surface * get_city_gfx(void);
+SDL_Surface * get_citizen_surface(enum citizen_category type,
int citizen_index);
-void unload_unused_graphics(void);
-
#endif /* FC__GUI_TILESPEC_H */
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/helpdlg.c
devel/client/gui-sdl/helpdlg.c
--- devel_distclean/client/gui-sdl/helpdlg.c 2005-10-18 00:31:09.000000000
+0200
+++ devel/client/gui-sdl/helpdlg.c 2005-11-15 06:52:44.000000000 +0100
@@ -166,10 +166,10 @@
redraw_group(pWindow->prev, pWindow, FALSE);
- dst.x = pStore->pDock->prev->size.x - 10;
- dst.y = pStore->pDock->prev->size.y - 10;
- dst.w = pWindow->size.w - (dst.x - pWindow->size.x) - 10;
- dst.h = pWindow->size.h - (dst.y - pWindow->size.y) - 10;
+ dst.x = pStore->pDock->prev->size.x - adj_size(10);
+ dst.y = pStore->pDock->prev->size.y - adj_size(10);
+ dst.w = pWindow->size.w - (dst.x - pWindow->size.x) - adj_size(10);
+ dst.h = pWindow->size.h - (dst.y - pWindow->size.y) - adj_size(10);
SDL_FillRectAlpha(pWindow->dst, &dst, &color);
putframe(pWindow->dst, dst.x , dst.y , dst.x + dst.w , dst.y + dst.h,
0xFF000000);
@@ -208,10 +208,10 @@
pHelpDlg = MALLOC(sizeof(struct ADVANCED_DLG));
pStore = MALLOC(sizeof(struct UNITS_BUTTONS));
- pStr = create_str16_from_char(_("Help : Improvement"), 12);
+ pStr = create_str16_from_char(_("Help : Improvement"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 400, 400, WF_FREE_DATA);
+ pWindow = create_window(NULL, pStr, adj_size(400), adj_size(400),
WF_FREE_DATA);
pWindow->action = help_dlg_window_callback;
set_wstate(pWindow , FC_WS_NORMAL);
pWindow->data.ptr = (void *)pStore;
@@ -223,7 +223,7 @@
pBuf = create_themeicon(pTheme->Small_CANCEL_Icon, pWindow->dst,
WF_DRAW_THEME_TRANSPARENT);
- //w += pBuf->size.w + 10;
+ /*w += pBuf->size.w + 10;*/
pBuf->action = exit_help_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
@@ -233,10 +233,10 @@
/* ------------------ */
pDock = pBuf;
- pStr = create_string16(NULL, 0, 10);
+ pStr = create_string16(NULL, 0, adj_font(10));
pStr->style |= (TTF_STYLE_BOLD | SF_CENTER);
- pTmp = create_surf(140, 40, SDL_SWSURFACE);
+ pTmp = create_surf(adj_size(140), adj_size(40), SDL_SWSURFACE);
pText = SDL_DisplayFormatAlpha(pTmp);
FREESURFACE(pTmp);
pTmp = pText;
@@ -250,16 +250,16 @@
{
pBack = SDL_DisplayFormatAlpha(pTmp);
copy_chars_to_string16(pStr, get_improvement_name(type));
- pText = create_text_surf_smaller_that_w(pStr, 100 - 4);
+ pText = create_text_surf_smaller_that_w(pStr, adj_size(100 - 4));
/* draw name tech text */
- dst.x = 40 + (pBack->w - pText->w - 40) / 2;
+ dst.x = adj_size(40) + (pBack->w - pText->w - adj_size(40)) / 2;
dst.y = (pBack->h - pText->h) / 2;
SDL_BlitSurface(pText, NULL, pBack, &dst);
FREESURFACE(pText);
/* draw tech icon */
- pText = GET_SURF(get_improvement_type(type)->sprite);
- dst.x = 5;
+ pText = adj_surf(GET_SURF(get_building_sprite(tileset, type)));
+ dst.x = adj_size(5);
dst.y = (pBack->h - pText->h) / 2;
SDL_BlitSurface(pText, NULL, pBack, &dst);
@@ -298,9 +298,9 @@
set_wstate(pBuf, FC_WS_NORMAL);
}
*/
- pBuf->size.w = 160;
- pBuf->size.h = 15;
- pBuf->string16->fgcol = *get_game_colorRGB(COLOR_STD_WHITE);
+ pBuf->size.w = adj_size(160);
+ pBuf->size.h = adj_size(15);
+ pBuf->string16->fgcol = (SDL_Color){255, 255, 255, 255};
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
add_to_gui_list(ID_BUTTON, pBuf);
@@ -326,19 +326,19 @@
pImpr_type = get_improvement_type(impr);
pBuf= create_iconlabel_from_chars(
- ZoomSurface(GET_SURF(pImpr_type->sprite), 3.0, 3.0, 1),
+ ZoomSurface(GET_SURF(get_building_sprite(tileset, impr)), 3.0, 3.0,
1),
pWindow->dst, get_impr_name_ex(NULL, impr),
- 24, WF_FREE_THEME);
+ adj_font(24), WF_FREE_THEME);
pBuf->ID = ID_LABEL;
DownAdd(pBuf, pDock);
pDock = pBuf;
- if (impr != B_CAPITAL)
+ if (!building_has_effect(impr, EFT_PROD_TO_GOLD))
{
sprintf(buffer, "%s %d", N_("Cost:"), impr_build_shield_cost(impr));
pBuf = create_iconlabel_from_chars(NULL,
- pWindow->dst, buffer, 12, 0);
+ pWindow->dst, buffer, adj_font(12), 0);
pBuf->ID = ID_LABEL;
DownAdd(pBuf, pDock);
pDock = pBuf;
@@ -346,38 +346,40 @@
{
sprintf(buffer, "%s %d", N_("Upkeep:"), pImpr_type->upkeep);
pBuf = create_iconlabel_from_chars(NULL,
- pWindow->dst, buffer, 12, 0);
+ pWindow->dst, buffer, adj_font(12), 0);
pBuf->ID = ID_LABEL;
DownAdd(pBuf, pDock);
pDock = pBuf;
}
}
pBuf = create_iconlabel_from_chars(NULL,
- pWindow->dst, N_("Requirement:"), 12, 0);
+ pWindow->dst, N_("Requirement:"), adj_font(12), 0);
pBuf->ID = ID_LABEL;
DownAdd(pBuf, pDock);
pDock = pBuf;
- if(pImpr_type->tech_req==A_LAST || pImpr_type->tech_req==A_NONE)
+ if (!(requirement_vector_size(&pImpr_type->reqs) > 0))
{
pBuf = create_iconlabel_from_chars(NULL,
- pWindow->dst, _("None"), 12, 0);
+ pWindow->dst, _("None"), adj_font(12), 0);
pBuf->ID = ID_LABEL;
} else {
+ requirement_vector_iterate(&pImpr_type->reqs, preq) {
pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,
- advances[pImpr_type->tech_req].name, 12,
+ advances[preq->source.value.tech].name, adj_font(12),
WF_DRAW_THEME_TRANSPARENT);
- pBuf->ID = MAX_ID - pImpr_type->tech_req;
- pBuf->string16->fgcol = *get_tech_color(pImpr_type->tech_req);
+ pBuf->ID = MAX_ID - preq->source.value.tech;
+ pBuf->string16->fgcol = *get_tech_color(preq->source.value.tech);
pBuf->action = change_tech_callback;
set_wstate(pBuf, FC_WS_NORMAL);
+ } requirement_vector_iterate_end;
}
DownAdd(pBuf, pDock);
pDock = pBuf;
pStore->pReq = pBuf;
pBuf = create_iconlabel_from_chars(NULL,
- pWindow->dst, N_("Obsolete by:"), 12, 0);
+ pWindow->dst, N_("Obsolete by:"), adj_font(12), 0);
pBuf->ID = ID_LABEL;
DownAdd(pBuf, pDock);
pDock = pBuf;
@@ -385,11 +387,11 @@
if(pImpr_type->obsolete_by==A_LAST || pImpr_type->obsolete_by==A_NONE)
{
pBuf = create_iconlabel_from_chars(NULL,
- pWindow->dst, _("None"), 12, 0);
+ pWindow->dst, _("None"), adj_font(12), 0);
pBuf->ID = ID_LABEL;
} else {
pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,
- advances[pImpr_type->obsolete_by].name, 12,
+ advances[pImpr_type->obsolete_by].name, adj_font(12),
WF_DRAW_THEME_TRANSPARENT);
pBuf->ID = MAX_ID - pImpr_type->obsolete_by;
pBuf->string16->fgcol = *get_tech_color(pImpr_type->obsolete_by);
@@ -400,14 +402,14 @@
pDock = pBuf;
pStore->pObs = pBuf;
- start_x = (FRAME_WH + 1 + width + pHelpDlg->pEndActiveWidgetList->size.w +
20);
+ start_x = (FRAME_WH + 1 + width + pHelpDlg->pEndActiveWidgetList->size.w +
adj_size(20));
buffer[0] = '\0';
helptext_building(buffer, sizeof(buffer), impr, NULL);
if (buffer[0] != '\0')
{
- SDL_String16 *pStr = create_str16_from_char(buffer, 12);
- convert_string_to_const_surface_width(pStr, 640 - start_x - 20);
+ SDL_String16 *pStr = create_str16_from_char(buffer, adj_font(12));
+ convert_string_to_const_surface_width(pStr, adj_size(640) - start_x
- adj_size(20));
pBuf = create_iconlabel(NULL, pWindow->dst, pStr, 0);
pBuf->ID = ID_LABEL;
DownAdd(pBuf, pDock);
@@ -421,8 +423,8 @@
/* --------------------------------------------------------- */
if (created)
{
- w = 640;
- h = 480;
+ w = adj_size(640);
+ h = adj_size(480);
pWindow->size.x = (Main.screen->w - w) / 2;
pWindow->size.y = (Main.screen->h - h) / 2;
@@ -443,7 +445,7 @@
pStore->pDock->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 1;
h = setup_vertical_widgets_position(1, pWindow->size.x + FRAME_WH + width,
- pWindow->size.y + WINDOW_TILE_HIGH + 17, 0, 0,
+ pWindow->size.y + WINDOW_TILE_HIGH + adj_size(17), 0, 0,
pHelpDlg->pBeginActiveWidgetList,
pHelpDlg->pEndActiveWidgetList);
@@ -451,7 +453,7 @@
{
setup_vertical_scrollbar_area(pHelpDlg->pScroll,
pWindow->size.x + FRAME_WH,
- pWindow->size.y + WINDOW_TILE_HIGH + 17,
+ pWindow->size.y + WINDOW_TILE_HIGH + adj_size(17),
h, FALSE);
}
}
@@ -459,10 +461,10 @@
/* unittype icon and label */
pBuf = pStore->pDock->prev;
pBuf->size.x = pWindow->size.x + start_x;
- pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 20;
- start_y = pBuf->size.y + pBuf->size.h + 10;
+ pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(20);
+ start_y = pBuf->size.y + pBuf->size.h + adj_size(10);
- if (impr != B_CAPITAL)
+ if (!building_has_effect(impr, EFT_PROD_TO_GOLD))
{
pBuf = pBuf->prev;
pBuf->size.x = pWindow->size.x + start_x;
@@ -470,7 +472,7 @@
if (!is_wonder(impr))
{
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 20;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(20);
pBuf->size.y = start_y;
}
start_y += pBuf->size.h;
@@ -480,21 +482,21 @@
pBuf->size.x = pWindow->size.x + start_x;
pBuf->size.y = start_y;
- pStore->pReq->size.x = pBuf->size.x + pBuf->size.w + 5;
+ pStore->pReq->size.x = pBuf->size.x + pBuf->size.w + adj_size(5);
pStore->pReq->size.y = start_y;
if (pStore->pObs)
{
pBuf = pStore->pObs->next;
- pBuf->size.x = pStore->pReq->size.x + pStore->pReq->size.w + 10;
+ pBuf->size.x = pStore->pReq->size.x + pStore->pReq->size.w + adj_size(10);
pBuf->size.y = start_y;
- pStore->pObs->size.x = pBuf->size.x + pBuf->size.w + 5;
+ pStore->pObs->size.x = pBuf->size.x + pBuf->size.w + adj_size(5);
pStore->pObs->size.y = start_y;
start_y += pStore->pObs->size.h;
}
- start_y += 30;
+ start_y += adj_size(30);
if (text)
{
pHelpText->size.x = pWindow->size.x + start_x;
@@ -521,10 +523,10 @@
redraw_group(pWindow->prev, pWindow, FALSE);
- dst.x = pStore->pDock->prev->size.x - 10;
- dst.y = pStore->pDock->prev->size.y - 10;
- dst.w = pWindow->size.w - (dst.x - pWindow->size.x) - 10;
- dst.h = pWindow->size.h - (dst.y - pWindow->size.y) - 10;
+ dst.x = pStore->pDock->prev->size.x - adj_size(10);
+ dst.y = pStore->pDock->prev->size.y - adj_size(10);
+ dst.w = pWindow->size.w - (dst.x - pWindow->size.x) - adj_size(10);
+ dst.h = pWindow->size.h - (dst.y - pWindow->size.y) - adj_size(10);
SDL_FillRectAlpha(pWindow->dst, &dst, &color);
putframe(pWindow->dst, dst.x , dst.y , dst.x + dst.w , dst.y + dst.h,
0xFF000000);
@@ -563,10 +565,10 @@
pHelpDlg = MALLOC(sizeof(struct ADVANCED_DLG));
pStore = MALLOC(sizeof(struct UNITS_BUTTONS));
- pStr = create_str16_from_char(_("Help : Units"), 12);
+ pStr = create_str16_from_char(_("Help : Units"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 400, 400, WF_FREE_DATA);
+ pWindow = create_window(NULL, pStr, adj_size(400), adj_size(400),
WF_FREE_DATA);
pWindow->action = help_dlg_window_callback;
set_wstate(pWindow , FC_WS_NORMAL);
pWindow->data.ptr = (void *)pStore;
@@ -587,10 +589,10 @@
/* ------------------ */
pDock = pBuf;
- pStr = create_string16(NULL, 0, 10);
+ pStr = create_string16(NULL, 0, adj_font(10));
pStr->style |= (TTF_STYLE_BOLD | SF_CENTER);
- pTmp = create_surf(135, 40, SDL_SWSURFACE);
+ pTmp = create_surf(adj_size(135), adj_size(40), SDL_SWSURFACE);
pText = SDL_DisplayFormatAlpha(pTmp);
FREESURFACE(pTmp);
pTmp = pText;
@@ -601,25 +603,25 @@
h = 0;
unit_type_iterate(type) {
- pUnit = get_unit_type(type);
+ pUnit = type;
pBack = SDL_DisplayFormatAlpha(pTmp);
copy_chars_to_string16(pStr, pUnit->name);
- pText = create_text_surf_smaller_that_w(pStr, 100 - 4);
+ pText = create_text_surf_smaller_that_w(pStr, adj_size(100 - 4));
/* draw name tech text */
- dst.x = 35 + (pBack->w - pText->w - 35) / 2;
+ dst.x = adj_size(35) + (pBack->w - pText->w - adj_size(35)) / 2;
dst.y = (pBack->h - pText->h) / 2;
SDL_BlitSurface(pText, NULL, pBack, &dst);
FREESURFACE(pText);
/* draw tech icon */
{
- float zoom = 25.0 / GET_SURF(pUnit->sprite)->h;
- pText = ZoomSurface(GET_SURF(pUnit->sprite), zoom, zoom, 1);
+ float zoom = 25.0 / GET_SURF(get_unittype_sprite(tileset, type))->h;
+ pText = ZoomSurface(GET_SURF(get_unittype_sprite(tileset, type)),
zoom, zoom, 1);
}
- dst.x = (35 - pText->w) / 2;;
+ dst.x = (adj_size(35) - pText->w) / 2;;
dst.y = (pBack->h - pText->h) / 2;
SDL_BlitSurface(pText, NULL, pBack, &dst);
FREESURFACE(pText);
@@ -629,7 +631,7 @@
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = change_unit_callback;
- add_to_gui_list(MAX_ID - type, pBuf);
+ add_to_gui_list(MAX_ID - type->index, pBuf);
if (++h > 10)
{
@@ -652,16 +654,16 @@
/* toggle techs list button */
pBuf = create_themeicon_button_from_chars(pTheme->UP_Icon,
- pWindow->dst, _("Units"), 10, 0);
+ pWindow->dst, _("Units"), adj_font(10), 0);
/*pBuf->action = toggle_full_tree_mode_in_help_dlg_callback;
if (pStore->show_tree)
{
set_wstate(pBuf, FC_WS_NORMAL);
}
*/
- pBuf->size.w = 160;
- pBuf->size.h = 15;
- pBuf->string16->fgcol = *get_game_colorRGB(COLOR_STD_WHITE);
+ pBuf->size.w = adj_size(160);
+ pBuf->size.h = adj_size(15);
+ pBuf->string16->fgcol = (SDL_Color){255, 255, 255, 255};
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
add_to_gui_list(ID_BUTTON, pBuf);
@@ -685,8 +687,8 @@
}
pUnit = get_unit_type(type_id);
- pBuf= create_iconlabel_from_chars(GET_SURF(pUnit->sprite),
- pWindow->dst, pUnit->name, 24, 0);
+ pBuf= create_iconlabel_from_chars(GET_SURF(get_unittype_sprite(tileset,
+ get_unit_type(type_id))), pWindow->dst, pUnit->name, 24, 0);
pBuf->ID = ID_LABEL;
DownAdd(pBuf, pDock);
@@ -697,8 +699,8 @@
char local[2048];
my_snprintf(local, sizeof(local), "%s %d %s",
- N_("Cost:"), unit_build_shield_cost(type_id),
- PL_("shield", "shields", unit_build_shield_cost(type_id)));
+ N_("Cost:"), unit_build_shield_cost(get_unit_type(type_id)),
+ PL_("shield", "shields",
unit_build_shield_cost(get_unit_type(type_id))));
if(pUnit->pop_cost)
{
@@ -708,20 +710,20 @@
cat_snprintf(local, sizeof(local), " %s", N_("Upkeep:"));
- if(pUnit->shield_cost)
+ if(pUnit->upkeep[O_SHIELD])
{
cat_snprintf(local, sizeof(local), " %d %s",
- pUnit->shield_cost, PL_("shield", "shields", pUnit->shield_cost));
+ pUnit->upkeep[O_SHIELD], PL_("shield", "shields",
pUnit->upkeep[O_SHIELD]));
}
- if(pUnit->food_cost)
+ if(pUnit->upkeep[O_FOOD])
{
cat_snprintf(local, sizeof(local), " %d %s",
- pUnit->food_cost, PL_("food", "foods", pUnit->food_cost));
+ pUnit->upkeep[O_FOOD], PL_("food", "foods", pUnit->upkeep[O_FOOD]));
}
- if(pUnit->gold_cost)
+ if(pUnit->upkeep[O_GOLD])
{
cat_snprintf(local, sizeof(local), " %d %s",
- pUnit->gold_cost, PL_("gold", "golds", pUnit->gold_cost));
+ pUnit->upkeep[O_GOLD], PL_("gold", "golds", pUnit->upkeep[O_GOLD]));
}
if(pUnit->happy_cost)
{
@@ -733,18 +735,18 @@
N_("Attack:"), pUnit->attack_strength,
N_("Defense:"), pUnit->defense_strength,
N_("Move:"), pUnit->move_rate / SINGLE_MOVE,
- N_("Vision:"), pUnit->vision_range,
+ N_("Vision:"), pUnit->vision_radius_sq,
N_("FirePower:"), pUnit->firepower,
N_("Hitpoints:"), pUnit->hp);
pBuf = create_iconlabel_from_chars(NULL,
- pWindow->dst, local, 12, 0);
+ pWindow->dst, local, adj_font(12), 0);
pBuf->ID = ID_LABEL;
DownAdd(pBuf, pDock);
pDock = pBuf;
}
pBuf = create_iconlabel_from_chars(NULL,
- pWindow->dst, N_("Requirement:"), 12, 0);
+ pWindow->dst, N_("Requirement:"), adj_font(12), 0);
pBuf->ID = ID_LABEL;
DownAdd(pBuf, pDock);
pDock = pBuf;
@@ -752,11 +754,11 @@
if(pUnit->tech_requirement==A_LAST || pUnit->tech_requirement==A_NONE)
{
pBuf = create_iconlabel_from_chars(NULL,
- pWindow->dst, _("None"), 12, 0);
+ pWindow->dst, _("None"), adj_font(12), 0);
pBuf->ID = ID_LABEL;
} else {
pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,
- advances[pUnit->tech_requirement].name, 12,
+ advances[pUnit->tech_requirement].name, adj_font(12),
WF_DRAW_THEME_TRANSPARENT);
pBuf->ID = MAX_ID - pUnit->tech_requirement;
pBuf->string16->fgcol = *get_tech_color(pUnit->tech_requirement);
@@ -768,21 +770,21 @@
pStore->pReq = pBuf;
pBuf = create_iconlabel_from_chars(NULL,
- pWindow->dst, N_("Obsolete by:"), 12, 0);
+ pWindow->dst, N_("Obsolete by:"), adj_font(12), 0);
pBuf->ID = ID_LABEL;
DownAdd(pBuf, pDock);
pDock = pBuf;
if (pUnit->obsoleted_by == U_NOT_OBSOLETED) {
pBuf = create_iconlabel_from_chars(NULL,
- pWindow->dst, _("None"), 12, 0);
+ pWindow->dst, _("None"), adj_font(12), 0);
pBuf->ID = ID_LABEL;
} else {
- struct unit_type *utype = get_unit_type(pUnit->obsoleted_by);
+ struct unit_type *utype = pUnit->obsoleted_by;
pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,
- utype->name, 12, WF_DRAW_THEME_TRANSPARENT);
+ utype->name, adj_font(12), WF_DRAW_THEME_TRANSPARENT);
pBuf->string16->fgcol = *get_tech_color(utype->tech_requirement);
- pBuf->ID = MAX_ID - pUnit->obsoleted_by;
+ pBuf->ID = MAX_ID - pUnit->obsoleted_by->index;
pBuf->action = change_unit_callback;
set_wstate(pBuf, FC_WS_NORMAL);
}
@@ -790,14 +792,14 @@
pDock = pBuf;
pStore->pObs = pBuf;
- start_x = (FRAME_WH + 1 + width + pHelpDlg->pActiveWidgetList->size.w + 20);
+ start_x = (FRAME_WH + 1 + width + pHelpDlg->pActiveWidgetList->size.w +
adj_size(20));
buffer[0] = '\0';
- helptext_unit(buffer, type_id, "");
+ helptext_unit(buffer, get_unit_type(type_id), "");
if (buffer[0] != '\0')
{
- SDL_String16 *pStr = create_str16_from_char(buffer, 12);
- convert_string_to_const_surface_width(pStr, 640 - start_x - 20);
+ SDL_String16 *pStr = create_str16_from_char(buffer, adj_font(12));
+ convert_string_to_const_surface_width(pStr, adj_size(640) - start_x
- adj_size(20));
pBuf = create_iconlabel(NULL, pWindow->dst, pStr, 0);
pBuf->ID = ID_LABEL;
DownAdd(pBuf, pDock);
@@ -810,8 +812,8 @@
/* --------------------------------------------------------- */
if (created)
{
- w = 640;
- h = 480;
+ w = adj_size(640);
+ h = adj_size(480);
pWindow->size.x = (Main.screen->w - w) / 2;
pWindow->size.y = (Main.screen->h - h) / 2;
@@ -832,7 +834,7 @@
pStore->pDock->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 1;
h = setup_vertical_widgets_position(1, pWindow->size.x + FRAME_WH + width,
- pWindow->size.y + WINDOW_TILE_HIGH + 17, 0, 0,
+ pWindow->size.y + WINDOW_TILE_HIGH + adj_size(17), 0, 0,
pHelpDlg->pBeginActiveWidgetList,
pHelpDlg->pEndActiveWidgetList);
@@ -840,7 +842,7 @@
{
setup_vertical_scrollbar_area(pHelpDlg->pScroll,
pWindow->size.x + FRAME_WH,
- pWindow->size.y + WINDOW_TILE_HIGH + 17,
+ pWindow->size.y + WINDOW_TILE_HIGH + adj_size(17),
h, FALSE);
}
}
@@ -848,8 +850,8 @@
/* unittype icon and label */
pBuf = pStore->pDock->prev;
pBuf->size.x = pWindow->size.x + start_x;
- pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 20;
- start_y = pBuf->size.y + pBuf->size.h + 10;
+ pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(20);
+ start_y = pBuf->size.y + pBuf->size.h + adj_size(10);
pBuf = pBuf->prev;
pBuf->size.x = pWindow->size.x + start_x;
@@ -860,16 +862,16 @@
pBuf->size.x = pWindow->size.x + start_x;
pBuf->size.y = start_y;
- pStore->pReq->size.x = pBuf->size.x + pBuf->size.w + 5;
+ pStore->pReq->size.x = pBuf->size.x + pBuf->size.w + adj_size(5);
pStore->pReq->size.y = start_y;
pBuf = pStore->pObs->next;
- pBuf->size.x = pStore->pReq->size.x + pStore->pReq->size.w + 10;
+ pBuf->size.x = pStore->pReq->size.x + pStore->pReq->size.w + adj_size(10);
pBuf->size.y = start_y;
- pStore->pObs->size.x = pBuf->size.x + pBuf->size.w + 5;
+ pStore->pObs->size.x = pBuf->size.x + pBuf->size.w + adj_size(5);
pStore->pObs->size.y = start_y;
- start_y += pStore->pObs->size.h + 20;
+ start_y += pStore->pObs->size.h + adj_size(20);
if (text)
{
@@ -917,15 +919,15 @@
redraw_group(pWindow->prev, pWindow, FALSE);
- dst.x = pStore->pDock->prev->prev->size.x - 10;
- dst.y = pStore->pDock->prev->prev->size.y - 10;
- dst.w = pWindow->size.w - (dst.x - pWindow->size.x) - 10;
- dst.h = pWindow->size.h - (dst.y - pWindow->size.y) - 10;
+ dst.x = pStore->pDock->prev->prev->size.x - adj_size(10);
+ dst.y = pStore->pDock->prev->prev->size.y - adj_size(10);
+ dst.w = pWindow->size.w - (dst.x - pWindow->size.x) - adj_size(10);
+ dst.h = pWindow->size.h - (dst.y - pWindow->size.y) - adj_size(10);
SDL_FillRectAlpha(pWindow->dst, &dst, &color);
putframe(pWindow->dst, dst.x , dst.y , dst.x + dst.w , dst.y + dst.h,
0xFF000000);
/* -------------------------- */
- pStr = create_str16_from_char(_("Allows"), 14);
+ pStr = create_str16_from_char(_("Allows"), adj_font(14));
pStr->style |= TTF_STYLE_BOLD;
pText0 = create_text_surf_from_str16(pStr);
@@ -935,7 +937,7 @@
dst.y = pStore->pTargets[0]->size.y - pText0->h;
} else {
dst.y = pStore->pDock->prev->prev->size.y
- + pStore->pDock->prev->prev->size.h + 10;
+ + pStore->pDock->prev->prev->size.h + adj_size(10);
}
SDL_BlitSurface(pText0, NULL, pWindow->dst, &dst);
FREESURFACE(pText0);
@@ -944,7 +946,7 @@
{
int i;
- change_ptsize16(pStr, 12);
+ change_ptsize16(pStr, adj_font(12));
copy_chars_to_string16(pStr, _("( witch "));
pText0 = create_text_surf_from_str16(pStr);
@@ -980,7 +982,7 @@
int start_x, start_y, imp_count, unit_count, flags_count, gov_count;
char *buffer = &long_buffer[0];
- start_x = (FRAME_WH + 1 + width + pHelpDlg->pActiveWidgetList->size.w + 20);
+ start_x = (FRAME_WH + 1 + width + pHelpDlg->pActiveWidgetList->size.w +
adj_size(20));
pBuf = create_icon2(pTheme->Tech_Tree_Icon, pWindow->dst,
WF_DRAW_THEME_TRANSPARENT);
@@ -993,7 +995,7 @@
/* ----------------------------------- */
pBuf= create_iconlabel_from_chars(get_tech_icon(tech),
- pWindow->dst, advances[tech].name, 24, 0);
+ pWindow->dst, advances[tech].name, adj_font(24), 0);
pBuf->ID = ID_LABEL;
DownAdd(pBuf, pDock);
@@ -1005,7 +1007,8 @@
if ((targets_count<6)
&& (advances[i].req[0] == tech || advances[i].req[1] == tech))
{
- pBuf= create_iconlabel_from_chars(NULL, pWindow->dst, advances[i].name,
12, WF_DRAW_THEME_TRANSPARENT);
+ pBuf= create_iconlabel_from_chars(NULL, pWindow->dst, advances[i].name,
+ adj_font(12), WF_DRAW_THEME_TRANSPARENT);
pBuf->string16->fgcol = *get_tech_color(i);
max_width = MAX(max_width, pBuf->size.w);
set_wstate(pBuf, FC_WS_NORMAL);
@@ -1041,7 +1044,8 @@
continue;
}
}
- pBuf= create_iconlabel_from_chars(NULL, pWindow->dst,
advances[sub_tech].name, 12, WF_DRAW_THEME_TRANSPARENT);
+ pBuf= create_iconlabel_from_chars(NULL, pWindow->dst,
+ advances[sub_tech].name, adj_font(12), WF_DRAW_THEME_TRANSPARENT);
pBuf->string16->fgcol = *get_tech_color(sub_tech);
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = change_tech_callback;
@@ -1061,9 +1065,32 @@
gov_count = 0;
government_iterate(gov) {
- if (gov->required_tech == tech)
- {
- pBuf = create_iconlabel_from_chars(GET_SURF(gov->sprite),
+
+ requirement_vector_iterate(&gov->reqs, preq) {
+ if ((preq->source.type == REQ_TECH) && preq->source.value.tech == tech) {
+
+ pBuf =
create_iconlabel_from_chars(GET_SURF(get_government_sprite(tileset, gov)),
+ pWindow->dst, gov->name, adj_font(14),
+ WF_DRAW_THEME_TRANSPARENT|WF_SELLECT_WITHOUT_BAR);
+ set_wstate(pBuf, FC_WS_NORMAL);
+ pBuf->action = change_gov_callback;
+ pBuf->ID = MAX_ID - gov->index;
+ DownAdd(pBuf, pDock);
+ pDock = pBuf;
+ gov_count++;
+ }
+
+ } requirement_vector_iterate_end;
+
+ /* TODO: check if code replacement above is correct */
+#if 0
+ int j;
+
+ for (j = 0; j < MAX_NUM_REQS; j++) {
+
+ if ((gov->req[j].source.type == REQ_TECH) &&
+ (gov->req[j].source.value.tech == tech)) {
+ pBuf =
create_iconlabel_from_chars(GET_SURF(get_government_sprite(tileset, gov)),
pWindow->dst, gov->name, 14,
WF_DRAW_THEME_TRANSPARENT|WF_SELLECT_WITHOUT_BAR);
set_wstate(pBuf, FC_WS_NORMAL);
@@ -1073,6 +1100,10 @@
pDock = pBuf;
gov_count++;
}
+
+ }
+#endif
+
} government_iterate_end;
@@ -1078,9 +1109,33 @@
imp_count = 0;
impr_type_iterate(imp) {
+
struct impr_type *pImpr = get_improvement_type(imp);
- if (pImpr->tech_req == tech) {
- pBuf = create_iconlabel_from_chars(GET_SURF(pImpr->sprite),
+
+ requirement_vector_iterate(&pImpr->reqs, preq) {
+
+ if (preq->source.value.tech == tech) {
+ pBuf =
create_iconlabel_from_chars(GET_SURF(get_building_sprite(tileset, imp)),
+ pWindow->dst, get_improvement_name(imp), adj_font(14),
+ WF_DRAW_THEME_TRANSPARENT|WF_SELLECT_WITHOUT_BAR);
+ set_wstate(pBuf, FC_WS_NORMAL);
+ if (is_wonder(imp))
+ {
+ pBuf->string16->fgcol = *get_game_colorRGB(COLOR_STD_CITY_LUX);
+ }
+ pBuf->action = change_impr_callback;
+ pBuf->ID = MAX_ID - imp;
+ DownAdd(pBuf, pDock);
+ pDock = pBuf;
+ imp_count++;
+ }
+
+ } requirement_vector_iterate_end;
+
+ /* TODO: check if code replacement above is correct */
+#if 0
+ if (pImpr->req[0].source.value.tech == tech) {
+ pBuf = create_iconlabel_from_chars(GET_SURF(get_building_sprite(tileset,
imp)),
pWindow->dst, get_improvement_name(imp), 14,
WF_DRAW_THEME_TRANSPARENT|WF_SELLECT_WITHOUT_BAR);
set_wstate(pBuf, FC_WS_NORMAL);
@@ -1094,26 +1149,27 @@
pDock = pBuf;
imp_count++;
}
+#endif
} impr_type_iterate_end;
unit_count = 0;
unit_type_iterate(un) {
- struct unit_type *pUnit = get_unit_type(un);
+ struct unit_type *pUnit = un;
if (pUnit->tech_requirement == tech) {
- if (GET_SURF(pUnit->sprite)->w > 64)
+ if (GET_SURF(get_unittype_sprite(tileset, un))->w > 64)
{
- float zoom = 64.0 / GET_SURF(pUnit->sprite)->w;
- pBuf =
create_iconlabel_from_chars(ZoomSurface(GET_SURF(pUnit->sprite), zoom, zoom, 1),
+ float zoom = 64.0 / GET_SURF(get_unittype_sprite(tileset, un))->w;
+ pBuf =
create_iconlabel_from_chars(ZoomSurface(GET_SURF(get_unittype_sprite(tileset,
un)), zoom, zoom, 1),
pWindow->dst, pUnit->name, 14,
(WF_FREE_THEME|WF_DRAW_THEME_TRANSPARENT|WF_SELLECT_WITHOUT_BAR));
} else {
- pBuf = create_iconlabel_from_chars(GET_SURF(pUnit->sprite),
- pWindow->dst, pUnit->name, 14,
+ pBuf =
create_iconlabel_from_chars(GET_SURF(get_unittype_sprite(tileset, un)),
+ pWindow->dst, pUnit->name, adj_font(14),
(WF_DRAW_THEME_TRANSPARENT|WF_SELLECT_WITHOUT_BAR));
}
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = change_unit_callback;
- pBuf->ID = MAX_ID - un;
+ pBuf->ID = MAX_ID - un->index;
DownAdd(pBuf, pDock);
pDock = pBuf;
unit_count++;
@@ -1124,8 +1180,8 @@
helptext_tech(buffer, tech, "");
if (buffer[0] != '\0')
{
- SDL_String16 *pStr = create_str16_from_char(buffer, 12);
- convert_string_to_const_surface_width(pStr, 640 - start_x - 20);
+ SDL_String16 *pStr = create_str16_from_char(buffer, adj_font(12));
+ convert_string_to_const_surface_width(pStr, adj_size(640) - start_x
- adj_size(20));
pBuf = create_iconlabel(NULL, pWindow->dst, pStr, 0);
pBuf->ID = ID_LABEL;
DownAdd(pBuf, pDock);
@@ -1140,14 +1196,14 @@
/* tree button */
pBuf = pStore->pDock->prev;
- pBuf->size.x = pWindow->size.x + pWindow->size.w - pBuf->size.w - 20;
- pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 20;
+ pBuf->size.x = pWindow->size.x + pWindow->size.w - pBuf->size.w -
adj_size(20);
+ pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(20);
/* Tech label */
pBuf = pBuf->prev;
pBuf->size.x = pWindow->size.x + start_x;
- pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 20;
- start_y = pBuf->size.y + pBuf->size.h + 30;
+ pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(20);
+ start_y = pBuf->size.y + pBuf->size.h + adj_size(30);
if (targets_count)
{
@@ -1177,7 +1233,7 @@
i++;
}
- start_y += 10;
+ start_y += adj_size(10);
}
pBuf = NULL;
@@ -1188,7 +1244,7 @@
{
pBuf->size.x = pWindow->size.x + start_x;
pBuf->size.y = start_y;
- start_y += pBuf->size.h + 2;
+ start_y += pBuf->size.h + adj_size(2);
pBuf = pBuf->prev;
}
}
@@ -1203,7 +1259,7 @@
{
pBuf->size.x = pWindow->size.x + start_x;
pBuf->size.y = start_y;
- start_y += pBuf->size.h + 2;
+ start_y += pBuf->size.h + adj_size(2);
pBuf = pBuf->prev;
}
}
@@ -1218,7 +1274,7 @@
{
pBuf->size.x = pWindow->size.x + start_x;
pBuf->size.y = start_y;
- start_y += pBuf->size.h + 2;
+ start_y += pBuf->size.h + adj_size(2);
pBuf = pBuf->prev;
}
}
@@ -1233,7 +1289,7 @@
{
pBuf->size.x = pWindow->size.x + start_x;
pBuf->size.y = start_y;
- start_y += pBuf->size.h + 2;
+ start_y += pBuf->size.h + adj_size(2);
pBuf = pBuf->prev;
}
}
@@ -1256,9 +1312,10 @@
/* Redraw Window with exit button */
redraw_group(pWindow->prev, pWindow, FALSE);
- pSurf = ResizeSurface(get_tech_icon(MAX_ID - pTech->ID), 420, 420, 1);
+ pSurf = ResizeSurface(get_tech_icon(MAX_ID - pTech->ID), adj_size(420),
+ adj_size(420), 1);
SDL_SetAlpha(pSurf, SDL_SRCALPHA, 164);
- dst.x = pWindow->size.x + pWindow->size.w - pSurf->w - 50;
+ dst.x = pWindow->size.x + pWindow->size.w - pSurf->w - adj_size(50);
dst.y = pWindow->size.y + (pWindow->size.h - pSurf->h) / 2;;
SDL_BlitSurface(pSurf, NULL, pWindow->dst, &dst);
FREESURFACE(pSurf);
@@ -1333,7 +1390,7 @@
if (pSub0 || pSub1)
{
putline(pStore->pReq[i]->dst,
- pStore->pReq[i]->size.x - 10,
+ pStore->pReq[i]->size.x - adj_size(10),
pStore->pReq[i]->size.y + pStore->pReq[i]->size.h / 2,
pStore->pReq[i]->size.x ,
pStore->pReq[i]->size.y + pStore->pReq[i]->size.h / 2,
@@ -1343,15 +1400,15 @@
if(pSub0)
{
putline(pStore->pReq[i]->dst,
- pStore->pReq[i]->size.x - 10,
+ pStore->pReq[i]->size.x - adj_size(10),
pSub0->size.y + pSub0->size.h / 2,
- pStore->pReq[i]->size.x - 10 ,
+ pStore->pReq[i]->size.x - adj_size(10),
pStore->pReq[i]->size.y + pStore->pReq[i]->size.h / 2,
color);
putline(pStore->pReq[i]->dst,
pSub0->size.x + pSub0->size.w,
pSub0->size.y + pSub0->size.h / 2,
- pStore->pReq[i]->size.x - 10 ,
+ pStore->pReq[i]->size.x - adj_size(10),
pSub0->size.y + pSub0->size.h / 2,
color);
}
@@ -1359,15 +1416,15 @@
if(pSub1)
{
putline(pStore->pReq[i]->dst,
- pStore->pReq[i]->size.x - 10,
+ pStore->pReq[i]->size.x - adj_size(10),
pSub1->size.y + pSub1->size.h / 2,
- pStore->pReq[i]->size.x - 10 ,
+ pStore->pReq[i]->size.x - adj_size(10),
pStore->pReq[i]->size.y + pStore->pReq[i]->size.h / 2,
color);
putline(pStore->pReq[i]->dst,
pSub1->size.x + pSub1->size.w,
pSub1->size.y + pSub1->size.h / 2,
- pStore->pReq[i]->size.x - 10 ,
+ pStore->pReq[i]->size.x - adj_size(10),
pSub1->size.y + pSub1->size.h / 2,
color);
}
@@ -1527,7 +1584,7 @@
SDL_Surface *pSurf;
struct GUI *pDock = pStore->pDock;
- pStr = create_string16(NULL, 0, 10);
+ pStr = create_string16(NULL, 0, adj_font(10));
pStr->style |= (TTF_STYLE_BOLD | SF_CENTER);
copy_chars_to_string16(pStr, advances[tech].name);
@@ -1662,13 +1719,13 @@
/* ------------------------------------------ */
if (sub_req_count)
{
- w = (20 + pStore->pSub_Req[0]->size.w) * 2;
+ w = (adj_size(20) + pStore->pSub_Req[0]->size.w) * 2;
w += (pWindow->size.w - (20 + pStore->pSub_Req[0]->size.w + w +
pTech->size.w)) / 2;
} else {
if (req_count)
{
- w = (FRAME_WH + 1 + width + pStore->pReq[0]->size.w * 2 + 20);
- w += (pWindow->size.w - ((20 + pStore->pReq[0]->size.w) + w +
pTech->size.w)) / 2;
+ w = (FRAME_WH + 1 + width + pStore->pReq[0]->size.w * 2 + adj_size(20));
+ w += (pWindow->size.w - ((adj_size(20) + pStore->pReq[0]->size.w) + w +
pTech->size.w)) / 2;
} else {
w = (pWindow->size.w - pTech->size.w) / 2;
}
@@ -1679,37 +1736,40 @@
if(req_count)
{
- h = (req_count == 1 ? pStore->pReq[0]->size.h : req_count *
(pStore->pReq[0]->size.h + 80) - 80);
+ h = (req_count == 1 ? pStore->pReq[0]->size.h :
+ req_count * (pStore->pReq[0]->size.h + adj_size(80)) - adj_size(80));
h = pTech->size.y + (pTech->size.h - h) / 2;
for(i =0; i <req_count; i++)
{
- pStore->pReq[i]->size.x = pTech->size.x - 20 - pStore->pReq[i]->size.w;
+ pStore->pReq[i]->size.x = pTech->size.x - adj_size(20) -
pStore->pReq[i]->size.w;
pStore->pReq[i]->size.y = h;
- h += (pStore->pReq[i]->size.h + 80);
+ h += (pStore->pReq[i]->size.h + adj_size(80));
}
}
if(sub_req_count)
{
- h = (sub_req_count == 1 ? pStore->pSub_Req[0]->size.h : sub_req_count *
(pStore->pSub_Req[0]->size.h + 20) - 20);
+ h = (sub_req_count == 1 ? pStore->pSub_Req[0]->size.h :
+ sub_req_count * (pStore->pSub_Req[0]->size.h + adj_size(20)) -
adj_size(20));
h = pTech->size.y + (pTech->size.h - h) / 2;
for(i =0; i <sub_req_count; i++)
{
- pStore->pSub_Req[i]->size.x = pTech->size.x - (20 +
pStore->pSub_Req[i]->size.w) * 2;
+ pStore->pSub_Req[i]->size.x = pTech->size.x - (adj_size(20) +
pStore->pSub_Req[i]->size.w) * 2;
pStore->pSub_Req[i]->size.y = h;
- h += (pStore->pSub_Req[i]->size.h + 20);
+ h += (pStore->pSub_Req[i]->size.h + adj_size(20));
}
}
if(targets_count)
{
- h = (targets_count == 1 ? pStore->pTargets[0]->size.h : targets_count *
(pStore->pTargets[0]->size.h + 20) - 20);
+ h = (targets_count == 1 ? pStore->pTargets[0]->size.h :
+ targets_count * (pStore->pTargets[0]->size.h + adj_size(20)) -
adj_size(20));
h = pTech->size.y + (pTech->size.h - h) / 2;
for(i =0; i <targets_count; i++)
{
- pStore->pTargets[i]->size.x = pTech->size.x + pTech->size.w + 20;
+ pStore->pTargets[i]->size.x = pTech->size.x + pTech->size.w +
adj_size(20);
pStore->pTargets[i]->size.y = h;
- h += (pStore->pTargets[i]->size.h + 20);
+ h += (pStore->pTargets[i]->size.h + adj_size(20));
}
}
@@ -1718,11 +1778,11 @@
if(sub_targets_count < 3)
{
pStore->pSub_Targets[0]->size.x = pTech->size.x + pTech->size.w -
pStore->pSub_Targets[0]->size.w;
- pStore->pSub_Targets[0]->size.y = pTech->size.y -
pStore->pSub_Targets[0]->size.h - 10;
+ pStore->pSub_Targets[0]->size.y = pTech->size.y -
pStore->pSub_Targets[0]->size.h - adj_size(10);
if (pStore->pSub_Targets[1])
{
pStore->pSub_Targets[1]->size.x = pTech->size.x + pTech->size.w -
pStore->pSub_Targets[1]->size.w;
- pStore->pSub_Targets[1]->size.y = pTech->size.y + pTech->size.h + 10;
+ pStore->pSub_Targets[1]->size.y = pTech->size.y + pTech->size.h +
adj_size(10);
}
}
else
@@ -1734,13 +1794,13 @@
pStore->pSub_Targets[i]->size.x = pTech->size.x + pTech->size.w -
pStore->pSub_Targets[i]->size.w;
if (i < 2)
{
- pStore->pSub_Targets[i]->size.y = pTech->size.y -
(pStore->pSub_Targets[i]->size.h + 5) * ( 2 - i );
+ pStore->pSub_Targets[i]->size.y = pTech->size.y -
(pStore->pSub_Targets[i]->size.h + adj_size(5)) * ( 2 - i );
} else {
- pStore->pSub_Targets[i]->size.y = pTech->size.y + pTech->size.h + 5
+ (pStore->pSub_Targets[i]->size.h + 5) * ( i - 2 );
+ pStore->pSub_Targets[i]->size.y = pTech->size.y + pTech->size.h +
adj_size(5) + (pStore->pSub_Targets[i]->size.h + adj_size(5)) * ( i - 2 );
}
}
} else {
- h = (pStore->pSub_Targets[0]->size.h + 6);
+ h = (pStore->pSub_Targets[0]->size.h + adj_size(6));
for(i =0; i <MIN(sub_targets_count, 6); i++)
{
switch(i)
@@ -1750,7 +1810,7 @@
pStore->pSub_Targets[i]->size.y = pTech->size.y - h * 2;
break;
case 1:
- pStore->pSub_Targets[i]->size.x = pTech->size.x + pTech->size.w -
pStore->pSub_Targets[i]->size.w * 2 - 10;
+ pStore->pSub_Targets[i]->size.x = pTech->size.x + pTech->size.w -
pStore->pSub_Targets[i]->size.w * 2 - adj_size(10);
pStore->pSub_Targets[i]->size.y = pTech->size.y - h - h / 2;
break;
case 2:
@@ -1759,15 +1819,15 @@
break;
case 3:
pStore->pSub_Targets[i]->size.x = pTech->size.x + pTech->size.w -
pStore->pSub_Targets[i]->size.w;
- pStore->pSub_Targets[i]->size.y = pTech->size.y + pTech->size.h +
6;
+ pStore->pSub_Targets[i]->size.y = pTech->size.y + pTech->size.h +
adj_size(6);
break;
case 4:
pStore->pSub_Targets[i]->size.x = pTech->size.x + pTech->size.w -
pStore->pSub_Targets[i]->size.w;
- pStore->pSub_Targets[i]->size.y = pTech->size.y + pTech->size.h +
6 + h;
+ pStore->pSub_Targets[i]->size.y = pTech->size.y + pTech->size.h +
adj_size(6) + h;
break;
default:
- pStore->pSub_Targets[i]->size.x = pTech->size.x + pTech->size.w -
pStore->pSub_Targets[i]->size.w * 2 - 10;
- pStore->pSub_Targets[i]->size.y = pTech->size.y + pTech->size.h +
6 + h / 2 ;
+ pStore->pSub_Targets[i]->size.x = pTech->size.x + pTech->size.w -
pStore->pSub_Targets[i]->size.w * 2 - adj_size(10);
+ pStore->pSub_Targets[i]->size.y = pTech->size.y + pTech->size.h +
adj_size(6) + h / 2 ;
break;
};
}
@@ -1807,10 +1867,10 @@
pStore->show_tree = FALSE;
pStore->show_full_tree = FALSE;
- pStr = create_str16_from_char(_("Help : Advances Tree"), 12);
+ pStr = create_str16_from_char(_("Help : Advances Tree"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 400, 400, WF_FREE_DATA);
+ pWindow = create_window(NULL, pStr, adj_size(400), adj_size(400),
WF_FREE_DATA);
pWindow->data.ptr = (void *)pStore;
pWindow->action = help_dlg_window_callback;
set_wstate(pWindow , FC_WS_NORMAL);
@@ -1823,7 +1883,7 @@
pBuf = create_themeicon(pTheme->Small_CANCEL_Icon, pWindow->dst,
WF_DRAW_THEME_TRANSPARENT);
- //w += pBuf->size.w + 10;
+ /*w += pBuf->size.w + 10;*/
pBuf->action = exit_help_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
@@ -1832,7 +1892,7 @@
/* ------------------ */
pDock = pBuf;
- pStr = create_string16(NULL, 0, 10);
+ pStr = create_string16(NULL, 0, adj_font(10));
pStr->style |= (TTF_STYLE_BOLD | SF_CENTER);
h = 0;
@@ -1870,17 +1930,17 @@
/* toggle techs list button */
pBuf = create_themeicon_button_from_chars(pTheme->UP_Icon,
- pWindow->dst, _("Advances"), 10, 0);
+ pWindow->dst, _("Advances"), adj_font(10), 0);
pBuf->action = toggle_full_tree_mode_in_help_dlg_callback;
if (pStore->show_tree)
{
set_wstate(pBuf, FC_WS_NORMAL);
}
- pBuf->size.w = 160;
- pBuf->size.h = 15;
- pBuf->string16->fgcol = *get_game_colorRGB(COLOR_STD_WHITE);
+ pBuf->size.w = adj_size(160);
+ pBuf->size.h = adj_size(15);
+ pBuf->string16->fgcol = (SDL_Color){255, 255, 255, 255};
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
- //pBuf->key = SDLK_ESCAPE;
+ /*pBuf->key = SDLK_ESCAPE;*/
add_to_gui_list(ID_BUTTON, pBuf);
@@ -1930,8 +1990,8 @@
/* --------------------------------------------------------- */
if (created)
{
- w = 640;
- h = 480;
+ w = adj_size(640);
+ h = adj_size(480);
pWindow->size.x = (Main.screen->w - w) / 2;
pWindow->size.y = (Main.screen->h - h) / 2;
@@ -1952,7 +2012,7 @@
pStore->pDock->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 1;
h = setup_vertical_widgets_position(1, pWindow->size.x + FRAME_WH + width,
- pWindow->size.y + WINDOW_TILE_HIGH + 17, 0, 0,
+ pWindow->size.y + WINDOW_TILE_HIGH + adj_size(17), 0, 0,
pHelpDlg->pBeginActiveWidgetList,
pHelpDlg->pEndActiveWidgetList);
@@ -1960,7 +2020,7 @@
{
setup_vertical_scrollbar_area(pHelpDlg->pScroll,
pWindow->size.x + FRAME_WH,
- pWindow->size.y + WINDOW_TILE_HIGH + 17,
+ pWindow->size.y + WINDOW_TILE_HIGH + adj_size(17),
h, FALSE);
}
}
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/inteldlg.c
devel/client/gui-sdl/inteldlg.c
--- devel_distclean/client/gui-sdl/inteldlg.c 2005-10-18 00:31:09.000000000
+0200
+++ devel/client/gui-sdl/inteldlg.c 2005-11-15 06:52:44.000000000 +0100
@@ -85,14 +85,14 @@
return;
}
- h = WINDOW_TILE_HIGH + 3 + FRAME_WH;
+ h = WINDOW_TILE_HIGH + adj_size(3) + FRAME_WH;
pIntel_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
- pStr = create_str16_from_char(_("Foreign Intelligence Report") , 12);
+ pStr = create_str16_from_char(_("Foreign Intelligence Report") ,
adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 10, 10, WF_DRAW_THEME_TRANSPARENT);
+ pWindow = create_window(NULL, pStr, adj_size(10), adj_size(10),
WF_DRAW_THEME_TRANSPARENT);
pWindow->action = intel_window_dlg_callback;
set_wstate(pWindow , FC_WS_NORMAL);
@@ -104,7 +104,7 @@
/* exit button */
pBuf = create_themeicon(pTheme->Small_CANCEL_Icon, pWindow->dst,
WF_DRAW_THEME_TRANSPARENT);
- w += pBuf->size.w + 10;
+ w += pBuf->size.w + adj_size(10);
pBuf->action = exit_intel_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
@@ -112,7 +112,7 @@
add_to_gui_list(ID_BUTTON, pBuf);
/* ---------- */
- pLogo = GET_SURF(get_nation_by_idx(pPlayer->nation)->flag_sprite);
+ pLogo = GET_SURF(get_nation_flag_sprite(tileset, pPlayer->nation));
pLogo = make_flag_surface_smaler(pLogo);
pText1 = ZoomSurface(pLogo, 4.0 , 4.0, 1);
@@ -130,7 +130,7 @@
my_snprintf(cBuf, sizeof(cBuf),
_("Intelligence Information about %s Spaceship"),
get_nation_name(pPlayer->nation));
- pBuf->string16 = create_str16_from_char(cBuf, 12);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(12));
add_to_gui_list(ID_ICON, pBuf);
@@ -139,20 +139,20 @@
_("Intelligence Information for the %s Empire"),
get_nation_name(pPlayer->nation));
- pStr = create_str16_from_char(cBuf, 14);
+ pStr = create_str16_from_char(cBuf, adj_font(14));
pStr->style |= TTF_STYLE_BOLD;
pStr->render = 3;
pStr->bgcol.unused = 128;
pText1 = create_text_surf_from_str16(pStr);
SDL_SetAlpha(pText1, 0x0, 0x0);
- w = MAX(w, pText1->w + 20);
- h += pText1->h + 20;
+ w = MAX(w, pText1->w + adj_size(20));
+ h += pText1->h + adj_size(20);
/* ---------- */
pCapital = find_palace(pPlayer);
- change_ptsize16(pStr, 10);
+ change_ptsize16(pStr, adj_font(10));
pStr->style &= ~TTF_STYLE_BOLD;
my_snprintf(cBuf, sizeof(cBuf),
_("Ruler: %s %s Government: %s\nCapital: %s Gold: %d\nTax: %d%%"
@@ -161,17 +161,17 @@
pPlayer->name, get_government_name(pPlayer->government),
(!pCapital) ? _("(Unknown)") : pCapital->name, pPlayer->economic.gold,
pPlayer->economic.tax, pPlayer->economic.science, pPlayer->economic.luxury,
- get_tech_name(pPlayer, pPlayer->research.researching),
- pPlayer->research.bulbs_researched, total_bulbs_required(pPlayer));
+ get_tech_name(pPlayer, get_player_research(pPlayer)->researching),
+ get_player_research(pPlayer)->bulbs_researched,
total_bulbs_required(pPlayer));
copy_chars_to_string16(pStr, cBuf);
pInfo = create_text_surf_from_str16(pStr);
SDL_SetAlpha(pInfo, 0x0, 0x0);
- w = MAX(w, pLogo->w + 10 + pInfo->w + 20);
- h += MAX(pLogo->h + 20, pInfo->h + 20);
+ w = MAX(w, pLogo->w + adj_size(10) + pInfo->w + adj_size(20));
+ h += MAX(pLogo->h + adj_size(20), pInfo->h + adj_size(20));
/* ---------- */
- col = w / (GET_SURF(advances[A_FIRST].sprite)->w + 4);
+ col = w / (GET_SURF(get_tech_sprite(tileset, A_FIRST))->w + adj_size(4));
n = 0;
pLast = pBuf;
for(i = A_FIRST; i<game.control.num_tech_types; i++) {
@@ -179,12 +179,12 @@
tech_is_available(game.player_ptr, i) &&
get_invention(game.player_ptr, i) != TECH_KNOWN) {
- pBuf = create_icon2(GET_SURF(advances[i].sprite), pWindow->dst,
+ pBuf = create_icon2(GET_SURF(get_tech_sprite(tileset, i)), pWindow->dst,
(WF_DRAW_THEME_TRANSPARENT|WF_WIDGET_HAS_INFO_LABEL|WF_FREE_STRING));
pBuf->action = tech_callback;
set_wstate(pBuf, FC_WS_NORMAL);
- pBuf->string16 = create_str16_from_char(advances[i].name, 12);
+ pBuf->string16 = create_str16_from_char(advances[i].name, adj_font(12));
add_to_gui_list(ID_ICON, pBuf);
@@ -204,13 +204,13 @@
if(n > 2 * col) {
pIntel_Dlg->pActiveWidgetList = pLast->prev;
count = create_vertical_scrollbar(pIntel_Dlg, col, 2, TRUE, TRUE);
- h += (2 * pBuf->size.h + 10);
+ h += (2 * pBuf->size.h + adj_size(10));
} else {
count = 0;
if(n > col) {
h += pBuf->size.h;
}
- h += (10 + pBuf->size.h);
+ h += (adj_size(10) + pBuf->size.h);
}
w = MAX(w, col * pBuf->size.w + count + DOUBLE_FRAME_WH);
@@ -236,30 +236,30 @@
pBuf->size.y = pWindow->size.y + 1;
dst.x = (pWindow->size.w - pText1->w) / 2;
- dst.y = WINDOW_TILE_HIGH + 12;
+ dst.y = WINDOW_TILE_HIGH + adj_size(12);
SDL_BlitSurface(pText1, NULL, pWindow->theme, &dst);
- dst.y += pText1->h + 10;
+ dst.y += pText1->h + adj_size(10);
FREESURFACE(pText1);
/* space ship button */
pBuf = pBuf->prev;
- dst.x = (pWindow->size.w - (pBuf->size.w + 10 + pInfo->w)) / 2;
+ dst.x = (pWindow->size.w - (pBuf->size.w + adj_size(10) + pInfo->w)) / 2;
pBuf->size.x = pWindow->size.x + dst.x;
pBuf->size.y = pWindow->size.y + dst.y;
- dst.x += pBuf->size.w + 10;
+ dst.x += pBuf->size.w + adj_size(10);
SDL_BlitSurface(pInfo, NULL, pWindow->theme, &dst);
- dst.y += pInfo->h + 10;
+ dst.y += pInfo->h + adj_size(10);
FREESURFACE(pInfo);
/* --------------------- */
if(n) {
- dst.x = FRAME_WH + 5;
+ dst.x = FRAME_WH + adj_size(5);
SDL_BlitSurface(pText2, NULL, pWindow->theme, &dst);
- dst.y += pText2->h + 2;
+ dst.y += pText2->h + adj_size(2);
FREESURFACE(pText2);
setup_vertical_widgets_position(col,
diff -u -r -b -B -X devel/diff_ignore
devel_distclean/client/gui-sdl/Makefile.am devel/client/gui-sdl/Makefile.am
--- devel_distclean/client/gui-sdl/Makefile.am 2005-10-15 20:41:57.000000000
+0200
+++ devel/client/gui-sdl/Makefile.am 2005-11-15 06:52:44.000000000 +0100
@@ -81,6 +81,7 @@
resources.h \
spaceshipdlg.c \
spaceshipdlg.h \
+ themes.c \
wldlg.c \
wldlg.h \
gui_string.c \
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/mapctrl.c
devel/client/gui-sdl/mapctrl.c
--- devel_distclean/client/gui-sdl/mapctrl.c 2005-10-16 21:49:00.000000000
+0200
+++ devel/client/gui-sdl/mapctrl.c 2005-11-15 06:52:44.000000000 +0100
@@ -45,6 +45,7 @@
#include "chatline.h"
#include "citydlg.h"
+#include "optiondlg.h"
#include "civclient.h"
#include "clinet.h"
#include "climisc.h"
@@ -65,8 +66,11 @@
#include "cma_core.h"
#include "wldlg.h"
#include "cityrep.h"
-#include "mapctrl.h"
#include "plrdlg.h"
+#include "overview_common.h"
+#include "log.h"
+
+#include "mapctrl.h"
extern int OVERVIEW_START_X;
extern int OVERVIEW_START_Y;
@@ -77,13 +81,10 @@
static struct SMALL_DLG *pScall_UnitInfo_Dlg = NULL;
static struct ADVANCED_DLG *pUnitInfo_Dlg = NULL;
-#define DEFAULT_MINI_MAP_W 196 /* 160 + BLOCK_W + DOUBLE_FRAME_WH */
-#define DEFAULT_MINI_MAP_H 106 /* 100 + DOUBLE_FRAME_WH */
-
-static int MINI_MAP_W = DEFAULT_MINI_MAP_W;
-static int MINI_MAP_H = DEFAULT_MINI_MAP_H;
-static int UNITS_W = DEFAULT_UNITS_W;
-static int UNITS_H = DEFAULT_UNITS_H;
+int MINI_MAP_W = DEFAULT_MINI_MAP_W;
+int MINI_MAP_H = DEFAULT_MINI_MAP_H;
+int UNITS_W = DEFAULT_UNITS_W;
+int UNITS_H = DEFAULT_UNITS_H;
static int INFO_WIDTH, INFO_HEIGHT = 0, INFO_WIDTH_MIN, INFO_HEIGHT_MIN;
@@ -121,11 +122,11 @@
popup_players_nations_dialog();
break;
default:
- popup_players_dialog();
+ popup_players_dialog(true);
break;
}
} else {
- popup_players_dialog();
+ popup_players_dialog(true);
}
return -1;
}
@@ -270,9 +271,9 @@
/* blit right vertical frame */
pBuf_Surf = ResizeSurface(pTheme->FR_Vert, pTheme->FR_Vert->w,
- pBuf->size.h - DOUBLE_FRAME_WH + 2, 1);
+ pBuf->size.h - DOUBLE_FRAME_WH + adj_size(2),
1);
- window_area.y += 2;
+ window_area.y += adj_size(2);
window_area.x = Main.gui->w - FRAME_WH;
SDL_BlitSurface(pBuf_Surf, NULL , pBuf->dst, &window_area);
FREESURFACE(pBuf_Surf);
@@ -376,7 +377,7 @@
set_new_mini_map_window_pos();
/* blit part of map window */
- src.x = pMap->theme->w - HIDDEN_MINI_MAP_W;
+ src.x = pMap->theme->w - HIDDEN_MINI_MAP_W - FRAME_WH;
src.y = 0;
src.w = HIDDEN_MINI_MAP_W;
src.h = pMap->theme->h;
@@ -385,9 +386,9 @@
/* blit left vertical frame theme */
pBuf_Surf = ResizeSurface(pTheme->FR_Vert, pTheme->FR_Vert->w,
- pMap->size.h - DOUBLE_FRAME_WH + 2, 1);
+ pMap->size.h - DOUBLE_FRAME_WH + adj_size(2),
1);
- map_area.y += 2;
+ map_area.y += adj_size(2);
SDL_BlitSurface(pBuf_Surf, NULL , pMap->dst, &map_area);
FREESURFACE(pBuf_Surf);
@@ -422,6 +423,14 @@
real_redraw_icon(pMap);
}
+ #ifdef SMALL_SCREEN
+ /* options */
+ pMap = pMap->prev;
+ if ((get_wflags(pMap) & WF_HIDDEN) != WF_HIDDEN) {
+ real_redraw_icon(pMap);
+ }
+ #endif
+
/* ID_TOGGLE_MAP_WINDOW_BUTTON */
pMap = pMap->prev;
real_redraw_icon(pMap);
@@ -481,7 +490,7 @@
popdown_meswin_dialog();
copy_chars_to_string16(pWidget->string16, _("Show Log (F10)"));
} else {
- popup_meswin_dialog();
+ popup_meswin_dialog(true);
copy_chars_to_string16(pWidget->string16, _("Hide Log (F10)"));
}
@@ -517,11 +526,11 @@
{
int w = OVERVIEW_TILE_WIDTH * map.xsize;
int h = OVERVIEW_TILE_HEIGHT * map.ysize;
- int current_w = pMiniMap_Window->size.w - BLOCK_W - DOUBLE_FRAME_WH;
+ int current_w = pMiniMap_Window->size.w - BLOCKM_W - DOUBLE_FRAME_WH;
int current_h = pMiniMap_Window->size.h - DOUBLE_FRAME_WH;
- if ((((current_w > DEFAULT_MINI_MAP_W - BLOCK_W - DOUBLE_FRAME_WH)
- || (w > DEFAULT_MINI_MAP_W - BLOCK_W - DOUBLE_FRAME_WH)) && (current_w !=
w)) ||
+ if ((((current_w > DEFAULT_MINI_MAP_W - BLOCKM_W - DOUBLE_FRAME_WH)
+ || (w > DEFAULT_MINI_MAP_W - BLOCKM_W - DOUBLE_FRAME_WH)) && (current_w !=
w)) ||
(((current_h > DEFAULT_MINI_MAP_H - DOUBLE_FRAME_WH)
|| (h > DEFAULT_MINI_MAP_H - DOUBLE_FRAME_WH)) && (current_h != h))) {
Remake_MiniMap(w, h);
@@ -537,7 +546,7 @@
{
redraw_widget(pWidget);
sdl_dirty_rect(pWidget->size);
- if (((OVERVIEW_TILE_WIDTH + 1) * map.xsize + BLOCK_W + DOUBLE_FRAME_WH) <=
+ if (((OVERVIEW_TILE_WIDTH + 1) * map.xsize + BLOCKM_W + DOUBLE_FRAME_WH) <=
pUnits_Info_Window->size.x) {
char cBuf[4];
my_snprintf(cBuf, sizeof(cBuf), "%d", OVERVIEW_TILE_WIDTH);
@@ -620,21 +629,21 @@
return;
}
- pStr = create_str16_from_char(_("Single Tile Width"), 12);
+ pStr = create_str16_from_char(_("Single Tile Width"), adj_font(12));
pText1 = create_text_surf_from_str16(pStr);
- w = MAX(w, pText1->w + 30);
+ w = MAX(w, pText1->w + adj_size(30));
copy_chars_to_string16(pStr, _("Single Tile Height"));
pText2 = create_text_surf_from_str16(pStr);
- w = MAX(w, pText2->w + 30);
+ w = MAX(w, pText2->w + adj_size(30));
FREESTRING16(pStr);
pScall_MiniMap_Dlg = MALLOC(sizeof(struct SMALL_DLG));
/* create window */
- pStr = create_str16_from_char(_("Scale Minimap"), 12);
+ pStr = create_str16_from_char(_("Scale Minimap"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 10, 10, 0);
+ pWindow = create_window(NULL, pStr, adj_size(10), adj_size(10), 0);
pWindow->action = move_scale_minmap_dlg_callback;
set_wstate(pWindow, FC_WS_NORMAL);
w = MAX(w, pWindow->size.w);
@@ -649,11 +658,11 @@
add_to_gui_list(ID_BUTTON, pBuf);
my_snprintf(cBuf, sizeof(cBuf), "%d" , OVERVIEW_TILE_WIDTH);
- pStr = create_str16_from_char(cBuf, 24);
+ pStr = create_str16_from_char(cBuf, adj_font(24));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr, WF_DRAW_THEME_TRANSPARENT);
- pBuf->size.w = MAX(50, pBuf->size.w);
- h += pBuf->size.h + 5;
+ pBuf->size.w = MAX(adj_size(50), pBuf->size.w);
+ h += pBuf->size.h + adj_size(5);
add_to_gui_list(ID_LABEL, pBuf);
pBuf = create_themeicon_button(pTheme->R_ARROW_Icon, pWindow->dst, NULL, 0);
@@ -671,11 +680,11 @@
add_to_gui_list(ID_BUTTON, pBuf);
my_snprintf(cBuf, sizeof(cBuf), "%d" , OVERVIEW_TILE_HEIGHT);
- pStr = create_str16_from_char(cBuf, 24);
+ pStr = create_str16_from_char(cBuf, adj_font(24));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr, WF_DRAW_THEME_TRANSPARENT);
- pBuf->size.w = MAX(50, pBuf->size.w);
- h += pBuf->size.h + 20;
+ pBuf->size.w = MAX(adj_size(50), pBuf->size.w);
+ h += pBuf->size.h + adj_size(20);
add_to_gui_list(ID_LABEL, pBuf);
pBuf = create_themeicon_button(pTheme->R_ARROW_Icon, pWindow->dst, NULL, 0);
@@ -683,21 +692,21 @@
set_wstate(pBuf, FC_WS_NORMAL);
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
add_to_gui_list(ID_BUTTON, pBuf);
- w = MAX(w , pBuf->size.w * 2 + pBuf->next->size.w + 20);
+ w = MAX(w , pBuf->size.w * 2 + pBuf->next->size.w + adj_size(20));
/* ------------ */
- pStr = create_str16_from_char(_("Exit"), 12);
+ pStr = create_str16_from_char(_("Exit"), adj_font(12));
pBuf = create_themeicon_button(pTheme->CANCEL_Icon,
pWindow->dst, pStr, 0);
pBuf->action = popdown_scale_minmap_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pScall_MiniMap_Dlg->pBeginWidgetList = pBuf;
add_to_gui_list(ID_BUTTON, pBuf);
- h += pBuf->size.h + 10;
- w = MAX(w, pBuf->size.w + 20);
+ h += pBuf->size.h + adj_size(10);
+ w = MAX(w, pBuf->size.w + adj_size(20));
/* ------------ */
- h += 20;
+ h += adj_size(20);
if (Main.event.motion.x + w > pWindow->dst->w)
{
@@ -735,12 +744,12 @@
resize_window(pWindow, NULL,
get_game_colorRGB(COLOR_STD_BACKGROUND_BROWN), w, h);
- blit_entire_src(pText1, pWindow->theme, 15, WINDOW_TILE_HIGH + 5);
+ blit_entire_src(pText1, pWindow->theme, 15, WINDOW_TILE_HIGH + adj_size(5));
FREESURFACE(pText1);
/* width label */
pBuf = pWindow->prev->prev;
- pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 20;
+ pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(20);
pBuf->size.x = pWindow->size.x + (pWindow->size.w - pBuf->size.w) / 2;
/* width left button */
@@ -753,10 +762,10 @@
/* height label */
pBuf = pBuf->prev->prev->prev;
- pBuf->size.y = pBuf->next->next->next->size.y +
pBuf->next->next->next->size.h + 20;
+ pBuf->size.y = pBuf->next->next->next->size.y +
pBuf->next->next->next->size.h + adj_size(20);
pBuf->size.x = pWindow->size.x + (pWindow->size.w - pBuf->size.w) / 2;
- blit_entire_src(pText2, pWindow->theme, 15, pBuf->size.y - pWindow->size.y -
pText2->h - 2);
+ blit_entire_src(pText2, pWindow->theme, adj_size(15), pBuf->size.y -
pWindow->size.y - pText2->h - adj_size(2));
FREESURFACE(pText2);
/* height left button */
@@ -770,7 +779,7 @@
/* exit button */
pBuf = pBuf->prev->prev;
pBuf->size.x = pWindow->size.x + (pWindow->size.w - pBuf->size.w) / 2;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - 10;
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h -
adj_size(10);
/* -------------------- */
redraw_group(pScall_MiniMap_Dlg->pBeginWidgetList, pWindow, 0);
@@ -802,11 +811,11 @@
{
int w = INFO_WIDTH * map.xsize;
int h = INFO_HEIGHT * map.ysize;
- int current_w = pUnits_Info_Window->size.w - BLOCK_W - DOUBLE_FRAME_WH;
+ int current_w = pUnits_Info_Window->size.w - BLOCKU_W - DOUBLE_FRAME_WH;
int current_h = pUnits_Info_Window->size.h - DOUBLE_FRAME_WH;
- if ((((current_w > DEFAULT_UNITS_W - BLOCK_W - DOUBLE_FRAME_WH)
- || (w > DEFAULT_UNITS_W - BLOCK_W - DOUBLE_FRAME_WH)) && (current_w != w))
||
+ if ((((current_w > DEFAULT_UNITS_W - BLOCKU_W - DOUBLE_FRAME_WH)
+ || (w > DEFAULT_UNITS_W - BLOCKU_W - DOUBLE_FRAME_WH)) && (current_w != w))
||
(((current_h > DEFAULT_UNITS_H - DOUBLE_FRAME_WH)
|| (h > DEFAULT_UNITS_H - DOUBLE_FRAME_WH)) && (current_h != h))) {
Remake_UnitInfo(w, h);
@@ -823,7 +832,7 @@
redraw_widget(pWidget);
sdl_dirty_rect(pWidget->size);
if (Main.gui->w -
- ((INFO_WIDTH + 1) * map.xsize + BLOCK_W + DOUBLE_FRAME_WH) >=
+ ((INFO_WIDTH + 1) * map.xsize + BLOCKU_W + DOUBLE_FRAME_WH) >=
pMiniMap_Window->size.x + pMiniMap_Window->size.w) {
INFO_WIDTH++;
resize_unit_info();
@@ -881,22 +890,22 @@
return;
}
- pStr = create_str16_from_char(_("Width"), 12);
+ pStr = create_str16_from_char(_("Width"), adj_font(12));
pText1 = create_text_surf_from_str16(pStr);
- w = MAX(w, pText1->w + 30);
- h += MAX(20, pText1->h + 4);
+ w = MAX(w, pText1->w + adj_size(30));
+ h += MAX(adj_size(20), pText1->h + adj_size(4));
copy_chars_to_string16(pStr, _("Height"));
pText2 = create_text_surf_from_str16(pStr);
- w = MAX(w, pText2->w + 30);
- h += MAX(20, pText2->h + 4);
+ w = MAX(w, pText2->w + adj_size(30));
+ h += MAX(adj_size(20), pText2->h + adj_size(4));
FREESTRING16(pStr);
pScall_UnitInfo_Dlg = MALLOC(sizeof(struct SMALL_DLG));
/* create window */
- pStr = create_str16_from_char(_("Scale Unit Info"), 12);
+ pStr = create_str16_from_char(_("Scale Unit Info"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 10, 10, 0);
+ pWindow = create_window(NULL, pStr, adj_size(10), adj_size(10), 0);
pWindow->action = move_scale_unitinfo_dlg_callback;
set_wstate(pWindow, FC_WS_NORMAL);
w = MAX(w, pWindow->size.w);
@@ -923,25 +932,25 @@
set_wstate(pBuf, FC_WS_NORMAL);
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
add_to_gui_list(ID_BUTTON, pBuf);
- h += pBuf->size.h + 10;
+ h += pBuf->size.h + adj_size(10);
pBuf = create_themeicon_button(pTheme->R_ARROW_Icon, pWindow->dst, NULL, 0);
pBuf->action = up_info_height_callback;
set_wstate(pBuf, FC_WS_NORMAL);
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
add_to_gui_list(ID_BUTTON, pBuf);
- w = MAX(w , pBuf->size.w * 2 + 20);
+ w = MAX(w , pBuf->size.w * 2 + adj_size(20));
/* ------------ */
- pStr = create_str16_from_char(_("Exit"), 12);
+ pStr = create_str16_from_char(_("Exit"), adj_font(12));
pBuf = create_themeicon_button(pTheme->CANCEL_Icon,
pWindow->dst, pStr, 0);
pBuf->action = popdown_scale_unitinfo_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pScall_UnitInfo_Dlg->pBeginWidgetList = pBuf;
add_to_gui_list(ID_BUTTON, pBuf);
- h += pBuf->size.h + 10;
- w = MAX(w, pBuf->size.w + 20);
+ h += pBuf->size.h + adj_size(10);
+ w = MAX(w, pBuf->size.w + adj_size(20));
/* ------------ */
if (Main.event.motion.x + w > pWindow->dst->w)
@@ -982,10 +991,10 @@
/* width left button */
pBuf = pWindow->prev;
- pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + MAX(20, pText1->h + 4);
+ pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + MAX(adj_size(20),
pText1->h + adj_size(4));
pBuf->size.x = pWindow->size.x + (pWindow->size.w - pBuf->size.w * 2) / 2;
- blit_entire_src(pText1, pWindow->theme, 15, pBuf->size.y
- - pWindow->size.y - pText1->h - 2);
+ blit_entire_src(pText1, pWindow->theme, adj_size(15), pBuf->size.y
+ - pWindow->size.y - pText1->h -
adj_size(2));
FREESURFACE(pText1);
/* width right button */
@@ -995,10 +1004,10 @@
/* height left button */
pBuf = pBuf->prev->prev;
pBuf->size.y = pBuf->next->next->size.y +
- pBuf->next->next->size.h + MAX(20, pText2->h + 4);
+ pBuf->next->next->size.h + MAX(adj_size(20), pText2->h
+ adj_size(4));
pBuf->size.x = pWindow->size.x + (pWindow->size.w - pBuf->size.w * 2) / 2;
- blit_entire_src(pText2, pWindow->theme, 15, pBuf->size.y - pWindow->size.y -
pText2->h - 2);
+ blit_entire_src(pText2, pWindow->theme, adj_size(15), pBuf->size.y -
pWindow->size.y - pText2->h - adj_size(2));
FREESURFACE(pText2);
/* height right button */
@@ -1008,10 +1017,10 @@
/* exit button */
pBuf = pBuf->prev->prev;
pBuf->size.x = pWindow->size.x + (pWindow->size.w - pBuf->size.w) / 2;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - 10;
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h -
adj_size(10);
if (!INFO_HEIGHT) {
- INFO_WIDTH_MIN = (DEFAULT_UNITS_W - BLOCK_W - DOUBLE_FRAME_WH) / map.xsize;
+ INFO_WIDTH_MIN = (DEFAULT_UNITS_W - BLOCKU_W - DOUBLE_FRAME_WH) /
map.xsize;
if (INFO_WIDTH_MIN == 1) {
INFO_WIDTH_MIN = 0;
}
@@ -1035,7 +1044,10 @@
{
switch(Main.event.button.button) {
case SDL_BUTTON_RIGHT:
+ /* FIXME: scaling needs to be fixed */
+#if 0
popup_minimap_scale_dialog();
+#endif
break;
default:
if ((SDL_Client_Flags & CF_MINI_MAP_SHOW) &&
@@ -1047,12 +1059,17 @@
(Main.event.motion.y <
Main.gui->h - pMiniMap_Window->size.h + OVERVIEW_START_Y +
OVERVIEW_TILE_HEIGHT * map.ysize)) {
- center_tile_mapcanvas(
- (Main.event.motion.x - OVERVIEW_START_X) / OVERVIEW_TILE_WIDTH,
- (Main.event.motion.y -
- (Main.gui->h - pMiniMap_Window->size.h + OVERVIEW_START_Y)) /
- OVERVIEW_TILE_HEIGHT);
+
+ int map_x, map_y;
+
+ overview_to_map_pos(&map_x, &map_y,
+ Main.event.motion.x - OVERVIEW_START_X, Main.event.motion.y
-
+ (Main.gui->h - pMiniMap_Window->size.h +
OVERVIEW_START_Y));
+
+ center_tile_mapcanvas(map_pos_to_tile(map_x, map_y));
+
}
+
break;
}
return -1;
@@ -1088,44 +1105,47 @@
**************************************************************************/
void set_new_units_window_pos(void)
{
- int new_x;
struct GUI *pUnit_Window = pUnits_Info_Window;
+ struct GUI *pWidget;
if (SDL_Client_Flags & CF_UNIT_INFO_SHOW) {
pUnit_Window->size.x = Main.screen->w - pUnit_Window->size.w;
} else {
- pUnit_Window->size.x = Main.screen->w - BLOCK_W - DOUBLE_FRAME_WH;
+ pUnit_Window->size.x = Main.screen->w - BLOCKU_W - DOUBLE_FRAME_WH;
}
pUnit_Window->size.y = Main.screen->h - pUnit_Window->size.h;
- new_x = pUnit_Window->size.x + FRAME_WH + 2;
pUnit_Window->dst = Main.gui;
/* ID_ECONOMY */
- pUnit_Window = pTax_Button;
- pUnit_Window->size.x = new_x + 3;
- pUnit_Window->size.y = Main.screen->h - UNITS_H + FRAME_WH + 2;
- pUnit_Window->dst = Main.gui;
+ pWidget = pTax_Button;
+ pWidget->size.x = pUnit_Window->size.x + FRAME_WH
+ + (BLOCKU_W - pWidget->size.w)/2;
+
+ pWidget->size.y = Main.screen->h - UNITS_H + FRAME_WH + adj_size(2);
+ pWidget->dst = Main.gui;
/* ID_RESEARCH */
- pUnit_Window = pUnit_Window->prev;
- pUnit_Window->size.x = new_x + 3;
- pUnit_Window->size.y = Main.screen->h - UNITS_H + FRAME_WH + 2 +
- pUnit_Window->size.h;
- pUnit_Window->dst = Main.gui;
+ pWidget = pWidget->prev;
+ pWidget->size.x = pUnit_Window->size.x + FRAME_WH
+ + (BLOCKU_W - pWidget->size.w)/2;
+ pWidget->size.y = Main.screen->h - UNITS_H + FRAME_WH + pWidget->size.h +
adj_size(2);
+ pWidget->dst = Main.gui;
/* ID_REVOLUTION */
- pUnit_Window = pUnit_Window->prev;
- pUnit_Window->size.x = new_x + 3;
- pUnit_Window->size.y = Main.screen->h - UNITS_H + FRAME_WH + 2 +
- (pUnit_Window->size.h << 1);
- pUnit_Window->dst = Main.gui;
+ pWidget = pWidget->prev;
+ pWidget->size.x = pUnit_Window->size.x + FRAME_WH
+ + (BLOCKU_W - pWidget->size.w)/2;
+ pWidget->size.y = Main.screen->h - UNITS_H + FRAME_WH +
+ (pWidget->size.h << 1) +
adj_size(2);
+ pWidget->dst = Main.gui;
/* ID_TOGGLE_UNITS_WINDOW_BUTTON */
- pUnit_Window = pUnit_Window->prev;
- pUnit_Window->size.x = new_x;
- pUnit_Window->size.y = Main.screen->h - FRAME_WH - pUnit_Window->size.h - 2;
- pUnit_Window->dst = Main.gui;
+ pWidget = pWidget->prev;
+ pWidget->size.x = pUnit_Window->size.x + FRAME_WH
+ + (BLOCKU_W - pWidget->size.w)/2;
+ pWidget->size.y = Main.screen->h - FRAME_WH - pWidget->size.h - adj_size(2);
+ pWidget->dst = Main.gui;
}
/**************************************************************************
@@ -1138,9 +1158,9 @@
struct GUI *pMM_Window = pMiniMap_Window;
if (SDL_Client_Flags & CF_MINI_MAP_SHOW) {
- new_x = pMM_Window->size.w - BLOCK_W;
+ new_x = pMM_Window->size.w - BLOCKM_W;
} else {
- new_x = FRAME_WH + 3;
+ new_x = FRAME_WH;
}
pMM_Window->size.y = Main.screen->h - pMM_Window->size.h;
@@ -1148,21 +1168,21 @@
/* ID_NEW_TURN */
pMM_Window = pMM_Window->prev;
- pMM_Window->size.x = new_x;
- pMM_Window->size.y = Main.screen->h - MINI_MAP_H + FRAME_WH + 2;
+ pMM_Window->size.x = new_x + pMM_Window->size.w;
+ pMM_Window->size.y = Main.screen->h - MINI_MAP_H + FRAME_WH + adj_size(2);
pMM_Window->dst = Main.gui;
/* PLAYERS BUTTON */
pMM_Window = pMM_Window->prev;
- pMM_Window->size.x = new_x;
- pMM_Window->size.y = Main.screen->h - MINI_MAP_H + FRAME_WH + 2 +
+ pMM_Window->size.x = new_x + pMM_Window->size.w;
+ pMM_Window->size.y = Main.screen->h - MINI_MAP_H + FRAME_WH + adj_size(2) +
pMM_Window->size.h;
pMM_Window->dst = Main.gui;
/* ID_FIND_CITY */
pMM_Window = pMM_Window->prev;
- pMM_Window->size.x = new_x;
- pMM_Window->size.y = Main.screen->h - MINI_MAP_H + FRAME_WH + 2 +
+ pMM_Window->size.x = new_x + pMM_Window->size.w;
+ pMM_Window->size.y = Main.screen->h - MINI_MAP_H + FRAME_WH + adj_size(2) +
pMM_Window->size.h * 2;
pMM_Window->dst = Main.gui;
@@ -1170,27 +1190,34 @@
/* UNITS BUTTON */
pMM_Window = pMM_Window->prev;
pMM_Window->size.x = new_x;
- pMM_Window->size.y = Main.screen->h - MINI_MAP_H + FRAME_WH + 2 +
- pMM_Window->size.h * 3;
+ pMM_Window->size.y = Main.screen->h - MINI_MAP_H + FRAME_WH + adj_size(2);
pMM_Window->dst = Main.gui;
/* ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON */
pMM_Window = pMM_Window->prev;
pMM_Window->size.x = new_x;
- pMM_Window->size.y = Main.screen->h - MINI_MAP_H + FRAME_WH + 2 +
- pMM_Window->size.h * 4;
+ pMM_Window->size.y = Main.screen->h - MINI_MAP_H + FRAME_WH + adj_size(2) +
+ pMM_Window->size.h;
/* Toggle minimap mode */
pMM_Window = pMM_Window->prev;
pMM_Window->size.x = new_x;
- pMM_Window->size.y = Main.screen->h - MINI_MAP_H + FRAME_WH + 2 +
- pMM_Window->size.h * 5;
+ pMM_Window->size.y = Main.screen->h - MINI_MAP_H + FRAME_WH + adj_size(2) +
+ pMM_Window->size.h * 2;
+ #ifdef SMALL_SCREEN
/* ID_TOGGLE_MAP_WINDOW_BUTTON */
pMM_Window = pMM_Window->prev;
pMM_Window->size.x = new_x;
- pMM_Window->size.y = Main.screen->h - FRAME_WH - pMM_Window->size.h - 2;
+ pMM_Window->size.y = Main.screen->h - FRAME_WH - pMM_Window->size.h -
adj_size(2);
+ pMM_Window->dst = Main.gui;
+ #endif
+
+ /* ID_TOGGLE_MAP_WINDOW_BUTTON */
+ pMM_Window = pMM_Window->prev;
+ pMM_Window->size.x = new_x + pMM_Window->size.w;
+ pMM_Window->size.y = Main.screen->h - FRAME_WH - pMM_Window->size.h -
adj_size(2);
pMM_Window->dst = Main.gui;
}
@@ -1199,10 +1226,10 @@
SDL_Surface *pSurf;
struct GUI *pWidget = pMiniMap_Window;
- if(w < DEFAULT_MINI_MAP_W - BLOCK_W - DOUBLE_FRAME_WH) {
+ if(w < DEFAULT_MINI_MAP_W - BLOCKM_W - DOUBLE_FRAME_WH) {
w = DEFAULT_MINI_MAP_W;
} else {
- w += BLOCK_W + DOUBLE_FRAME_WH;
+ w += BLOCKM_W + DOUBLE_FRAME_WH;
}
if(h < DEFAULT_MINI_MAP_H - DOUBLE_FRAME_WH) {
@@ -1228,7 +1255,7 @@
draw_frame(pWidget->theme, 0, 0, pWidget->size.w, pWidget->size.h);
- pSurf = ResizeSurface(pTheme->Block, BLOCK_W,
+ pSurf = ResizeSurface(pTheme->Block, BLOCKM_W,
pWidget->size.h - DOUBLE_FRAME_WH, 1);
blit_entire_src(pSurf, pWidget->theme,
@@ -1240,26 +1267,26 @@
/* new turn button */
pWidget = pWidget->prev;
FREESURFACE(pWidget->gfx);
- pWidget->size.x = w - BLOCK_W;
- pWidget->size.y = pWidget->dst->h - h + FRAME_WH + 2;
+ pWidget->size.x = w - BLOCKM_W + pWidget->size.w;
+ pWidget->size.y = pWidget->dst->h - h + FRAME_WH + adj_size(2);
/* players */
pWidget = pWidget->prev;
FREESURFACE(pWidget->gfx);
- pWidget->size.x = w - BLOCK_W;
- pWidget->size.y = pWidget->dst->h - h + FRAME_WH + 2 + pWidget->size.h;
+ pWidget->size.x = w - BLOCKM_W + pWidget->size.w;
+ pWidget->size.y = pWidget->dst->h - h + FRAME_WH + adj_size(2) +
pWidget->size.h;
/* find city */
pWidget = pWidget->prev;
FREESURFACE(pWidget->gfx);
- pWidget->size.x = w - BLOCK_W;
- pWidget->size.y = pWidget->dst->h - h + FRAME_WH + 2 + pWidget->size.h * 2;
+ pWidget->size.x = w - BLOCKM_W + pWidget->size.w;
+ pWidget->size.y = pWidget->dst->h - h + FRAME_WH + adj_size(2) +
pWidget->size.h * 2;
/* units */
pWidget = pWidget->prev;
FREESURFACE(pWidget->gfx);
- pWidget->size.x = w - BLOCK_W;
- pWidget->size.y = pWidget->dst->h - h + FRAME_WH + 2 + pWidget->size.h * 3;
+ pWidget->size.x = w - BLOCKM_W;
+ pWidget->size.y = pWidget->dst->h - h + FRAME_WH + adj_size(2);
if(pWidget->size.y < pWidget->dst->h - pWidget->size.h * 2) {
clear_wflag(pWidget, WF_HIDDEN);
} else {
@@ -1269,8 +1296,8 @@
/* show/hide log */
pWidget = pWidget->prev;
FREESURFACE(pWidget->gfx);
- pWidget->size.x = w - BLOCK_W;
- pWidget->size.y = pWidget->dst->h - h + FRAME_WH + 2 + pWidget->size.h * 4;
+ pWidget->size.x = w - BLOCKM_W;
+ pWidget->size.y = pWidget->dst->h - h + FRAME_WH + adj_size(2) +
pWidget->size.h;
if(pWidget->size.y < pWidget->dst->h - pWidget->size.h * 2) {
clear_wflag(pWidget, WF_HIDDEN);
} else {
@@ -1280,35 +1307,42 @@
/* toggle minimap mode */
pWidget = pWidget->prev;
FREESURFACE(pWidget->gfx);
- pWidget->size.x = w - BLOCK_W;
- pWidget->size.y = pWidget->dst->h - h + FRAME_WH + 2 + pWidget->size.h * 5;
+ pWidget->size.x = w - BLOCKM_W;
+ pWidget->size.y = pWidget->dst->h - h + FRAME_WH + adj_size(2) +
pWidget->size.h * 2;
if(pWidget->size.y < pWidget->dst->h - pWidget->size.h * 2) {
clear_wflag(pWidget, WF_HIDDEN);
} else {
set_wflag(pWidget, WF_HIDDEN);
}
+ #ifdef SMALL_SCREEN
+ /* options */
+ pWidget = pWidget->prev;
+ FREESURFACE(pWidget->gfx);
+ pWidget->size.x = w - BLOCKM_W;
+ pWidget->size.y = pWidget->dst->h - FRAME_WH - pWidget->size.h - adj_size(2);
+ #endif
+
/* hide/show mini map */
pWidget = pWidget->prev;
FREESURFACE(pWidget->gfx);
- pWidget->size.x = w - BLOCK_W;
- pWidget->size.y = pWidget->dst->h - FRAME_WH - pWidget->size.h - 2;
+ pWidget->size.x = w - BLOCKM_W + pWidget->size.w;
+ pWidget->size.y = pWidget->dst->h - FRAME_WH - pWidget->size.h - adj_size(2);
MINI_MAP_W = w;
MINI_MAP_H = h;
-
}
static void Remake_UnitInfo(int w, int h)
{
SDL_Surface *pSurf;
- SDL_Rect area = {FRAME_WH + BLOCK_W, FRAME_WH , 0, 0};
+ SDL_Rect area = {FRAME_WH + BLOCKU_W, FRAME_WH , 0, 0};
struct GUI *pWidget = pUnits_Info_Window;
- if(w < DEFAULT_UNITS_W - BLOCK_W - DOUBLE_FRAME_WH) {
+ if(w < DEFAULT_UNITS_W - BLOCKU_W - DOUBLE_FRAME_WH) {
w = DEFAULT_UNITS_W;
} else {
- w += BLOCK_W + DOUBLE_FRAME_WH;
+ w += BLOCKU_W + DOUBLE_FRAME_WH;
}
if(h < DEFAULT_UNITS_H - DOUBLE_FRAME_WH) {
@@ -1334,13 +1368,13 @@
draw_frame(pWidget->theme, 0, 0, pWidget->size.w, pWidget->size.h);
- pSurf = ResizeSurface(pTheme->Block, BLOCK_W,
+ pSurf = ResizeSurface(pTheme->Block, BLOCKU_W,
pWidget->size.h - DOUBLE_FRAME_WH, 1);
blit_entire_src(pSurf, pWidget->theme, FRAME_WH, FRAME_WH);
FREESURFACE(pSurf);
- area.w = w - BLOCK_W - DOUBLE_FRAME_WH;
+ area.w = w - BLOCKU_W - DOUBLE_FRAME_WH;
area.h = h - DOUBLE_FRAME_WH;
SDL_FillRect(pWidget->theme, &area,
SDL_MapRGBA(pWidget->theme->format, 255, 255, 255, 128));
@@ -1350,25 +1384,29 @@
/* economy button */
pWidget = pTax_Button;
FREESURFACE(pWidget->gfx);
- pWidget->size.x = pWidget->dst->w - w + FRAME_WH + 5;
+ pWidget->size.x = pWidget->dst->w - w + FRAME_WH
+ + (BLOCKU_W - pWidget->size.w)/2;
pWidget->size.y = pWidget->dst->h - h + FRAME_WH + 2;
/* research button */
pWidget = pWidget->prev;
FREESURFACE(pWidget->gfx);
- pWidget->size.x = pWidget->dst->w - w + FRAME_WH + 5;
- pWidget->size.y = pWidget->dst->h - h + FRAME_WH + 2 + pWidget->size.h;
+ pWidget->size.x = pWidget->dst->w - w + FRAME_WH
+ + (BLOCKU_W - pWidget->size.w)/2;
+ pWidget->size.y = pWidget->dst->h - h + FRAME_WH + pWidget->size.h + 2;
/* revolution button */
pWidget = pWidget->prev;
FREESURFACE(pWidget->gfx);
- pWidget->size.x = pWidget->dst->w - w + FRAME_WH + 5;
- pWidget->size.y = pWidget->dst->h - h + FRAME_WH + 2 + pWidget->size.h * 2;
+ pWidget->size.x = pWidget->dst->w - w + FRAME_WH
+ + (BLOCKU_W - pWidget->size.w)/2;
+ pWidget->size.y = pWidget->dst->h - h + FRAME_WH + pWidget->size.h * 2 + 2;
/* show/hide unit's window button */
pWidget = pWidget->prev;
FREESURFACE(pWidget->gfx);
- pWidget->size.x = pWidget->dst->w - w + FRAME_WH + 2;
+ pWidget->size.x = pWidget->dst->w - w + FRAME_WH
+ + (BLOCKU_W - pWidget->size.w)/2;
pWidget->size.y = pWidget->dst->h - FRAME_WH - pWidget->size.h - 2;
UNITS_W = w;
@@ -1381,97 +1419,129 @@
**************************************************************************/
void Init_MapView(void)
{
- SDL_Rect area = {FRAME_WH + BLOCK_W, FRAME_WH ,
- UNITS_W - BLOCK_W - DOUBLE_FRAME_WH,
+ struct GUI *pWidget;
+
+ SDL_Rect unit_info_area = {FRAME_WH + BLOCKU_W, FRAME_WH ,
+ UNITS_W - BLOCKU_W - DOUBLE_FRAME_WH,
UNITS_H - DOUBLE_FRAME_WH};
+
SDL_Surface *pIcon_theme = NULL;
+ SDL_Surface *pSurf = NULL;
/* =================== Units Window ======================= */
pUnitInfo_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
- struct GUI *pBuf = create_window(Main.gui, create_string16(NULL, 0, 12),
+
+ pWidget = create_window(Main.gui, create_string16(NULL, 0, 12),
UNITS_W, UNITS_H, WF_DRAW_THEME_TRANSPARENT);
- pBuf->size.x = Main.screen->w - UNITS_W;
- pBuf->size.y = Main.screen->h - UNITS_H;
+ pWidget->size.x = Main.screen->w - UNITS_W;
+ pWidget->size.y = Main.screen->h - UNITS_H;
- pIcon_theme = create_surf(UNITS_W, UNITS_H, SDL_SWSURFACE);
- pBuf->theme = SDL_DisplayFormatAlpha(pIcon_theme);
- FREESURFACE(pIcon_theme);
+ pSurf = create_surf(UNITS_W, UNITS_H, SDL_SWSURFACE);
+ pWidget->theme = SDL_DisplayFormatAlpha(pSurf);
+ FREESURFACE(pSurf);
- draw_frame(pBuf->theme, 0, 0, pBuf->size.w, pBuf->size.h);
+ draw_frame(pWidget->theme, 0, 0, pWidget->size.w, pWidget->size.h);
- pIcon_theme = ResizeSurface(pTheme->Block, BLOCK_W,
- pBuf->size.h - DOUBLE_FRAME_WH, 1);
+ pIcon_theme = ResizeSurface(pTheme->Block, BLOCKU_W,
+ pWidget->size.h - DOUBLE_FRAME_WH, 1);
- blit_entire_src(pIcon_theme, pBuf->theme, FRAME_WH, FRAME_WH);
+ blit_entire_src(pIcon_theme, pWidget->theme, FRAME_WH, FRAME_WH);
FREESURFACE(pIcon_theme);
- SDL_FillRect(pBuf->theme, &area,
- SDL_MapRGBA(pBuf->theme->format, 255, 255, 255, 128));
+ SDL_FillRect(pWidget->theme, &unit_info_area,
+ SDL_MapRGBA(pWidget->theme->format, 255, 255, 255, 128));
- SDL_SetAlpha(pBuf->theme , 0x0 , 0x0);/* turn off alpha chanel */
+ SDL_SetAlpha(pWidget->theme , 0x0 , 0x0); /* turn off alpha chanel */
- pBuf->string16->style |= (SF_CENTER);
- pBuf->string16->render = 3;
+ pWidget->string16->style |= (SF_CENTER);
+ pWidget->string16->render = 3;
+ pWidget->string16->bgcol = (SDL_Color) {255, 255, 255, 128};
+
+ pWidget->action = unit_info_window_callback;
+ set_wstate(pWidget, FC_WS_NORMAL);
+ add_to_gui_list(ID_UNITS_WINDOW, pWidget);
+
+ pUnits_Info_Window = pWidget;
+
+ pUnitInfo_Dlg->pEndWidgetList = pUnits_Info_Window;
+ pUnits_Info_Window->private_data.adv_dlg = pUnitInfo_Dlg;
- pBuf->string16->bgcol.r = 255;
- pBuf->string16->bgcol.g = 255;
- pBuf->string16->bgcol.b = 255;
- pBuf->string16->bgcol.unused = 128;
- pBuf->action = unit_info_window_callback;
- set_wstate(pBuf, FC_WS_NORMAL);
- add_to_gui_list(ID_UNITS_WINDOW, pBuf);
- pUnits_Info_Window = pBuf;
- pUnitInfo_Dlg->pEndWidgetList = pBuf;
- pBuf->private_data.adv_dlg = pUnitInfo_Dlg;
/* economy button */
- pBuf = create_icon2(NULL, Main.gui,
- WF_FREE_GFX | WF_FREE_THEME |
- WF_WIDGET_HAS_INFO_LABEL | WF_DRAW_THEME_TRANSPARENT);
- pBuf->string16 = create_str16_from_char(_("Economy (F5)"), 12);
+ pWidget = create_icon2(NULL, Main.gui, WF_FREE_GFX | WF_FREE_THEME
+ | WF_WIDGET_HAS_INFO_LABEL | WF_DRAW_THEME_TRANSPARENT);
+
+ pWidget->string16 = create_str16_from_char(_("Economy (F5)"), adj_font(12));
- pBuf->size.x = Main.screen->w - UNITS_W + FRAME_WH + 5;
- pBuf->size.y = Main.screen->h - UNITS_H + FRAME_WH + 2;
+ #ifdef SMALL_SCREEN
+ pWidget->size.w = 8;
+ pWidget->size.h = 10;
+ #else
+ pWidget->size.w = 18;
+ pWidget->size.h = 24;
+ #endif
+
+ pWidget->size.x = Main.screen->w - UNITS_W + FRAME_WH
+ + (BLOCKU_W - pWidget->size.w)/2;
+ pWidget->size.y = Main.screen->h - UNITS_H + FRAME_WH + 2;
- pBuf->action = economy_callback;
- pBuf->key = SDLK_F5;
+ pWidget->action = economy_callback;
+ pWidget->key = SDLK_F5;
+ set_wstate(pWidget, FC_WS_NORMAL);
+ add_to_gui_list(ID_ECONOMY, pWidget);
- add_to_gui_list(ID_ECONOMY, pBuf);
- pTax_Button = pBuf;
+ pTax_Button = pWidget;
/* research button */
- pBuf = create_icon2(NULL, Main.gui, WF_FREE_GFX | WF_FREE_THEME
- | WF_WIDGET_HAS_INFO_LABEL | WF_DRAW_THEME_TRANSPARENT);
- pBuf->string16 = create_str16_from_char(_("Research (F6)"), 12);
- pBuf->size.w = 19;
- pBuf->size.h = 24;
+ pWidget = create_icon2(NULL, Main.gui,
+ WF_FREE_GFX | WF_FREE_THEME |
+ WF_WIDGET_HAS_INFO_LABEL | WF_DRAW_THEME_TRANSPARENT);
+ pWidget->string16 = create_str16_from_char(_("Research (F6)"), adj_font(12));
- pBuf->size.x = Main.screen->w - UNITS_W + FRAME_WH + 5;
- pBuf->size.y = Main.screen->h - UNITS_H + FRAME_WH + 2 + pBuf->size.h;
+ #ifdef SMALL_SCREEN
+ pWidget->size.w = 8;
+ pWidget->size.h = 10;
+ #else
+ pWidget->size.w = 18;
+ pWidget->size.h = 24;
+ #endif
+
+ pWidget->size.x = Main.screen->w - UNITS_W + FRAME_WH
+ + (BLOCKU_W - pWidget->size.w)/2;
+ pWidget->size.y = Main.screen->h - UNITS_H + FRAME_WH + pWidget->size.h + 2;
- pBuf->action = research_callback;
- pBuf->key = SDLK_F6;
+ pWidget->action = research_callback;
+ pWidget->key = SDLK_F6;
+ set_wstate(pWidget, FC_WS_NORMAL);
+ add_to_gui_list(ID_RESEARCH, pWidget);
- add_to_gui_list(ID_RESEARCH, pBuf);
- pResearch_Button = pBuf;
+ pResearch_Button = pWidget;
/* revolution button */
- pBuf = create_icon2(NULL, Main.gui, (WF_FREE_GFX | WF_FREE_THEME
+ pWidget = create_icon2(NULL, Main.gui, (WF_FREE_GFX | WF_FREE_THEME
| WF_WIDGET_HAS_INFO_LABEL| WF_DRAW_THEME_TRANSPARENT));
- pBuf->string16 = create_str16_from_char(_("Revolution (Shift + R)"), 12);
- pBuf->size.w = 19;
- pBuf->size.h = 24;
-
- pBuf->size.x = Main.screen->w - UNITS_W + FRAME_WH + 5;
- pBuf->size.y =
- Main.screen->h - UNITS_H + FRAME_WH + 2 + (pBuf->size.h << 1);
-
- pBuf->action = revolution_callback;
- pBuf->key = SDLK_r;
- pBuf->mod = KMOD_SHIFT;
+ pWidget->string16 = create_str16_from_char(_("Revolution (Shift + R)"),
adj_font(12));
+
+ #ifdef SMALL_SCREEN
+ pWidget->size.w = 8;
+ pWidget->size.h = 10;
+ #else
+ pWidget->size.w = 18;
+ pWidget->size.h = 24;
+ #endif
+
+ pWidget->size.x = Main.screen->w - UNITS_W + FRAME_WH
+ + (BLOCKU_W - pWidget->size.w)/2;
+ pWidget->size.y =
+ Main.screen->h - UNITS_H + FRAME_WH + (pWidget->size.h << 1) + 2;
+
+ pWidget->action = revolution_callback;
+ pWidget->key = SDLK_r;
+ pWidget->mod = KMOD_SHIFT;
+ set_wstate(pWidget, FC_WS_NORMAL);
+ add_to_gui_list(ID_REVOLUTION, pWidget);
- add_to_gui_list(ID_REVOLUTION, pBuf);
- pRevolution_Button = pBuf;
+ pRevolution_Button = pWidget;
/* show/hide unit's window button */
@@ -1482,119 +1552,151 @@
SDL_BlitSurface(pTheme->R_ARROW_Icon, NULL, pIcon_theme, NULL);
SDL_SetColorKey(pIcon_theme, SDL_SRCCOLORKEY, 0x0);
- pBuf = create_themeicon(pIcon_theme, Main.gui,
+ pWidget = create_themeicon(pIcon_theme, Main.gui,
WF_FREE_GFX | WF_FREE_THEME |
WF_DRAW_THEME_TRANSPARENT | WF_WIDGET_HAS_INFO_LABEL);
- pBuf->string16 = create_str16_from_char(_("Hide Unit Info Window"), 12);
- pBuf->size.x = Main.screen->w - UNITS_W + FRAME_WH + 2;
- pBuf->size.y = Main.screen->h - FRAME_WH - pBuf->size.h - 2;
-
- pBuf->action = toggle_unit_info_window_callback;
- add_to_gui_list(ID_TOGGLE_UNITS_WINDOW_BUTTON, pBuf);
- pUnitInfo_Dlg->pBeginWidgetList = pBuf;
- /* ========================= Mini map ========================== */
+ pWidget->string16 = create_str16_from_char(_("Hide Unit Info Window"),
adj_font(12));
+ pWidget->size.x = Main.screen->w - UNITS_W + FRAME_WH
+ + (BLOCKU_W - pWidget->size.w)/2;
+ pWidget->size.y = Main.screen->h - FRAME_WH - pWidget->size.h - 2;
- pBuf = create_window(Main.gui, NULL, MINI_MAP_W, MINI_MAP_H, 0);
- pBuf->size.x = 0;
- pBuf->size.y = pBuf->dst->h - MINI_MAP_H;
+ pWidget->action = toggle_unit_info_window_callback;
+ set_wstate(pWidget, FC_WS_NORMAL);
+ add_to_gui_list(ID_TOGGLE_UNITS_WINDOW_BUTTON, pWidget);
- pIcon_theme = create_surf(MINI_MAP_W, MINI_MAP_H, SDL_SWSURFACE);
- pBuf->theme = SDL_DisplayFormatAlpha(pIcon_theme);
- FREESURFACE(pIcon_theme);
+ pUnitInfo_Dlg->pBeginWidgetList = pWidget;
+
+ /* ========================= Mini map ========================== */
- draw_frame(pBuf->theme, 0, 0, pBuf->size.w, pBuf->size.h);
+ pWidget = create_window(Main.gui, NULL, MINI_MAP_W, MINI_MAP_H, 0);
+ pWidget->size.x = 0;
+ pWidget->size.y = pWidget->dst->h - MINI_MAP_H;
+
+ pSurf = create_surf(MINI_MAP_W, MINI_MAP_H, SDL_SWSURFACE);
+ pWidget->theme = SDL_DisplayFormatAlpha(pSurf);
+ FREESURFACE(pSurf);
- pIcon_theme = ResizeSurface(pTheme->Block, BLOCK_W,
- pBuf->size.h - DOUBLE_FRAME_WH, 1);
+ draw_frame(pWidget->theme, 0, 0, pWidget->size.w, pWidget->size.h);
- blit_entire_src(pIcon_theme , pBuf->theme ,
- pBuf->size.w - FRAME_WH - pIcon_theme->w, FRAME_WH);
+ pIcon_theme = ResizeSurface(pTheme->Block, BLOCKM_W,
+ pWidget->size.h - DOUBLE_FRAME_WH, 1);
+ blit_entire_src(pIcon_theme, pWidget->theme,
+ pWidget->size.w - FRAME_WH - pIcon_theme->w, FRAME_WH);
FREESURFACE(pIcon_theme);
- SDL_SetAlpha(pBuf->theme, 0x0, 0x0);
- pBuf->action = minimap_window_callback;
- set_wstate(pBuf, FC_WS_NORMAL);
- add_to_gui_list(ID_MINI_MAP_WINDOW, pBuf);
- pMiniMap_Window = pBuf;
+ SDL_SetAlpha(pWidget->theme, 0x0, 0x0);
+ pWidget->action = minimap_window_callback;
+ set_wstate(pWidget, FC_WS_NORMAL);
+ add_to_gui_list(ID_MINI_MAP_WINDOW, pWidget);
+
+ pMiniMap_Window = pWidget;
/* new turn button */
- pBuf = create_themeicon(pTheme->NEW_TURN_Icon, Main.gui,
+ pWidget = create_themeicon(pTheme->NEW_TURN_Icon, Main.gui,
WF_WIDGET_HAS_INFO_LABEL |
WF_DRAW_THEME_TRANSPARENT);
- pBuf->string16 = create_str16_from_char(_("End Turn (Enter)"), 12);
+ pWidget->string16 = create_str16_from_char(_("End Turn (Enter)"),
adj_font(12));
- pBuf->action = end_turn_callback;
- pBuf->key = SDLK_RETURN;
- pBuf->mod = KMOD_LCTRL;
+ pWidget->size.x = MINI_MAP_W - BLOCKM_W + pWidget->size.w;
+ pWidget->size.y = pWidget->dst->h - MINI_MAP_H + FRAME_WH + 2;
- pBuf->size.x = DEFAULT_UNITS_W - BLOCK_W;
- pBuf->size.y = pBuf->dst->h - MINI_MAP_H + FRAME_WH + 2;
- pNew_Turn_Button = pBuf;
+ pWidget->action = end_turn_callback;
+ pWidget->key = SDLK_RETURN;
+ pWidget->mod = KMOD_LCTRL;
- add_to_gui_list(ID_NEW_TURN, pBuf);
+ add_to_gui_list(ID_NEW_TURN, pWidget);
+
+ pNew_Turn_Button = pWidget;
/* players button */
- pBuf = create_themeicon(pTheme->PLAYERS_Icon, Main.gui,
+ pWidget = create_themeicon(pTheme->PLAYERS_Icon, Main.gui,
WF_WIDGET_HAS_INFO_LABEL);
- pBuf->string16 = create_str16_from_char(_("Players (F3)"), 12);
- pBuf->action = players_action_callback;
- pBuf->key = SDLK_F3;
- add_to_gui_list(ID_PLAYERS, pBuf);
+ pWidget->string16 = create_str16_from_char(_("Players (F3)"), adj_font(12));
+ pWidget->size.x = MINI_MAP_W - BLOCKM_W + pWidget->size.w;
+ pWidget->size.y = pWidget->dst->h - MINI_MAP_H + FRAME_WH + pWidget->size.h
+ 2;
- pBuf->size.x = DEFAULT_UNITS_W - BLOCK_W;
- pBuf->size.y = pBuf->dst->h - MINI_MAP_H + FRAME_WH + 2 + pBuf->size.h;
+ pWidget->action = players_action_callback;
+ pWidget->key = SDLK_F3;
+ set_wstate(pWidget, FC_WS_NORMAL);
+
+ add_to_gui_list(ID_PLAYERS, pWidget);
/* find city button */
- pBuf = create_themeicon(pTheme->FindCity_Icon, Main.gui,
+ pWidget = create_themeicon(pTheme->FindCity_Icon, Main.gui,
WF_WIDGET_HAS_INFO_LABEL);
- pBuf->string16 = create_str16_from_char(
- _("Cities Report (F1)\nor\nFind City (Shift + F)"), 12);
- pBuf->string16->style |= SF_CENTER;
- pBuf->size.x = DEFAULT_UNITS_W - BLOCK_W;
- pBuf->size.y = pBuf->dst->h - MINI_MAP_H + FRAME_WH + 2 + pBuf->size.h * 2;
-
- pBuf->action = cities_action_callback;
- pBuf->key = SDLK_f;
- pBuf->mod = KMOD_SHIFT;
+ pWidget->string16 = create_str16_from_char(
+ _("Cities Report (F1)\nor\nFind City (Shift + F)"),
adj_font(12));
+ pWidget->string16->style |= SF_CENTER;
+ pWidget->size.x = MINI_MAP_W - BLOCKM_W + pWidget->size.w;
+ pWidget->size.y = pWidget->dst->h - MINI_MAP_H + FRAME_WH + pWidget->size.h
* 2 + 2;
+
+ pWidget->action = cities_action_callback;
+ pWidget->key = SDLK_f;
+ pWidget->mod = KMOD_SHIFT;
+ set_wstate(pWidget, FC_WS_NORMAL);
- add_to_gui_list(ID_CITIES, pBuf);
- pFind_City_Button = pBuf;
+ add_to_gui_list(ID_CITIES, pWidget);
+
+ pFind_City_Button = pWidget;
/* units button */
- pBuf = create_themeicon(pTheme->UNITS2_Icon, Main.gui,
+ pWidget = create_themeicon(pTheme->UNITS2_Icon, Main.gui,
WF_WIDGET_HAS_INFO_LABEL);
- pBuf->string16 = create_str16_from_char(_("Units (F2)"), 12);
- pBuf->action = units_action_callback;
- pBuf->key = SDLK_F2;
- add_to_gui_list(ID_UNITS, pBuf);
- set_wflag(pBuf , WF_HIDDEN);
- pBuf->size.x = DEFAULT_UNITS_W - BLOCK_W;
- pBuf->size.y = pBuf->dst->h - MINI_MAP_H + FRAME_WH + 2 + pBuf->size.h * 3;
+ pWidget->string16 = create_str16_from_char(_("Units (F2)"), adj_font(12));
+ pWidget->size.x = MINI_MAP_W - BLOCKM_W;
+ pWidget->size.y = pWidget->dst->h - MINI_MAP_H + FRAME_WH + 2;
+
+ pWidget->action = units_action_callback;
+ pWidget->key = SDLK_F2;
+ set_wstate(pWidget, FC_WS_NORMAL);
+ set_wflag(pWidget, WF_HIDDEN);
+
+ add_to_gui_list(ID_UNITS, pWidget);
/* show/hide log window button */
- pBuf = create_themeicon(pTheme->LOG_Icon, Main.gui,
+ pWidget = create_themeicon(pTheme->LOG_Icon, Main.gui,
WF_WIDGET_HAS_INFO_LABEL);
- pBuf->string16 = create_str16_from_char(_("Hide Log (F10)"), 12);
- pBuf->action = togle_msg_window;
- pBuf->key = SDLK_F10;
- add_to_gui_list(ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON, pBuf);
- set_wflag(pBuf, WF_HIDDEN);
- pBuf->size.x = DEFAULT_UNITS_W - BLOCK_W;
- pBuf->size.y = pBuf->dst->h - MINI_MAP_H + FRAME_WH + 2 + pBuf->size.h * 4;
+ pWidget->string16 = create_str16_from_char(_("Hide Log (F10)"),
adj_font(12));
+ pWidget->size.x = MINI_MAP_W - BLOCKM_W;
+ pWidget->size.y = pWidget->dst->h - MINI_MAP_H + FRAME_WH + pWidget->size.h
+ 2;
+ pWidget->action = togle_msg_window;
+ pWidget->key = SDLK_F10;
+ set_wstate(pWidget, FC_WS_NORMAL);
+ set_wflag(pWidget, WF_HIDDEN);
- /* show/hide log window button */
- pBuf = create_themeicon(pTheme->BORDERS_Icon, Main.gui,
+ add_to_gui_list(ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON, pWidget);
+
+ /* toggle minimap mode button */
+ pWidget = create_themeicon(pTheme->BORDERS_Icon, Main.gui,
WF_WIDGET_HAS_INFO_LABEL);
- pBuf->string16 = create_str16_from_char(_("Toggle Minimap Mode (Shift +
\\)"), 12);
- pBuf->action = togle_minimap_mode;
- pBuf->key = SDLK_BACKSLASH;
- pBuf->mod = KMOD_SHIFT;
- add_to_gui_list(ID_BUTTON, pBuf);
- set_wflag(pBuf, WF_HIDDEN);
- pBuf->size.x = DEFAULT_UNITS_W - BLOCK_W;
- pBuf->size.y = pBuf->dst->h - MINI_MAP_H + FRAME_WH + 2 + pBuf->size.h * 5;
+ pWidget->string16 = create_str16_from_char(
+ _("Toggle Minimap Mode (Shift + \\)"), adj_font(12));
+ pWidget->size.x = MINI_MAP_W - BLOCKM_W;
+ pWidget->size.y = pWidget->dst->h - MINI_MAP_H + FRAME_WH + pWidget->size.h
* 2 + 2;
+ pWidget->action = togle_minimap_mode;
+ pWidget->key = SDLK_BACKSLASH;
+ pWidget->mod = KMOD_SHIFT;
+ set_wstate(pWidget, FC_WS_NORMAL);
+ set_wflag(pWidget, WF_HIDDEN);
+
+ add_to_gui_list(ID_TOGGLE_MINIMAP_MODE, pWidget);
+
+ #ifdef SMALL_SCREEN
+ /* options button */
+ pOptions_Button = create_themeicon(pTheme->Options_Icon, Main.gui,
+ (WF_WIDGET_HAS_INFO_LABEL |
+ WF_DRAW_THEME_TRANSPARENT));
+ pOptions_Button->string16 = create_str16_from_char(_("Options"),
adj_font(12));
+ pOptions_Button->size.x = MINI_MAP_W - BLOCKM_W;
+ pOptions_Button->size.y = pWidget->dst->h - FRAME_WH - pWidget->size.h - 2;
+ pOptions_Button->action = optiondlg_callback;
+ pOptions_Button->key = SDLK_TAB;
+ set_wstate(pOptions_Button, FC_WS_NORMAL);
+ set_wflag(pOptions_Button, WF_HIDDEN);
+ add_to_gui_list(ID_CLIENT_OPTIONS, pOptions_Button);
+ #endif
/* show/hide minimap button */
@@ -1605,42 +1707,43 @@
SDL_BlitSurface(pTheme->L_ARROW_Icon, NULL, pIcon_theme, NULL);
SDL_SetColorKey(pIcon_theme, SDL_SRCCOLORKEY, 0x0);
- pBuf = create_themeicon(pIcon_theme, Main.gui,
+ pWidget = create_themeicon(pIcon_theme, Main.gui,
WF_FREE_GFX | WF_FREE_THEME |
WF_DRAW_THEME_TRANSPARENT | WF_WIDGET_HAS_INFO_LABEL);
- pBuf->string16 = create_str16_from_char(_("Hide MiniMap"), 12);
- pBuf->size.x = DEFAULT_UNITS_W - BLOCK_W;
- pBuf->size.y = pBuf->dst->h - FRAME_WH - pBuf->size.h - 2;
+ pWidget->string16 = create_str16_from_char(_("Hide MiniMap"), adj_font(12));
+ pWidget->size.x = MINI_MAP_W - BLOCKM_W + pWidget->size.w;
+ pWidget->size.y = pWidget->dst->h - FRAME_WH - pWidget->size.h - 2;
- pBuf->action = toggle_map_window_callback;
- add_to_gui_list(ID_TOGGLE_MAP_WINDOW_BUTTON, pBuf);
+ pWidget->action = toggle_map_window_callback;
+ set_wstate(pWidget, FC_WS_NORMAL);
+
+ add_to_gui_list(ID_TOGGLE_MAP_WINDOW_BUTTON, pWidget);
/* ========================= Cooling/Warming ========================== */
/* cooling icon */
- pIcon_theme = GET_SURF(sprites.cooling[0]);
+ pIcon_theme = adj_surf(GET_SURF(client_cooling_sprite()));
assert(pIcon_theme != NULL);
- pBuf = create_iconlabel(pIcon_theme, Main.gui, NULL, 0);
+ pWidget = create_iconlabel(pIcon_theme, Main.gui, NULL, 0);
- pBuf->size.x = pBuf->dst->w - 10 - pBuf->size.w;
- pBuf->size.y = 10;
+ pWidget->size.x = pWidget->dst->w - pWidget->size.w - adj_size(10);
+ pWidget->size.y = adj_size(10);
- add_to_gui_list(ID_COOLING_ICON, pBuf);
+ add_to_gui_list(ID_COOLING_ICON, pWidget);
/* warming icon */
- pIcon_theme = GET_SURF(sprites.warming[0]);
+ pIcon_theme = adj_surf(GET_SURF(client_warming_sprite()));
assert(pIcon_theme != NULL);
- pBuf = create_iconlabel(pIcon_theme, Main.gui, NULL, 0);
- pBuf->size.x = pBuf->dst->w - 10 - pBuf->size.w * 2;
- pBuf->size.y = 10;
+ pWidget = create_iconlabel(pIcon_theme, Main.gui, NULL, 0);
- add_to_gui_list(ID_WARMING_ICON, pBuf);
+ pWidget->size.x = pWidget->dst->w - pWidget->size.w * 2 - adj_size(10);
+ pWidget->size.y = adj_size(10);
- /* ================================ */
+ add_to_gui_list(ID_WARMING_ICON, pWidget);
- tmp_map_surfaces_init();
+ /* ================================ */
SDL_Client_Flags |= (CF_MAP_UNIT_W_CREATED | CF_UNIT_INFO_SHOW |
CF_MINI_MAP_SHOW);
@@ -1689,6 +1792,12 @@
pBuf = pBuf->prev;
pBuf->dst = Main.gui;
+ #ifdef SMALL_SCREEN
+ /* options button */
+ pBuf = pBuf->prev;
+ pBuf->dst = Main.gui;
+ #endif
+
/* show/hide minimap button */
pBuf = pBuf->prev;
pBuf->dst = Main.gui;
@@ -1745,6 +1854,12 @@
pBuf = pBuf->prev;
set_wstate(pBuf, FC_WS_DISABLED);
+ #ifdef SMALL_SCREEN
+ /* options button */
+ pBuf = pBuf->prev;
+ set_wstate(pBuf, FC_WS_DISABLED);
+ #endif
+
/* show/hide minimap button */
pBuf = pBuf->prev;
set_wstate(pBuf, FC_WS_DISABLED);
@@ -1794,6 +1909,12 @@
pBuf = pBuf->prev;
set_wstate(pBuf, FC_WS_NORMAL);
+ #ifdef SMALL_SCREEN
+ /* options button */
+ pBuf = pBuf->prev;
+ set_wstate(pBuf, FC_WS_NORMAL);
+ #endif
+
/* show/hide minimap button */
pBuf = pBuf->prev;
set_wstate(pBuf, FC_WS_NORMAL);
@@ -1849,31 +1970,24 @@
**************************************************************************/
void button_down_on_map(SDL_MouseButtonEvent * pButtonEvent)
{
- int col, row;
+ struct tile *ptile;
struct city *pCity;
if (get_client_state() != CLIENT_GAME_RUNNING_STATE) {
return;
}
-#if 0
- if (ev->button == 1 && (ev->state & GDK_SHIFT_MASK)) {
- adjust_workers(w, ev);
- return TRUE;
- }
-#endif
-
draw_goto_patrol_lines = FALSE;
if (pButtonEvent->button == SDL_BUTTON_LEFT) {
if(LSHIFT || LALT || LCTRL) {
- if (canvas_to_map_pos(&col, &row,
- (int) pButtonEvent->x, (int) pButtonEvent->y)) {
+ if ((ptile = canvas_pos_to_tile((int) pButtonEvent->x,
+ (int) pButtonEvent->y))) {
if(LSHIFT) {
- popup_advanced_terrain_dialog(col, row);
+ popup_advanced_terrain_dialog(ptile);
} else {
- if(((pCity = map_get_tile(col, row)->city) != NULL) &&
- (pCity->owner == game.player_idx)) {
+ if(((pCity = ptile->city) != NULL) &&
+ (pCity->owner == game.player_ptr)) {
if(LCTRL) {
popup_worklist_editor(pCity, &(pCity->worklist));
} else {
@@ -1888,9 +2002,9 @@
}
} else {
if (pButtonEvent->button == SDL_BUTTON_MIDDLE) {
- if (canvas_to_map_pos(&col, &row,
- (int) pButtonEvent->x, (int) pButtonEvent->y)) {
- popup_advanced_terrain_dialog(col, row);
+ if ((ptile = canvas_pos_to_tile((int) pButtonEvent->x,
+ (int) pButtonEvent->y))) {
+ popup_advanced_terrain_dialog(ptile);
}
} else {
recenter_button_pressed(pButtonEvent->x, pButtonEvent->y);
@@ -2157,15 +2271,15 @@
/* create ok button */
pOK_Button =
create_themeicon_button_from_chars(pTheme->Small_OK_Icon, Main.gui,
- _("OK"), 10, 0);
+ _("OK"), adj_font(10), 0);
/* create cancel button */
pCancel_Button =
create_themeicon_button_from_chars(pTheme->Small_CANCEL_Icon,
- Main.gui, _("Cancel"), 10, 0);
+ Main.gui, _("Cancel"), adj_font(10), 0);
/* create text label */
- pStr = create_str16_from_char(_("What should we call our new city?"), 10);
+ pStr = create_str16_from_char(_("What should we call our new city?"),
adj_font(10));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pStr->fgcol.r = 255;
pStr->fgcol.g = 255;
@@ -2173,25 +2287,25 @@
pLabel = create_iconlabel(NULL, Main.gui, pStr,
WF_DRAW_TEXT_LABEL_WITH_SPACE);
- pEdit = create_edit(NULL, Main.gui, create_str16_from_char(pSuggestname, 12),
- 180, WF_DRAW_THEME_TRANSPARENT);
+ pEdit = create_edit(NULL, Main.gui, create_str16_from_char(pSuggestname,
adj_font(12)),
+ adj_size(180), WF_DRAW_THEME_TRANSPARENT);
/* create window */
- pStr = create_str16_from_char(_("Build New City"), 12);
+ pStr = create_str16_from_char(_("Build New City"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(Main.gui, pStr, pEdit->size.w + 20, pEdit->size.h +
+ pWindow = create_window(Main.gui, pStr, pEdit->size.w + adj_size(20),
pEdit->size.h +
pOK_Button->size.h + pLabel->size.h +
- WINDOW_TILE_HIGH + 25, 0);
+ WINDOW_TILE_HIGH + adj_size(25), 0);
/* I make this hack to center label on window */
if (pLabel->size.w < pWindow->size.w)
{
pLabel->size.w = pWindow->size.w;
} else {
- pWindow->size.w = pLabel->size.w + 10;
+ pWindow->size.w = pLabel->size.w + adj_size(10);
}
- pEdit->size.w = pWindow->size.w - 20;
+ pEdit->size.w = pWindow->size.w - adj_size(20);
/* set actions */
pWindow->action = move_new_city_dlg_callback;
@@ -2207,7 +2321,7 @@
pOK_Button->data.unit = pUnit;
/* correct sizes */
- pCancel_Button->size.w += 5;
+ pCancel_Button->size.w += adj_size(5);
/*pOK_Button->size.w += 10; */
pOK_Button->size.w = pCancel_Button->size.w;
@@ -2216,21 +2330,21 @@
pWindow->size.y = (Main.screen->h - pWindow->size.h) / 2;
- pOK_Button->size.x = pWindow->size.x + 10;
+ pOK_Button->size.x = pWindow->size.x + adj_size(10);
pOK_Button->size.y =
- pWindow->size.y + pWindow->size.h - pOK_Button->size.h - 10;
+ pWindow->size.y + pWindow->size.h - pOK_Button->size.h - adj_size(10);
pCancel_Button->size.y = pOK_Button->size.y;
pCancel_Button->size.x = pWindow->size.x + pWindow->size.w -
- pCancel_Button->size.w - 10;
+ pCancel_Button->size.w - adj_size(10);
- pEdit->size.x = pWindow->size.x + 10;
+ pEdit->size.x = pWindow->size.x + adj_size(10);
pEdit->size.y =
- pWindow->size.y + WINDOW_TILE_HIGH + 5 + pLabel->size.h + 3;
+ pWindow->size.y + WINDOW_TILE_HIGH + adj_size(5) + pLabel->size.h +
adj_size(3);
pLabel->size.x = pWindow->size.x + FRAME_WH;
- pLabel->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 5;
+ pLabel->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(5);
/* create window background */
pLogo = get_logo_gfx();
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/mapctrl.h
devel/client/gui-sdl/mapctrl.h
--- devel_distclean/client/gui-sdl/mapctrl.h 2005-10-17 17:15:35.000000000
+0200
+++ devel/client/gui-sdl/mapctrl.h 2005-11-15 06:52:44.000000000 +0100
@@ -26,11 +26,31 @@
#include "mapctrl_g.h"
-#define BLOCK_W 30
-#define HIDDEN_UNITS_W 36 /* BLOCK_W + DOUBLE_FRAME_WH */
-#define HIDDEN_MINI_MAP_W 36 /* BLOCK_W + DOUBLE_FRAME_WH */
-#define DEFAULT_UNITS_W 196 /* 160 + BLOCK_W + DOUBLE_FRAME_WH
*/
-#define DEFAULT_UNITS_H 106 /* 100 + DOUBLE_FRAME_WH */
+#ifdef SMALL_SCREEN
+
+#define BLOCKM_W 28
+#define BLOCKU_W 15
+#define DEFAULT_MINI_MAP_W 78 + BLOCKM_W + DOUBLE_FRAME_WH
+#define DEFAULT_MINI_MAP_H 52 + DOUBLE_FRAME_WH
+#define DEFAULT_UNITS_W 78 + BLOCKU_W + DOUBLE_FRAME_WH
+#define DEFAULT_UNITS_H 52 + DOUBLE_FRAME_WH
+
+#else
+
+#define BLOCKM_W 56
+#define BLOCKU_W 30
+#define DEFAULT_MINI_MAP_W 156 + BLOCKM_W + DOUBLE_FRAME_WH
+#define DEFAULT_MINI_MAP_H 104 + DOUBLE_FRAME_WH
+#define DEFAULT_UNITS_W 156 + BLOCKU_W + DOUBLE_FRAME_WH
+#define DEFAULT_UNITS_H 104 + DOUBLE_FRAME_WH
+
+#endif
+
+#define HIDDEN_MINI_MAP_W BLOCKM_W + DOUBLE_FRAME_WH
+#define HIDDEN_UNITS_W BLOCKU_W + DOUBLE_FRAME_WH
+
+extern int MINI_MAP_W;
+extern int MINI_MAP_H;
void popdown_newcity_dialog(void);
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/mapview.c
devel/client/gui-sdl/mapview.c
--- devel_distclean/client/gui-sdl/mapview.c 2005-10-18 21:02:43.000000000
+0200
+++ devel/client/gui-sdl/mapview.c 2005-11-15 06:57:09.000000000 +0100
@@ -61,6 +61,8 @@
#include "gui_zoom.h"
#include "gui_main.h"
#include "gui_tilespec.h"
+#include "overview_common.h"
+#include "log.h"
#include "menu.h"
#include "dialogs.h" /*sdl_map_get_tile_info_text(...)*/
@@ -71,59 +73,54 @@
#include "cma_fe.h"
#include "gui_dither.h"
#include "timing.h"
+#include "text.h"
#include "mapview.h"
extern SDL_Event *pFlush_User_Event;
extern SDL_Cursor **pAnimCursor;
extern bool do_cursor_animation;
-static Uint32 Amask;
-static int HALF_tileset_tile_height(tileset), HALF_tileset_tile_width(tileset);
-
-static SDL_Surface *pTmpSurface;
-
-static SDL_Surface *pBlinkSurfaceA;
-static SDL_Surface *pBlinkSurfaceB;
-
-static SDL_Surface *pMapGrid[3][2];
-static SDL_Surface ***pMapBorders = NULL;
-static bool UPDATE_OVERVIEW_MAP = FALSE;
int OVERVIEW_START_X;
int OVERVIEW_START_Y;
-SDL_Surface *pDitherMask;
-
-static SDL_Surface *pOcean_Tile;
-static SDL_Surface *pOcean_Foged_Tile;
-static SDL_Surface *pDithers[MAX_NUM_TERRAINS][4];
-
static enum {
NORMAL = 0,
BORDERS = 1,
TEAMS
} overview_mode = NORMAL;
+static struct canvas *overview_canvas;
+static struct canvas *city_map_canvas;
+static struct canvas *terrain_canvas;
+
+static int *fonts[FONT_COUNT] = {
+ &city_names_font_size,
+ &city_productions_font_size,
+ &city_productions_font_size
+};
-static void init_dither_tiles(void);
-static void free_dither_tiles(void);
-static void fill_dither_buffers(SDL_Surface **pDitherBufs, int x, int y,
- Terrain_type_id terrain);
-
+/* ================================================================ */
-static void draw_map_cell(SDL_Surface * pDest, Sint16 map_x, Sint16 map_y,
- Uint16 map_col, Uint16 map_wier, int citymode);
+/**************************************************************************
+ Create a canvas of the given size.
+**************************************************************************/
+struct canvas *canvas_create(int width, int height)
+{
+ struct canvas *result = fc_malloc(sizeof(*result));
-/* ================================================================ */
+ result->surf = create_surf(width, height, SDL_SWSURFACE);
+ return result;
+}
/**************************************************************************
- Draw some or all of a tile onto the mapview canvas.
+ Free any resources associated with this canvas and the canvas struct
+ itself.
**************************************************************************/
-void put_one_tile_iso(struct canvas *pcanvas, int map_x, int map_y,
- int canvas_x, int canvas_y, bool citymode)
+void canvas_free(struct canvas *store)
{
- draw_map_cell(pcanvas->surf, canvas_x, canvas_y,
- (Uint16)map_x, (Uint16)map_y, citymode);
+ FREESURFACE(store->surf);
+ free(store);
}
/**************************************************************************
@@ -139,6 +136,24 @@
SDL_BlitSurface(GET_SURF(sprite), &src, pcanvas->surf, &dst);
}
+/****************************************************************************
+ Draw a full sprite onto the canvas. If "fog" is specified draw it with
+ fog.
+****************************************************************************/
+void canvas_put_sprite_fogged(struct canvas *pcanvas,
+ int canvas_x, int canvas_y,
+ struct sprite *psprite,
+ bool fog, int fog_x, int fog_y)
+{
+ /* PORTME */
+ freelog(LOG_NORMAL, "PORT ME: canvas_put_sprite_fogged()");
+
+ /* FIXME: implement fog */
+ SDL_Rect dst = {canvas_x, canvas_y, 0, 0};
+
+ SDL_BlitSurface(GET_SURF(psprite), NULL, pcanvas->surf, &dst);
+}
+
/**************************************************************************
Draw a full sprite onto the mapview or citydialog canvas.
**************************************************************************/
@@ -154,50 +169,106 @@
Draw a filled-in colored rectangle onto the mapview or citydialog canvas.
**************************************************************************/
void canvas_put_rectangle(struct canvas *pcanvas,
- enum color_std color,
+ struct color *pcolor,
int canvas_x, int canvas_y, int width, int height)
{
SDL_Rect dst = {canvas_x, canvas_y, width, height};
SDL_FillRect(pcanvas->surf, &dst,
- get_game_color(color, pcanvas->surf));
+ get_game_color(pcolor, pcanvas->surf));
}
/**************************************************************************
Draw a 1-pixel-width colored line onto the mapview or citydialog canvas.
**************************************************************************/
-void canvas_put_line(struct canvas *pcanvas, enum color_std color,
+void canvas_put_line(struct canvas *pcanvas, struct color *pcolor,
enum line_type ltype, int start_x, int start_y,
int dx, int dy)
{
putline(pcanvas->surf, start_x, start_y, start_x + dx, start_y + dy,
- get_game_color(color, pcanvas->surf));
+ get_game_color(pcolor, pcanvas->surf));
}
-void canvas_copy(struct canvas *dest, struct canvas *src,
- int src_x, int src_y, int dest_x, int dest_y,
- int width, int height)
+/****************************************************************************
+ Fill the area covered by the sprite with the given color.
+****************************************************************************/
+void canvas_fill_sprite_area(struct canvas *pcanvas,
+ struct sprite *psprite, struct color *pcolor,
+ int canvas_x, int canvas_y)
{
+ SDL_Rect dst = {canvas_x, canvas_y, GET_SURF(psprite)->w,
+ GET_SURF(psprite)->h};
+ SDL_FillRect(pcanvas->surf, &dst, get_game_color(pcolor, pcanvas->surf));
+}
+void canvas_fog_sprite_area(struct canvas *pcanvas, struct sprite *psprite,
+ int canvas_x, int canvas_y)
+{
+ /* PORTME */
+ freelog(LOG_NORMAL, "PORT ME: canvas_fog_sprite_area()");
}
-struct canvas *canvas_create(int width, int height)
+void update_map_canvas_scrollbars_size()
{
- return NULL;
+ /* No scrollbars */
}
-void canvas_free(struct canvas *store)
+/**************************************************************************
+ Copies an area from the source canvas to the destination canvas.
+**************************************************************************/
+void canvas_copy(struct canvas *dest, struct canvas *src,
+ int src_x, int src_y, int dest_x, int dest_y, int width,
+ int height)
{
+ SDL_Rect src_rect = {src_x, src_y, width, height};
+ SDL_Rect dest_rect = {dest_x, dest_y, width, height};
+ SDL_BlitSurface(src->surf, &src_rect, dest->surf, &dest_rect);
}
-void map_size_changed(void)
+/****************************************************************************
+ Return the size of the given text in the given font. This size should
+ include the ascent and descent of the text. Either of width or height
+ may be NULL in which case those values simply shouldn't be filled out.
+****************************************************************************/
+void get_text_size(int *width, int *height,
+ enum client_font font, const char *text)
{
- /* Nothing */
+ SDL_String16 *pText = create_string16(NULL, 0, *fonts[font]);
+ copy_chars_to_string16(pText, text);
+
+ if (width) {
+ *width = str16size(pText).w;
+ }
+ if (height) {
+ *height = str16size(pText).h;
+ }
+
+ FREESTRING16(pText);
}
-void update_map_canvas_scrollbars_size()
-{
- /* No scrollbars */
+/****************************************************************************
+ Draw the text onto the canvas in the given color and font. The canvas
+ position does not account for the ascent of the text; this function must
+ take care of this manually. The text will not be NULL but may be empty.
+****************************************************************************/
+void canvas_put_text(struct canvas *pcanvas, int canvas_x, int canvas_y,
+ enum client_font font, struct color *pcolor,
+ const char *text)
+{
+ SDL_Surface *pTmp;
+ SDL_String16 *pText = create_string16(NULL, 0, *fonts[font]);
+ copy_chars_to_string16(pText, text);
+
+ pText->fgcol = *pcolor->color;
+ pText->bgcol = (SDL_Color) {0, 0, 0, 0};
+ pText->render = 3;
+
+ pTmp = create_text_surf_from_str16(pText);
+
+ blit_entire_src(pTmp, pcanvas->surf, canvas_x, canvas_y);
+
+ FREESTRING16(pText);
+ FREESURFACE(pTmp);
}
static bool is_flush_queued = FALSE;
@@ -258,11 +329,9 @@
**************************************************************************/
void unqueue_flush(void)
{
- if(UPDATE_OVERVIEW_MAP) {
refresh_overview();
- UPDATE_OVERVIEW_MAP = FALSE;
- }
flush_dirty();
+ redraw_selection_rectangle();
is_flush_queued = FALSE;
}
@@ -340,9 +409,16 @@
if(!Main.rects_count) {
return;
}
+
+ if (mapview.store) {
+ SDL_BlitSurface(mapview.store->surf, NULL, Main.map, NULL);
+ }
+
if(Main.rects_count >= RECT_LIMIT) {
+
SDL_BlitSurface(Main.map, NULL, Main.screen, NULL);
SDL_BlitSurface(Main.gui, NULL, Main.screen, NULL);
+
while(Main.guis && Main.guis[j] && j < Main.guis_count) {
SDL_BlitSurface(Main.guis[j++], NULL, Main.screen, NULL);
}
@@ -384,13 +460,16 @@
char cBuf[128];
pBuf = get_widget_pointer_form_main_list(ID_WARMING_ICON);
- pBuf->theme = GET_SURF(sol);
+ pBuf->theme = adj_surf(GET_SURF(sol));
+ SDL_SetAlpha(pBuf->theme, 0, 0);
redraw_label(pBuf);
pBuf = get_widget_pointer_form_main_list(ID_COOLING_ICON);
- pBuf->theme = GET_SURF(flake);
+ pBuf->theme = adj_surf(GET_SURF(flake));
+ SDL_SetAlpha(pBuf->theme, 0, 0);
redraw_label(pBuf);
+#if 0
putframe(pBuf->dst, pBuf->size.x - pBuf->size.w - 1,
pBuf->size.y - 1,
pBuf->size.x + pBuf->size.w,
@@ -399,13 +478,18 @@
dirty_rect(pBuf->size.x - pBuf->size.w - 1, pBuf->size.y - 1,
2 * pBuf->size.w + 2, 2 * pBuf->size.h + 2);
+#endif
if (SDL_Client_Flags & CF_REVOLUTION) {
pBuf = get_revolution_widget();
- set_new_icon2_theme(pBuf, GET_SURF(gov), FALSE);
+ set_new_icon2_theme(pBuf, adj_surf(GET_SURF(gov)), FALSE);
+ if (game.player_ptr) {
my_snprintf(cBuf, sizeof(cBuf), _("Revolution (Shift + R)\n%s"),
get_gov_pplayer(game.player_ptr)->name);
+ } else {
+ my_snprintf(cBuf, sizeof(cBuf), _("Revolution (Shift + R)\n%s"), "None");
+ }
copy_chars_to_string16(pBuf->string16, cBuf);
redraw_widget(pBuf);
@@ -415,15 +499,22 @@
pBuf = get_tax_rates_widget();
if(!pBuf->theme) {
+#if 0
/* create economy icon */
int i;
+
+ #ifdef SMALL_SCREEN
+ SDL_Surface *pIcon = create_surf(8, 10, SDL_SWSURFACE);
+ #else
SDL_Surface *pIcon = create_surf(16, 19, SDL_SWSURFACE);
+ #endif
+
Uint32 color = SDL_MapRGB(pIcon->format, 255, 255, 0);
SDL_Rect dst;
- for(i = 0; i < 16; i+=3) {
+ for(i = 0; i < pIcon->w; i+=3) {
putline(pIcon, i, 0, i, pIcon->h - 1, color);
}
- for(i = 0; i < 19; i+=3) {
+ for(i = 0; i < pIcon->h; i+=3) {
putline(pIcon, 0, i, pIcon->w - 1, i, color);
}
@@ -433,24 +524,59 @@
SDL_SetColorKey(pIcon, SDL_SRCCOLORKEY|SDL_RLEACCEL, 0x0);
set_new_icon2_theme(pBuf,pIcon, FALSE);
+#endif
+ set_new_icon2_theme(pBuf,
+ adj_surf(GET_SURF(get_tax_sprite(tileset, O_GOLD))), FALSE);
}
pBuf = get_research_widget();
+ if (!game.player_ptr) {
+ my_snprintf(cBuf, sizeof(cBuf), _("Research (F6)\n%s (%d/%d)"),
+ "None", 0, 0);
+ } else if (get_player_research(game.player_ptr)->researching != A_UNSET) {
my_snprintf(cBuf, sizeof(cBuf), _("Research (F6)\n%s (%d/%d)"),
get_tech_name(game.player_ptr,
- game.player_ptr->research.researching),
- game.player_ptr->research.bulbs_researched,
+ get_player_research(game.player_ptr)->researching),
+ get_player_research(game.player_ptr)->bulbs_researched,
total_bulbs_required(game.player_ptr));
+ } else {
+ my_snprintf(cBuf, sizeof(cBuf), _("Research (F6)\n%s (%d/%d)"),
+ get_tech_name(game.player_ptr,
+ get_player_research(game.player_ptr)->researching),
+ get_player_research(game.player_ptr)->bulbs_researched,
+ 0);
+ }
copy_chars_to_string16(pBuf->string16, cBuf);
- set_new_icon2_theme(pBuf, GET_SURF(bulb), FALSE);
+ set_new_icon2_theme(pBuf, adj_surf(GET_SURF(bulb)), FALSE);
+
redraw_widget(pBuf);
sdl_dirty_rect(pBuf->size);
}
+/****************************************************************************
+ Called when the map size changes. This may be used to change the
+ size of the GUI element holding the overview canvas. The
+ overview.width and overview.height are updated if this function is
+ called.
+****************************************************************************/
+void overview_size_changed(void)
+{
+ map_canvas_resized(Main.screen->w, Main.screen->h);
+
+ if (overview_canvas) {
+ canvas_free(overview_canvas);
+ }
+
+ overview_canvas = canvas_create(MINI_MAP_W - BLOCKM_W - DOUBLE_FRAME_WH,
+ MINI_MAP_H - DOUBLE_FRAME_WH);
+
+ center_minimap_on_minimap_window();
+}
+
/**************************************************************************
Typically an info box is provided to tell the player about the state
of their civilization. This function is called when the label is
@@ -459,19 +585,25 @@
void update_info_label(void)
{
SDL_Surface *pTmp = NULL;
- SDL_Rect area = {0, 3, 0, 0};
Uint32 color = 0x0;/* black */
SDL_Color col = {0, 0, 0, 80};
char buffer[512];
+
+ #ifdef SMALL_SCREEN
+ SDL_Rect area = {0, 0, 0, 0};
+ SDL_String16 *pText = create_string16(NULL, 0, 8);
+ #else
+ SDL_Rect area = {0, 3, 0, 0};
SDL_String16 *pText = create_string16(NULL, 0, 10);
+ #endif
/* set text settings */
pText->style |= TTF_STYLE_BOLD;
- pText->fgcol.r = 255;
- pText->fgcol.g = 255;
- pText->fgcol.b = 255;
-
+ pText->fgcol = (SDL_Color) {255, 255, 255, 255};
+ pText->render = 3;
+ pText->bgcol = col;
+ if (game.player_ptr) {
my_snprintf(buffer, sizeof(buffer),
_("%s Population: %s Year: %s "
"Gold %d Tax: %d Lux: %d Sci: %d "),
@@ -483,16 +615,13 @@
game.player_ptr->economic.luxury,
game.player_ptr->economic.science);
- pText->render = 3;
- pText->bgcol = col;
-
/* convert to unistr and create text surface */
copy_chars_to_string16(pText, buffer);
pTmp = create_text_surf_from_str16(pText);
- area.x = (Main.gui->w - pTmp->w) / 2 - 5;
- area.w = pTmp->w + 8;
- area.h = pTmp->h + 4;
+ area.x = (Main.gui->w - pTmp->w) / 2 - adj_size(5);
+ area.w = pTmp->w + adj_size(8);
+ area.h = pTmp->h + adj_size(4);
color = SDL_MapRGBA(Main.gui->format, col.r, col.g, col.b, col.unused);
SDL_FillRect(Main.gui, &area , color);
@@ -515,11 +644,12 @@
SDL_SetAlpha(pTmp, 0x0, 0x0);
/* blit text to screen */
- blit_entire_src(pTmp, Main.gui, area.x + 5, area.y + 2);
+ blit_entire_src(pTmp, Main.gui, area.x + adj_size(5), area.y +
adj_size(2));
sdl_dirty_rect(area);
FREESURFACE(pTmp);
+ }
set_indicator_icons(client_research_sprite(),
client_warming_sprite(),
@@ -552,6 +682,8 @@
SDL_Rect src, area = {pInfo_Window->size.x, pInfo_Window->size.y, 0, 0};
SDL_Surface *pBuf_Surf;
SDL_String16 *pStr;
+ struct canvas *destcanvas;
+ int infra_count;
if (SDL_Client_Flags & CF_UNIT_INFO_SHOW) {
/* Unit Window is Show */
@@ -566,12 +698,12 @@
char buffer[512];
struct city *pCity = player_find_city_by_id(game.player_ptr,
pUnit->homecity);
- struct tile *pTile = map_get_tile(pUnit->x, pUnit->y);
- int infrastructure = get_tile_infrastructure_set(pTile);
+ struct tile *pTile = pUnit->tile;
+ bv_special infrastructure = get_tile_infrastructure_set(pTile,
&infra_count);
pStr = pInfo_Window->string16;
- change_ptsize16(pStr, 12);
+ change_ptsize16(pStr, adj_font(12));
/* get and draw unit name (with veteran status) */
copy_chars_to_string16(pStr, unit_type(pUnit)->name);
@@ -591,7 +723,7 @@
if(pUnit->veteran) {
copy_chars_to_string16(pStr, _("veteran"));
- change_ptsize16(pStr, 10);
+ change_ptsize16(pStr, adj_font(10));
pStr->fgcol.b = 255;
pVet_Name = create_text_surf_from_str16(pStr);
SDL_SetAlpha(pVet_Name, 0x0, 0x0);
@@ -599,15 +731,15 @@
}
/* get and draw other info (MP, terran, city, etc.) */
- change_ptsize16(pStr, 10);
+ change_ptsize16(pStr, adj_font(10));
my_snprintf(buffer, sizeof(buffer), "%s\n%s\n%s%s%s",
(hover_unit == pUnit->id) ? _("Select destination") :
unit_activity_text(pUnit),
sdl_map_get_tile_info_text(pTile),
- infrastructure ?
+ (infra_count > 0) ?
get_infrastructure_text(infrastructure) : "",
- infrastructure ? "\n" : "", pCity ? pCity->name : _("NONE"));
+ (infra_count > 0) ? "\n" : "", pCity ? pCity->name :
_("NONE"));
copy_chars_to_string16(pStr, buffer);
pInfo = create_text_surf_from_str16(pStr);
@@ -652,7 +784,8 @@
/* Look at city owner, not tile owner (the two should be the same,
if
* borders are in use). */
struct player *pOwner = city_owner(pTile->city);
- bool citywall, barrack = FALSE, airport = FALSE, port = FALSE;
+ bool citywall;
+/* bool barrack = FALSE, airport = FALSE, port = FALSE;*/
const char *diplo_city_adjectives[DS_LAST] =
{Q_("?city:Neutral"), Q_("?city:Hostile"),
"" /*unused, DS_CEASEFIRE */, Q_("?city:Peaceful"),
@@ -661,13 +794,12 @@
cat_snprintf(buffer, sizeof(buffer), _("\nCity of %s"),
pTile->city->name);
citywall = city_got_citywalls(pTile->city);
+
+#if 0
if (pplayers_allied(game.player_ptr, pOwner)) {
- barrack = (city_affected_by_wonder(pTile->city, B_SUNTZU) ||
- city_got_building(pTile->city, B_BARRACKS) ||
- city_got_building(pTile->city, B_BARRACKS2) ||
- city_got_building(pTile->city, B_BARRACKS3));
- airport = city_got_effect(pTile->city, B_AIRPORT);
- port = city_got_effect(pTile->city, B_PORT);
+ barrack = (get_city_bonus(pTile->city, EFT_LAND_REGEN) > 0);
+ airport = (get_city_bonus(pTile->city, EFT_AIR_VETERAN) > 0);
+ port = (get_city_bonus(pTile->city, EFT_SEA_VETERAN) > 0);
}
if (citywall || barrack || airport || port) {
@@ -694,6 +826,7 @@
cat_snprintf(buffer, sizeof(buffer), _("City Walls"));
}
}
+#endif
if (pOwner && pOwner != game.player_ptr) {
/* TRANS: (<nation>,<diplomatic_state>)" */
@@ -708,18 +841,18 @@
if (pInfo_Window->size.h > 4 * h + DEFAULT_UNITS_H || right) {
cat_snprintf(buffer, sizeof(buffer), _("\nFood/Prod/Trade: %s"),
- get_tile_output_text(pUnit->x, pUnit->y));
+ get_tile_output_text(pUnit->tile));
}
copy_chars_to_string16(pStr, buffer);
- pInfo_II = create_text_surf_smaller_that_w(pStr, width - BLOCK_W - 10);
+ pInfo_II = create_text_surf_smaller_that_w(pStr, width - BLOCKU_W -
adj_size(10));
SDL_SetAlpha(pInfo_II, 0x0, 0x0);
}
/* ------------------------------------------- */
- n = unit_list_size(&pTile->units);
+ n = unit_list_size(pTile->units);
y = 0;
if (n > 1 && ((!right && pInfo_II
@@ -736,26 +869,26 @@
sy = y + DOUBLE_FRAME_WH;
area.y = pInfo_Window->size.y + sy;
- area.x = pInfo_Window->size.x + FRAME_WH + BLOCK_W +
- (width - pName->w - BLOCK_W - DOUBLE_FRAME_WH) / 2;
+ area.x = pInfo_Window->size.x + FRAME_WH + BLOCKU_W +
+ (width - pName->w - BLOCKU_W - DOUBLE_FRAME_WH) / 2;
SDL_BlitSurface(pName, NULL, pInfo_Window->dst, &area);
sy += pName->h;
if(pVet_Name) {
- area.y += pName->h - 3;
- area.x = pInfo_Window->size.x + FRAME_WH + BLOCK_W +
- (width - pVet_Name->w - BLOCK_W - DOUBLE_FRAME_WH) / 2;
+ area.y += pName->h - adj_size(3);
+ area.x = pInfo_Window->size.x + FRAME_WH + BLOCKU_W +
+ (width - pVet_Name->w - BLOCKU_W - DOUBLE_FRAME_WH) / 2;
SDL_BlitSurface(pVet_Name, NULL, pInfo_Window->dst, &area);
- sy += pVet_Name->h - 3;
+ sy += pVet_Name->h - adj_size(3);
FREESURFACE(pVet_Name);
}
FREESURFACE(pName);
/* draw unit sprite */
- pBuf_Surf = GET_SURF(unit_type(pUnit)->sprite);
+ pBuf_Surf = adj_surf(GET_SURF(get_unittype_sprite(tileset,
pUnit->type)));
src = get_smaller_surface_rect(pBuf_Surf);
- sx = FRAME_WH + BLOCK_W + 3 +
- (width / 2 - src.w - 3 - BLOCK_W - FRAME_WH) / 2;
+ sx = FRAME_WH + BLOCKU_W + adj_size(3) +
+ (width / 2 - src.w - adj_size(3) - BLOCKU_W -
FRAME_WH) / 2;
area.x = pInfo_Window->size.x + sx + src.w +
(width - (sx + src.w) - FRAME_WH - pInfo->w) / 2;
@@ -781,8 +914,8 @@
(height - FRAME_WH - pInfo_II->h) / 2;
} else {
area.y = pInfo_Window->size.y + DEFAULT_UNITS_H + y;
- area.x = pInfo_Window->size.x + BLOCK_W +
- (width - BLOCK_W - pInfo_II->w) / 2;
+ area.x = pInfo_Window->size.x + BLOCKU_W +
+ (width - BLOCKU_W - pInfo_II->w) / 2;
}
/* blit unit info text */
@@ -808,7 +941,7 @@
if (pDlg->pEndActiveWidgetList && pDlg->pBeginActiveWidgetList) {
del_group(pDlg->pBeginActiveWidgetList, pDlg->pEndActiveWidgetList);
}
- num_w = (pInfo_Window->size.w - BLOCK_W - DOUBLE_FRAME_WH) / 68;
+ num_w = (pInfo_Window->size.w - BLOCKU_W - DOUBLE_FRAME_WH) / 68;
num_h = (pInfo_Window->size.h - sy - FRAME_WH) / 52;
pDock = pInfo_Window;
n = 0;
@@ -817,7 +950,7 @@
continue;
}
- pUType = get_unit_type(aunit->type);
+ pUType = aunit->type;
pHome_City = find_city_by_id(aunit->homecity);
my_snprintf(buffer, sizeof(buffer), "%s
(%d,%d,%d)%s\n%s\n(%d/%d)\n%s",
pUType->name, pUType->attack_strength,
@@ -830,7 +963,12 @@
pBuf_Surf = create_surf(tileset_full_tile_width(tileset),
tileset_full_tile_height(tileset),
SDL_SWSURFACE);
- put_unit_pixmap_draw(aunit, pBuf_Surf, 0, 0);
+ destcanvas = canvas_create(tileset_full_tile_width(tileset),
tileset_full_tile_height(tileset));
+
+ put_unit(aunit, destcanvas, 0, 0);
+ SDL_BlitSurface(adj_surf(destcanvas->surf), NULL, pBuf_Surf, NULL);
+
+ canvas_free(destcanvas);
if (pBuf_Surf->w > 64) {
float zoom = 64.0 / pBuf_Surf->w;
@@ -915,7 +1053,7 @@
}
setup_vertical_widgets_position(num_w,
- pInfo_Window->size.x + FRAME_WH + BLOCK_W + 2,
+ pInfo_Window->size.x + FRAME_WH + BLOCKU_W +
adj_size(2),
pInfo_Window->size.y + sy +
(pInfo_Window->size.h - sy - num_h * 52) / 2,
0, 0, pDlg->pBeginActiveWidgetList,
@@ -939,17 +1077,20 @@
if (pInfo_Window->private_data.adv_dlg->pScroll) {
hide_scrollbar(pInfo_Window->private_data.adv_dlg->pScroll);
}
- change_ptsize16(pInfo_Window->string16, 14);
+
+ if (game.player_ptr) {
+ change_ptsize16(pInfo_Window->string16, adj_font(14));
copy_chars_to_string16(pInfo_Window->string16,
_("End of Turn\n(Press Enter)"));
pBuf_Surf = create_text_surf_from_str16(pInfo_Window->string16);
SDL_SetAlpha(pBuf_Surf, 0x0, 0x0);
- area.x = pInfo_Window->size.x + BLOCK_W +
- (pInfo_Window->size.w - BLOCK_W - pBuf_Surf->w)/2;
+ area.x = pInfo_Window->size.x + BLOCKU_W +
+ (pInfo_Window->size.w - BLOCKU_W - pBuf_Surf->w)/2;
area.y = pInfo_Window->size.y + (pInfo_Window->size.h - pBuf_Surf->h)/2;
SDL_BlitSurface(pBuf_Surf, NULL, pInfo_Window->dst, &area);
FREESURFACE(pBuf_Surf);
}
+ }
redraw_group(pInfo_Window->private_data.adv_dlg->pBeginWidgetList,
pInfo_Window->private_data.adv_dlg->pEndWidgetList->prev, 0);
@@ -980,7 +1121,7 @@
**************************************************************************/
void set_unit_icon(int idx, struct unit *punit)
{
-/* Balast */
+ update_unit_info_label(punit);
}
/**************************************************************************
@@ -1022,7 +1163,7 @@
enable_focus_animation();
}
if (hover_unit != pUnit->id) {
- set_hover_state(NULL, HOVER_NONE, ACTIVITY_LAST);
+ set_hover_state(NULL, HOVER_NONE, ACTIVITY_LAST, ORDER_LAST);
}
switch (hover_state) {
case HOVER_NONE:
@@ -1122,298 +1263,6 @@
dirty_all();
}
-/**************************************************************************
- Clear the city descriptions out of the buffer.
-**************************************************************************/
-void prepare_show_city_descriptions(void)
-{
- /* Nothing */
-}
-
-/**************************************************************************
- Draw a description for the given city onto the surface.
-**************************************************************************/
-static void put_city_desc_on_surface(SDL_Surface *pDest,
- struct city *pCity,
- int canvas_x, int canvas_y,
- int *width, int *height)
-{
- static char buffer[128];
- SDL_Surface *pCity_Size = NULL, *pCity_Name = NULL, *pCity_Prod = NULL;
- int togrow;
- SDL_String16 *pText = NULL;
- SDL_Rect dst, clear_area = {0, 0, 0, 0};
- SDL_Color color_size = *(get_game_colorRGB(
- player_color(get_player(pCity->owner))));
- SDL_Color color_bg = {0, 0, 0, 80};
- Uint32 frame_color;
-
- *width = *height = 0; /* TODO */
-
- color_size.unused = 128;
-
- pText = create_string16(NULL, 0, 10);
- pText->style |= (TTF_STYLE_BOLD|SF_CENTER);
- pText->fgcol = *(get_game_colorRGB(COLOR_STD_WHITE));
-
- if (SDL_Client_Flags & CF_CIV3_CITY_TEXT_STYLE)
- {
- pText->render = 3;
- pText->bgcol = color_bg;
- }
-
- canvas_y += tileset_tile_height(tileset);
-
- if (draw_city_names) {
- if (draw_city_growth && pCity->owner == game.player_idx) {
- togrow = city_turns_to_grow(pCity);
- switch (togrow) {
- case 0:
- my_snprintf(buffer, sizeof(buffer), "%s: #", pCity->name);
- break;
- case FC_INFINITY:
- my_snprintf(buffer, sizeof(buffer), "%s: --", pCity->name);
- break;
- default:
- my_snprintf(buffer, sizeof(buffer), "%s: %d", pCity->name, togrow);
- break;
- }
- } else {
- /* Force certain behavior below. */
- togrow = 0;
- my_snprintf(buffer, sizeof(buffer), "%s\n%s", pCity->name ,
- get_nation_name(get_player(pCity->owner)->nation));
- }
-
- if (togrow < 0) {
- /* set RED */
- pText->fgcol.g = 0;
- pText->fgcol.b = 0;
- }
-
- copy_chars_to_string16(pText, buffer);
- pCity_Name = create_text_surf_from_str16(pText);
-
- if (togrow < 0) {
- /* set white */
- pText->fgcol.g = 255;
- pText->fgcol.b = 255;
- }
- }
-
- /* City Production */
- if (draw_city_productions && pCity->owner == game.player_idx) {
- /* set text color */
- if (pCity->production.is_unit) {
- pText->fgcol.r = 255;
- pText->fgcol.g = 255;
- pText->fgcol.b = 0;
- } else {
- if (get_improvement_type(pCity->production.value)->is_wonder) {
- pText->fgcol.r = 0xe2;
- pText->fgcol.g = 0xc2;
- pText->fgcol.b = 0x1f;
- } else {
- pText->fgcol.r = 255;
- pText->fgcol.g = 255;
- pText->fgcol.b = 255;
- }
- }
-
- get_city_mapview_production(pCity, buffer, sizeof(buffer));
-
- copy_chars_to_string16(pText, buffer);
- pCity_Prod = create_text_surf_from_str16(pText);
-
- }
- else
- {
- if (!pCity_Name && (SDL_Client_Flags & CF_CIV3_CITY_TEXT_STYLE))
- {
- /* Civ3 style don't draw player flag and size
- outside city description and that is reason I made this hack */
- my_snprintf(buffer, sizeof(buffer), "%s",
- get_nation_name(get_player(pCity->owner)->nation));
-
- copy_chars_to_string16(pText, buffer);
- pCity_Prod = create_text_surf_from_str16(pText);
- }
- }
-
-
- if (SDL_Client_Flags & CF_CIV3_CITY_TEXT_STYLE)
- {
-
- /* city size */
- if (pCity_Name || pCity_Prod) {
- my_snprintf(buffer , sizeof(buffer), "%d", pCity->size);
- copy_chars_to_string16(pText, buffer);
- pText->style |= TTF_STYLE_BOLD;
- pText->fgcol.r = 255;
- pText->fgcol.g = 255;
- pText->fgcol.b = 255;
- pText->bgcol = color_size;
- pCity_Size = create_text_surf_from_str16(pText);
-
- clear_area.y = canvas_y;
- }
-
- if (pCity_Name)
- {
- clear_area.w = pCity_Name->w + 6;
- clear_area.h = pCity_Name->h;
- }
-
- if (pCity_Prod)
- {
- clear_area.h += pCity_Prod->h;
- clear_area.w = MAX(clear_area.w , pCity_Prod->w + 6);
- }
-
- clear_area.h += 2;
- if (pCity_Name && pCity_Prod) {
- clear_area.h += 1;
- }
-
- if (pCity_Size)
- {
- /* this isn't a error */
- clear_area.w += pCity_Size->h + 1;
- clear_area.h = MAX(clear_area.h , pCity_Size->h + 2);
- }
-
- if (clear_area.w)
- {
- clear_area.x = canvas_x + (tileset_tile_width(tileset) - clear_area.w) /
2;
- }
-
- if (pCity_Size)
- {
-
- frame_color = SDL_MapRGB(pDest->format, color_size.r ,color_size.g,
- color_size.b);
-
- /* solid citi size background */
- dst = clear_area;
- SDL_FillRect(pDest, &dst,
- SDL_MapRGBA(pDest->format, color_bg.r, color_bg.g,
- color_bg.b, color_bg.unused));
- /* solid text background */
- dst.w = pCity_Size->h + 1;
- SDL_FillRect(pDest, &dst ,
- SDL_MapRGBA(pDest->format, color_size.r, color_size.g,
- color_size.b, color_size.unused));
-
- /* blit city size number */
- SDL_SetAlpha(pCity_Size, 0x0, 0x0);
-
- /* this isn't error */
- dst.x = clear_area.x + (pCity_Size->h - pCity_Size->w) / 2;
- dst.y = canvas_y + (clear_area.h - pCity_Size->h) / 2;
- SDL_BlitSurface(pCity_Size, NULL, pDest, &dst);
-
- /* Draw Frame */
- /* Horizontal lines */
- putline(pDest, clear_area.x , clear_area.y - 1,
- clear_area.x + clear_area.w,
- clear_area.y - 1, frame_color);
- putline(pDest, clear_area.x, clear_area.y + clear_area.h,
- clear_area.x + clear_area.w,
- clear_area.y + clear_area.h, frame_color);
-
- if (pCity_Name && pCity_Prod) {
- putline(pDest, clear_area.x + 1 + pCity_Size->h,
- clear_area.y + pCity_Name->h,
- clear_area.x + clear_area.w,
- clear_area.y + pCity_Name->h, frame_color);
- }
-
- /* vertical lines */
- putline(pDest, clear_area.x + clear_area.w, clear_area.y,
- clear_area.x + clear_area.w,
- clear_area.y + clear_area.h, frame_color);
- putline(pDest, clear_area.x - 1, clear_area.y, clear_area.x - 1,
- clear_area.y + clear_area.h, frame_color);
-
-
- putline(pDest, clear_area.x + 1 + pCity_Size->h, clear_area.y,
- clear_area.x + 1 + pCity_Size->h,
- clear_area.y + clear_area.h, frame_color);
- }
-
- if (pCity_Name)
- {
- SDL_SetAlpha(pCity_Name, 0x0, 0x0);
- dst.x = clear_area.x + pCity_Size->h + 2 +
- (clear_area.w - (pCity_Size->h + 2) - pCity_Name->w) / 2;
- if (pCity_Prod) {
- dst.y = canvas_y;
- } else {
- dst.y = canvas_y + (clear_area.h - pCity_Name->h) / 2;
- }
- SDL_BlitSurface(pCity_Name, NULL, pDest, &dst);
- canvas_y += pCity_Name->h;
- }
-
- if (pCity_Prod)
- {
- SDL_SetAlpha(pCity_Prod, 0x0, 0x0);
- dst.x = clear_area.x + pCity_Size->h + 2 +
- (clear_area.w - (pCity_Size->h + 2) - pCity_Prod->w) / 2;
- if (pCity_Name) {
- dst.y = canvas_y + 1;
- } else {
- dst.y = canvas_y + (clear_area.h - pCity_Prod->h) / 2;
- }
- SDL_BlitSurface(pCity_Prod, NULL, pDest, &dst);
- }
- }
- else
- {
- if (pCity_Name)
- {
- SDL_SetAlpha(pCity_Name, 0x0, 0x0);
- dst.x = canvas_x + (tileset_tile_width(tileset) - pCity_Name->w) / 2;
- dst.y = canvas_y;
- SDL_BlitSurface(pCity_Name, NULL, pDest, &dst);
- canvas_y += pCity_Name->h;
- }
-
- if (pCity_Prod)
- {
- SDL_SetAlpha(pCity_Prod, 0x0, 0x0);
- dst.x = canvas_x + (tileset_tile_width(tileset) - pCity_Prod->w) / 2;
- dst.y = canvas_y;
- SDL_BlitSurface(pCity_Prod, NULL, pDest, &dst);
- }
-
- }
-
- FREESURFACE(pCity_Prod);
- FREESURFACE(pCity_Name);
- FREESURFACE(pCity_Size);
- FREESTRING16(pText);
-}
-
-/****************************************************************************
- Draw a description for the given city. This description may include the
- name, turns-to-grow, production, and city turns-to-build (depending on
- client options).
-
- (canvas_x, canvas_y) gives the location on the given canvas at which to
- draw the description. This is the location of the city itself so the
- text must be drawn underneath it. pcity gives the city to be drawn,
- while (*width, *height) should be set by show_ctiy_desc to contain the
- width and height of the text block (centered directly underneath the
- city's tile).
-****************************************************************************/
-void show_city_desc(struct canvas *pcanvas, int canvas_x, int canvas_y,
- struct city *pcity, int *width, int *height)
-{
- put_city_desc_on_surface(Main.map, pcity,
- canvas_x, canvas_y, width, height);
-}
-
/* ===================================================================== */
/* =============================== Mini Map ============================ */
/* ===================================================================== */
@@ -1423,16 +1272,17 @@
**************************************************************************/
void center_minimap_on_minimap_window(void)
{
- struct GUI *pMMap = get_minimap_window_widget();
- OVERVIEW_START_X = FRAME_WH +
- (pMMap->size.w - 30 - DOUBLE_FRAME_WH -
- OVERVIEW_TILE_WIDTH * map.xsize) / 2;
- OVERVIEW_START_Y = FRAME_WH + (pMMap->size.h - DOUBLE_FRAME_WH -
- OVERVIEW_TILE_HEIGHT * map.ysize) / 2;
+ /* FIXME: really center */
+ OVERVIEW_START_X = FRAME_WH;
+ OVERVIEW_START_Y = FRAME_WH;
}
+/**************************************************************************
+...
+**************************************************************************/
void toggle_overview_mode(void)
{
+ /* FIXME: has no effect anymore */
if (overview_mode == BORDERS) {
overview_mode = NORMAL;
} else {
@@ -1440,10 +1290,22 @@
}
}
+/****************************************************************************
+ Return a canvas that is the overview window.
+****************************************************************************/
struct canvas *get_overview_window(void)
{
- /* TODO */
- return NULL;
+ return overview_canvas;
+}
+
+/****************************************************************************
+ Return the dimensions of the area (container widget; maximum size) for
+ the overview.
+****************************************************************************/
+void get_overview_area_dimensions(int *width, int *height)
+{
+ *width = MINI_MAP_W - BLOCKM_W - DOUBLE_FRAME_WH;
+ *height = MINI_MAP_H - DOUBLE_FRAME_WH;
}
/**************************************************************************
@@ -1468,11 +1330,16 @@
if (SDL_Client_Flags & CF_MINI_MAP_SHOW) {
+ SDL_Rect dst = {OVERVIEW_START_X, OVERVIEW_START_Y, 0, 0};
+ SDL_BlitSurface(overview_canvas->surf, NULL,
+ pMMap->theme, &dst);
+
SDL_BlitSurface(pMMap->theme, NULL, pMMap->dst, &map_area);
+#if 0
map_area.x += OVERVIEW_START_X;
map_area.y += OVERVIEW_START_Y;
- map_area.w = MIN(pMMap->size.w - 30 - DOUBLE_FRAME_WH,
+ map_area.w = MIN(pMMap->size.w - BLOCKM_W - DOUBLE_FRAME_WH,
OVERVIEW_TILE_WIDTH * map.xsize);
map_area.h = MIN(pMMap->size.h - DOUBLE_FRAME_WH,
OVERVIEW_TILE_HEIGHT * map.ysize);
@@ -1482,6 +1349,7 @@
map_area.x + map_area.w + 1,
map_area.y + map_area.h + 1, 0xFFFFFFFF);
}
+#endif
refresh_overview_canvas();
/* ===== */
@@ -1490,7 +1358,7 @@
/* redraw widgets */
/* ID_NEW_TURN */
- pBuf = pMMap->prev;
+ pBuf = get_widget_pointer_form_ID(pMMap, ID_NEW_TURN, SCAN_BACKWARD);
if (!pBuf->gfx) {
pBuf->gfx = crop_rect_from_surface(pBuf->dst, &pBuf->size);
}
@@ -1499,8 +1367,7 @@
/* ===== */
/* ID_PLAYERS */
- pBuf = pBuf->prev;
-
+ pBuf = get_widget_pointer_form_ID(pMMap, ID_PLAYERS, SCAN_BACKWARD);
if (!pBuf->gfx) {
pBuf->gfx = crop_rect_from_surface(pBuf->dst, &pBuf->size);
}
@@ -1509,7 +1376,7 @@
/* ===== */
/* ID_CITIES */
- pBuf = pBuf->prev;
+ pBuf = get_widget_pointer_form_ID(pMMap, ID_CITIES, SCAN_BACKWARD);
if (!pBuf->gfx) {
pBuf->gfx = crop_rect_from_surface(pBuf->dst, &pBuf->size);
@@ -1519,7 +1386,7 @@
/* ===== */
/* ID_UNITS */
- pBuf = pBuf->prev;
+ pBuf = get_widget_pointer_form_ID(pMMap, ID_UNITS, SCAN_BACKWARD);
if((get_wflags(pBuf) & WF_HIDDEN) != WF_HIDDEN) {
if (!pBuf->gfx) {
pBuf->gfx = crop_rect_from_surface(pBuf->dst, &pBuf->size);
@@ -1530,7 +1397,8 @@
/* ===== */
/* ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON */
- pBuf = pBuf->prev;
+ pBuf = get_widget_pointer_form_ID(pMMap,
ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON,
+ SCAN_BACKWARD);
if((get_wflags(pBuf) & WF_HIDDEN) != WF_HIDDEN) {
if (!pBuf->gfx) {
pBuf->gfx = crop_rect_from_surface(pBuf->dst, &pBuf->size);
@@ -1542,7 +1410,18 @@
/* ===== */
/* Toggle minimap mode */
- pBuf = pBuf->prev;
+ pBuf = get_widget_pointer_form_ID(pMMap, ID_TOGGLE_MINIMAP_MODE,
SCAN_BACKWARD);
+ if((get_wflags(pBuf) & WF_HIDDEN) != WF_HIDDEN) {
+ if (!pBuf->gfx) {
+ pBuf->gfx = crop_rect_from_surface(pBuf->dst, &pBuf->size);
+ }
+
+ real_redraw_icon(pBuf);
+ }
+
+ #ifdef SMALL_SCREEN
+ /* options */
+ pBuf = get_widget_pointer_form_ID(pMMap, ID_CLIENT_OPTIONS,
SCAN_BACKWARD);
if((get_wflags(pBuf) & WF_HIDDEN) != WF_HIDDEN) {
if (!pBuf->gfx) {
pBuf->gfx = crop_rect_from_surface(pBuf->dst, &pBuf->size);
@@ -1550,11 +1429,12 @@
real_redraw_icon(pBuf);
}
+ #endif
/* ===== */
/* ID_TOGGLE_MAP_WINDOW_BUTTON */
- pBuf = pBuf->prev;
-
+ pBuf = get_widget_pointer_form_ID(pMMap, ID_TOGGLE_MAP_WINDOW_BUTTON,
+
SCAN_BACKWARD);
if (!pBuf->gfx && pBuf->theme) {
pBuf->gfx = crop_rect_from_surface(pBuf->dst, &pBuf->size);
}
@@ -1562,520 +1442,25 @@
real_redraw_icon(pBuf);
sdl_dirty_rect(pMMap->size);
-
- } else {/* map hiden */
-
-#if 0
- src.y = 0;
- src.h = pMMap->theme->h;
- src.x = pMMap->theme->w - pMMap->size.w;
- src.w = pMMap->size.w;
- map_area.w = pMMap->theme->w;
- map_area.h = pMMap->theme->h;
-
- /* clear area under old map window */
- SDL_FillRect(pMMap->dst, &map_area , 0x0);
-
- /*map_area.x = 0;
- map_area.y = Main.gui->h - pMMap->size.h;*/
- SDL_BlitSurface(pMMap->theme, &src, pMMap->dst, &map_area);
-
-
- SDL_Surface *pBuf_Surf =
- ResizeSurface(pTheme->FR_Vert, pTheme->FR_Vert->w,
- pMMap->size.h - DOUBLE_FRAME_WH + 2, 1);
-
- map_area.y += 2;
- SDL_BlitSurface(pBuf_Surf, NULL , pMMap->dst, &map_area);
- FREESURFACE(pBuf_Surf);
-
- /* ID_NEW_TURN */
- real_redraw_icon(pBuf);
-
- /* ID_CHATLINE_TOGGLE_LOG_WINDOW_BUTTON */
- pBuf = pBuf->prev;
- real_redraw_icon(pBuf);
-
- /* ID_FIND_CITY */
- pBuf = pBuf->prev;
- real_redraw_icon(pBuf);
-
- /* ID_TOGGLE_MAP_WINDOW_BUTTON */
- pBuf = pBuf->prev;
- real_redraw_icon(pBuf);
-
-
- /*add_refresh_rect(pMMap->size);*/
-#endif
}
}
-/* ===================================================================== */
-/* ===================================================================== */
-/* ===================================================================== */
-
+static bool reset_anim = FALSE;
/**************************************************************************
- Draw City's surfaces to 'pDest' on position 'map_x' , 'map_y'.
+ Force rebuild sellecting unit animation frames
**************************************************************************/
-static void put_city_pixmap_draw(struct city *pCity, SDL_Surface *pDest,
- Sint16 map_x, Sint16 map_y)
+void rebuild_focus_anim_frames(void)
{
- /* FIXME */
+ reset_anim = TRUE;
}
/**************************************************************************
- Draw Unit's surfaces to 'pDest' on position 'map_x' , 'map_y'.
+ Update (refresh) the locations of the mapview scrollbars (if it uses
+ them).
**************************************************************************/
-void put_unit_pixmap_draw(struct unit *pUnit, SDL_Surface *pDest,
- Sint16 map_x, Sint16 map_y)
-{
- if (pUnit) {
- struct canvas canvas = {.surf = pDest};
-
- put_unit_full(pUnit, &canvas, map_x, map_y);
- }
-}
-
-/**************************************************************************
-...
-**************************************************************************/
-static bool is_full_ocean(Terrain_type_id t, int x, int y)
-{
-
- if (is_ocean(t))
- {
- Terrain_type_id ter;
- adjc_iterate(x, y, x1, y1) {
- ter = tile_get_terrain(x1, y1);
- if (!is_ocean(ter) && ter != T_UNKNOWN) {
- return FALSE;
- }
- } adjc_iterate_end;
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**************************************************************************
- This function draw 1x1 [map_col]x[map_row] map cell to 'pDest' surface
- on map_x , map_y position.
- Main Draw Map Function... speed of this function is critical !
-**************************************************************************/
-static void draw_map_cell(SDL_Surface *pDest, Sint16 map_x, Sint16 map_y,
- Uint16 map_col, Uint16 map_row, int citymode)
-{
- static struct drawn_sprite pTile_sprs[80];
- static SDL_Surface *pDitherBufs[4];
- static SDL_Surface *pBufSurface = NULL;
- static SDL_Rect dst, des;
- static struct tile *pTile = NULL;
- static struct city *pCity = NULL;
- static struct unit *pUnit = NULL, *pFocus = NULL;
- static enum tile_special_type special;
- static Terrain_type_id terrain;
- static int count, i;
- static bool fog, full_ocean, solid_bg;
- enum color_std bg_color;
-
- count =
- fill_tile_sprite_array(pTile_sprs, &solid_bg, &bg_color,
- map_col, map_row, citymode);
-
- if (count == -1) { /* tile is unknown */
- des.x = map_x;
- des.y = map_y;
- SDL_BlitSurface(GET_SURF(sprites.black_tile), NULL, pDest, &des);
- return;
- }
-
- i = 0;
- pTile = map_get_tile(map_col, map_row);
- pCity = pTile->city;
- special = pTile->special;
- terrain = pTile->terrain;
- fog = (draw_fog_of_war && (enum known_type)pTile->known ==
TILE_KNOWN_FOGGED);
- pUnit = get_drawable_unit(map_col, map_row, citymode);
- pFocus = get_unit_in_focus();
- full_ocean = is_full_ocean(terrain, map_col, map_row);
-
- if (!full_ocean && !is_ocean(terrain) && (SDL_Client_Flags &
CF_DRAW_MAP_DITHER))
- {
- fill_dither_buffers(pDitherBufs, map_col, map_row, terrain);
- }
-
- if (fog && !full_ocean) {
- des.x = 0;
- des.y = HALF_tileset_tile_height(tileset);
- pBufSurface = pTmpSurface;
- } else {
- des.x = map_x;
- des.y = map_y;
- pBufSurface = pDest;
- }
-
- dst = des;
-
- des = dst;
-
- /*** Rest of terrain and specials ***/
- if (draw_terrain) {
- for (i = 0; i < count; i++) {
- if (pTile_sprs[i].sprite) {
- if (GET_SURF(pTile_sprs[i].sprite)->w - tileset_tile_width(tileset) > 0
- || GET_SURF(pTile_sprs[i].sprite)->h - tileset_tile_height(tileset)
> 0) {
- des.x -= ((GET_SURF(pTile_sprs[i].sprite)->w -
tileset_tile_width(tileset)) / 2); /* center */
- /* this allow drawing of civ3 bigger tiles */
- des.y -= (GET_SURF(pTile_sprs[i].sprite)->h -
tileset_tile_height(tileset));
- SDL_BlitSurface(GET_SURF(pTile_sprs[i].sprite), NULL, pBufSurface,
&des);
- } else {
- SDL_BlitSurface(GET_SURF(pTile_sprs[i].sprite), NULL, pBufSurface,
&des);
- }
- des = dst;
- } else {
- freelog(LOG_ERROR, _("sprite is NULL"));
- }
- }
- }
-
- /*** Map grid ***/
- if (draw_map_grid) {
- int color1 = 0, color2 = 0, x = map_col, y = map_row;
- if((SDL_Client_Flags & CF_DRAW_CITY_GRID) == CF_DRAW_CITY_GRID) {
- enum city_tile_type city_tile_type = C_TILE_EMPTY,
- city_tile_type1 = C_TILE_EMPTY, city_tile_type2 = C_TILE_EMPTY;
- struct city *dummy_pcity;
- bool is_in_city_radius =
- player_in_city_radius(game.player_ptr, map_col, map_row);
- bool pos1_is_in_city_radius = FALSE;
- bool pos2_is_in_city_radius = FALSE;
-
- if((SDL_Client_Flags & CF_DRAW_CITY_WORKER_GRID) ==
CF_DRAW_CITY_WORKER_GRID) {
- get_worker_on_map_position(x, y, &city_tile_type, &dummy_pcity);
- }
-
- x--;
- if (is_real_map_pos(x, y)) {
- normalize_map_pos(&x, &y);
- /*assert(is_tiles_adjacent(map_col, map_row, x, y));*/
-
- if ((enum known_type)(map_get_tile(x, y))->known != TILE_UNKNOWN) {
- pos1_is_in_city_radius = player_in_city_radius(game.player_ptr, x,
y);
- if((SDL_Client_Flags & CF_DRAW_CITY_WORKER_GRID) ==
CF_DRAW_CITY_WORKER_GRID) {
- get_worker_on_map_position(x, y, &city_tile_type1, &dummy_pcity);
- }
- }
- } else {
- city_tile_type1 = C_TILE_UNAVAILABLE;
- }
-
- x = map_col;
- y = map_row - 1;
- if (is_real_map_pos(x, y)) {
- normalize_map_pos(&x, &y);
- /*assert(is_tiles_adjacent(map_col, map_row, x, y));*/
-
- if ((enum known_type)(map_get_tile(x, y))->known != TILE_UNKNOWN) {
- pos2_is_in_city_radius = player_in_city_radius(game.player_ptr, x,
y);
- if((SDL_Client_Flags & CF_DRAW_CITY_WORKER_GRID) ==
CF_DRAW_CITY_WORKER_GRID) {
- get_worker_on_map_position(x, y, &city_tile_type2, &dummy_pcity);
- }
- }
- } else {
- city_tile_type2 = C_TILE_UNAVAILABLE;
- }
-
- if (is_in_city_radius || pos1_is_in_city_radius) {
- if (city_tile_type == C_TILE_WORKER || city_tile_type1 ==
C_TILE_WORKER) {
- color1 = 2;
- } else {
- color1 = 1;
- }
- }
- if (is_in_city_radius || pos2_is_in_city_radius) {
- if (city_tile_type == C_TILE_WORKER || city_tile_type2 ==
C_TILE_WORKER) {
- color2 = 2;
- } else {
- color2 = 1;
- }
- }
- }
- /* we draw buffers surfaces with 1 lines on top of the tile;
- the buttom lines will be drawn by the tiles underneath. */
- SDL_BlitSurface(pMapGrid[color1][0], NULL, pBufSurface, &des);
- des = dst;
- des.x += HALF_tileset_tile_width(tileset);
- SDL_BlitSurface(pMapGrid[color2][1], NULL, pBufSurface, &des);
- des = dst;
- }
-
- /* Draw national borders */
- if (draw_borders && (game.info.borders != 0)) {
- struct tile *pBorder_Tile;
- struct player *this_owner = pTile->owner;
- int x1, y1;
-
- /* left side */
- if (this_owner && MAPSTEP(x1, y1, map_col, map_row, DIR8_WEST)
- && (pBorder_Tile = map_get_tile(x1, y1))
- && (this_owner != pBorder_Tile->owner)
- && pBorder_Tile->known) {
- SDL_BlitSurface(pMapBorders[this_owner->player_no][0], NULL,
pBufSurface, &des);
- des = dst;
- }
- /* top side */
- if (this_owner && MAPSTEP(x1, y1, map_col, map_row, DIR8_NORTH)
- && (pBorder_Tile = map_get_tile(x1, y1))
- && (this_owner != pBorder_Tile->owner)
- && pBorder_Tile->known) {
- SDL_BlitSurface(pMapBorders[this_owner->player_no][1], NULL,
pBufSurface, &des);
- des = dst;
- }
- /* right side */
- if (this_owner && MAPSTEP(x1, y1, map_col, map_row, DIR8_EAST)
- && (pBorder_Tile = map_get_tile(x1, y1))
- && (this_owner != pBorder_Tile->owner)
- && pBorder_Tile->known) {
- SDL_BlitSurface(pMapBorders[this_owner->player_no][2], NULL,
pBufSurface, &des);
- des = dst;
- }
- /* bottom side */
- if (this_owner && MAPSTEP(x1, y1, map_col, map_row, DIR8_SOUTH)
- && (pBorder_Tile = map_get_tile(x1, y1))
- && (this_owner != pBorder_Tile->owner)
- && pBorder_Tile->known) {
- SDL_BlitSurface(pMapBorders[this_owner->player_no][3], NULL,
pBufSurface, &des);
- des = dst;
- }
- }
-
- /*** City and various terrain improvements ***/
- if (sdl_contains_special(special, S_FORTRESS) && draw_fortress_airbase) {
- SDL_BlitSurface(GET_SURF(sprites.tx.fortress_back),
- NULL, pBufSurface, &des);
- des = dst;
- }
-
- if (pCity && draw_cities) {
- put_city_pixmap_draw(pCity, pBufSurface,
- des.x, des.y - HALF_tileset_tile_height(tileset));
- }
-
- if (sdl_contains_special(special, S_AIRBASE) && draw_fortress_airbase) {
- SDL_BlitSurface(GET_SURF(sprites.tx.airbase), NULL, pBufSurface, &des);
- des = dst;
- }
-
- if (sdl_contains_special(special, S_FALLOUT) && draw_pollution) {
- SDL_BlitSurface(GET_SURF(sprites.tx.fallout), NULL, pBufSurface, &des);
- des = dst;
- }
-
- if (sdl_contains_special(special, S_POLLUTION) && draw_pollution) {
- SDL_BlitSurface(GET_SURF(sprites.tx.pollution), NULL, pBufSurface, &des);
- des = dst;
- }
-
- /*** city size ***/
- /* Not fogged as it would be unreadable */
- if ((!(SDL_Client_Flags & CF_CIV3_CITY_TEXT_STYLE)
- || (!draw_city_productions && !draw_city_names)) &&
- pCity && draw_cities) {
- if (pCity->size >= 10) {
- SDL_BlitSurface(GET_SURF(sprites.city.size_tens[pCity->size / 10]),
- NULL, pBufSurface, &des);
- des = dst;
- }
-
- SDL_BlitSurface(GET_SURF(sprites.city.size[pCity->size % 10]),
- NULL, pBufSurface, &des);
- des = dst;
- }
-
-
- /*** Unit ***/
- if (pUnit && (draw_units || (pUnit == pFocus && draw_focus_unit))) {
- put_unit_pixmap_draw(pUnit, pBufSurface, des.x,
- des.y - HALF_tileset_tile_height(tileset));
-
- if (!pCity && unit_list_size(&(pTile->units)) > 1) {
- des.y -= HALF_tileset_tile_height(tileset);
- SDL_BlitSurface(GET_SURF(sprites.unit.stack), NULL, pBufSurface, &des);
- des = dst;
- }
- }
-
- if (sdl_contains_special(special, S_FORTRESS) && draw_fortress_airbase) {
- SDL_BlitSurface(GET_SURF(sprites.tx.fortress), NULL, pBufSurface, &des);
- des = dst;
- }
-
-
- if (fog && !full_ocean) {
-
- SDL_FillRectAlpha(pBufSurface, NULL,
- get_game_colorRGB(COLOR_STD_FOG_OF_WAR));
-
- des.x = map_x;
- des.y = map_y - HALF_tileset_tile_height(tileset);
- SDL_BlitSurface(pBufSurface, NULL, pDest, &des);
-
- /* clear pBufSurface */
- /* if BytesPerPixel == 4 and Amask == 0 ( 24 bit coding ) alpha blit
- * functions Set A = 255 in all pixels and then pixel val
- * ( r=0, g=0, b=0) != 0. Real val of this pixel is
0xff000000/0x000000ff.*/
- if (pBufSurface->format->BytesPerPixel == 4
- && !pBufSurface->format->Amask) {
- SDL_FillRect(pBufSurface, NULL, Amask);
- } else {
- SDL_FillRect(pBufSurface, NULL, 0x0);
- }
-
- }
-
-}
-
-static int frame = 0;
-static bool reset_anim = FALSE;
-
-/**************************************************************************
- Force rebuild sellecting unit animation frames
-**************************************************************************/
-void rebuild_focus_anim_frames(void)
-{
- reset_anim = TRUE;
-}
-
-/**************************************************************************
- Draw sellecting unit animation
-**************************************************************************/
-void real_blink_active_unit(void)
-{
- static int oldCol = 0, oldRow = 0, canvas_x, canvas_y, next_x, next_y;
- static struct unit *pPrevUnit = NULL, *pUnit = NULL;
- static SDL_Rect area, backup;
- static struct city *pCity;
-
- if (draw_units && (pUnit = get_unit_in_focus())) {
- if(tile_to_canvas_pos(&canvas_x, &canvas_y, pUnit->x, pUnit->y)) {
- area.x = canvas_x;
- area.y = canvas_y - HALF_tileset_tile_height(tileset);
- backup = area;
- if (!reset_anim
- && pUnit == pPrevUnit && pUnit->type == pPrevUnit->type
- && pUnit->x == oldCol && pUnit->y == oldRow) {
- /* blit clear area */
- SDL_BlitSurface(pBlinkSurfaceA, NULL, Main.map, &area);
- area = backup;
- /* blit frame of animation */
- area.y += HALF_tileset_tile_height(tileset);
- SDL_BlitSurface(pAnim->Focus[frame++], NULL, Main.map, &area);
- area = backup;
- /* blit unit graphic */
- SDL_BlitSurface(pBlinkSurfaceB, NULL, Main.map, &area);
-
- flush_mapcanvas(area.x, area.y, tileset_full_tile_width(tileset),
tileset_full_tile_height(tileset));
-
- } else {
-
- if (reset_anim) {
- bool un = draw_units, unf = draw_focus_unit;
-
- draw_units = FALSE;
- draw_focus_unit = FALSE;
-
- draw_map_cell(Main.map, canvas_x, canvas_y, pUnit->x, pUnit->y, 0);
-
- draw_units = un;
- draw_focus_unit = unf;
- }
-
- /* refresh clear area */
- area.w = tileset_full_tile_width(tileset);
- area.h = tileset_full_tile_height(tileset);
- SDL_BlitSurface(Main.map, &area, pBlinkSurfaceA, NULL);
- area = backup;
-
- /* create unit graphic */
- SDL_FillRect(pBlinkSurfaceB, NULL, 0x0);
- put_unit_pixmap_draw(pUnit, pBlinkSurfaceB, 0, 0);
-
- /* left unit */
- next_x = pUnit->x;
- next_y = pUnit->y + 1;
- if(normalize_map_pos(&next_x, &next_y)) {
- if(draw_cities && (pCity = tile_get_city(next_x, next_y))) {
- put_city_pixmap_draw(pCity, pBlinkSurfaceB,
- -HALF_tileset_tile_width(tileset),
HALF_tileset_tile_height(tileset));
- } else {
- put_unit_pixmap_draw(get_drawable_unit(next_x, next_y, 0),
- pBlinkSurfaceB,
-HALF_tileset_tile_width(tileset),
-
HALF_tileset_tile_height(tileset));
- }
- }
-
- /* right unit */
- next_x = pUnit->x + 1;
- next_y = pUnit->y;
- if(normalize_map_pos(&next_x, &next_y)) {
- if((pCity = tile_get_city(next_x, next_y)) && draw_cities) {
- put_city_pixmap_draw(pCity, pBlinkSurfaceB,
- HALF_tileset_tile_width(tileset),
HALF_tileset_tile_height(tileset));
- } else {
- put_unit_pixmap_draw(get_drawable_unit(next_x, next_y, 0),
- pBlinkSurfaceB,
HALF_tileset_tile_width(tileset),
-
HALF_tileset_tile_height(tileset));
- if(!pCity &&
- unit_list_size(&map_get_tile(next_x, next_y)->units) > 1) {
- blit_entire_src(GET_SURF(sprites.unit.stack), pBlinkSurfaceB,
- HALF_tileset_tile_width(tileset),
HALF_tileset_tile_height(tileset));
- }
- }
- }
-
- /* botton unit */
- next_x = pUnit->x + 1;
- next_y = pUnit->y + 1;
- if(normalize_map_pos(&next_x, &next_y)) {
- if(draw_cities && (pCity = tile_get_city(next_x, next_y))) {
- put_city_pixmap_draw(pCity, pBlinkSurfaceB, 0,
tileset_tile_height(tileset));
- } else {
- put_unit_pixmap_draw(get_drawable_unit(next_x, next_y, 0),
- pBlinkSurfaceB, 0,
tileset_tile_height(tileset));
- }
- }
-
- /* draw focus animation frame */
- area.y += HALF_tileset_tile_height(tileset);
- SDL_BlitSurface(pAnim->Focus[frame++], NULL, Main.map, &area);
- area = backup;
-
- /* draw unit graphic */
- SDL_BlitSurface(pBlinkSurfaceB, NULL, Main.map, &area);
-
- flush_rect(area);
-
- pPrevUnit = pUnit;
- oldCol = pUnit->x;
- oldRow = pUnit->y;
- reset_anim = FALSE;
- }
- }
- }
-
- if(!(frame < pAnim->num_tiles_focused_unit)) {
- frame = 0;
- }
-
-}
-
-/**************************************************************************
- Update (refresh) the locations of the mapview scrollbars (if it uses
- them).
-**************************************************************************/
-void update_map_canvas_scrollbars(void)
+void update_map_canvas_scrollbars(void)
{
/* No scrollbars. */
}
@@ -2083,7 +1468,7 @@
/**************************************************************************
Draw a cross-hair overlay on a tile.
**************************************************************************/
-void put_cross_overlay_tile(int x, int y)
+void put_cross_overlay_tile(struct tile *ptile)
{
freelog(LOG_DEBUG, "MAPVIEW: put_cross_overlay_tile : PORT ME");
}
@@ -2094,6 +1479,8 @@
void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h)
{
/* PORTME */
+ putframe(Main.map, canvas_x, canvas_y, canvas_x + w, canvas_y + h,
+ SDL_MapRGB(Main.map->format, 255, 255, 255));
}
/**************************************************************************
@@ -2105,643 +1492,42 @@
/* Here you should do any necessary redraws (for instance, the city
* dialogs usually need to be resized). */
- free_dither_tiles();
- init_dither_tiles();
-
}
/* =====================================================================
City MAP
===================================================================== */
-/**************************************************************************
- normalize_map_pos + (y) corrections. This function must go to drink!
-**************************************************************************/
-int correction_map_pos(int *pCol, int *pRow)
+SDL_Surface *create_city_map(struct city *pCity)
{
- int iRet = 0;
-
- /* correction ... pCol and pRow must be in map :) */
- if (*pCol < 0) {
- *pCol += map.xsize;
- iRet = 1;
- } else {
- if (*pCol >= map.xsize) {
- *pCol -= map.xsize;
- iRet = 1;
- }
- }
+ /* city map dimensions might have changed, so create a new canvas each time
*/
- if (*pRow < 0) {
- *pRow += map.ysize;
- iRet = 1;
- } else if (*pRow >= map.ysize) {
- *pRow -= map.ysize;
- iRet = 1;
+ if (city_map_canvas) {
+ canvas_free(city_map_canvas);
}
- return iRet;
-}
+ city_map_canvas = canvas_create(get_citydlg_canvas_width(),
+ get_citydlg_canvas_height() + tileset_tile_height(tileset) / 2);
+ city_dialog_redraw_map(pCity, city_map_canvas);
-/**************************************************************************
- ...
-**************************************************************************/
-static SDL_Surface * create_iso_city_map(struct city *pCity)
-{
-#if 0
- register Uint16 col = 0, row;
- SDL_Rect dest;
- int draw_units_backup = draw_units;
- int draw_map_grid_backup = draw_map_grid;
- int sx, sy, row0, real_col = pCity->x, real_row = pCity->y;
-
- Sint16 x0 = 3 * tileset_tile_width(tileset) / 2;
- Sint16 y0 = 0;
- SDL_Surface *pTile = NULL;
- SDL_Surface *pDest = create_surf(get_citydlg_canvas_width(),
- get_citydlg_canvas_height()
- + HALF_tileset_tile_height(tileset),
SDL_SWSURFACE);
- real_col -= 2;
- real_row -= 2;
- correction_map_pos((int *) &real_col, (int *) &real_row);
- row0 = real_row;
-
- /* turn off drawing units and map_grid */
- draw_units = 0;
- draw_map_grid = 0;
-
- /* draw loop */
- for (; col < CITY_MAP_SIZE; col++) {
- for (row = 0; row < CITY_MAP_SIZE; row++) {
-#if 1
- sx = x0 + (col - row) * HALF_tileset_tile_width(tileset);
- sy = y0 + (row + col) * HALF_tileset_tile_height(tileset);
-
-#else
- /* ugly hack for speed. Assumes:
- * tileset_tile_width(tileset) == 64
- * tileset_tile_height(tileset) == 32 */
- sx = x0 + ((col - row) << 5);
- sy = y0 + ((row + col) << 4);
-#endif
- if (sx > -tileset_tile_width(tileset) && sx < pDest->w +
tileset_tile_width(tileset)
- && sy > -tileset_tile_height(tileset)
- && sy < pDest->h + tileset_tile_height(tileset)) {
- dest.x = sx;
- dest.y = sy;
- if ((!col && !row) ||
- (!col && row == CITY_MAP_SIZE - 1) ||
- (!row && col == CITY_MAP_SIZE - 1) ||
- (col == CITY_MAP_SIZE - 1 && row == CITY_MAP_SIZE - 1)) {
- /* draw black corners */
-
- SDL_BlitSurface(GET_SURF(sprites.black_tile),
- NULL, pDest, &dest);
- } else {
- /* draw map cell */
- draw_map_cell(pDest, dest.x, dest.y, real_col, real_row, 1);
- if (get_worker_city(pCity, col, row) == C_TILE_UNAVAILABLE &&
- tile_get_terrain(real_col, real_row) != T_UNKNOWN) {
- if (!pTile) {
-
- /* fill pTile with Mask Color */
- SDL_FillRect(pTmpSurface, NULL,
- SDL_MapRGB(pTmpSurface->format, 255, 0, 255));
-
- /* make mask */
- SDL_BlitSurface(GET_SURF(sprites.black_tile),
- NULL, pTmpSurface, NULL);
-
- SDL_SetColorKey(pTmpSurface, SDL_SRCCOLORKEY,
- getpixel(pTmpSurface,
HALF_tileset_tile_width(tileset),
- HALF_tileset_tile_height(tileset)));
- /* create pTile */
- pTile = create_surf(tileset_tile_width(tileset),
- tileset_tile_height(tileset), SDL_SWSURFACE);
-
- /* fill pTile with RED */
- SDL_FillRect(pTile, NULL,
- SDL_MapRGBA(pTile->format, 255, 0, 0, 96));
-
- /* blit mask */
- SDL_BlitSurface(pTmpSurface, NULL, pTile, NULL);
-
- SDL_SetColorKey(pTile, SDL_SRCCOLORKEY | SDL_RLEACCEL,
- get_first_pixel(pTile));
-
- SDL_SetAlpha(pTile, SDL_SRCALPHA, 96);
-
- /* clear pTmpSurface */
- if (pTmpSurface->format->BytesPerPixel == 4 &&
- !pTmpSurface->format->Amask) {
- SDL_SetColorKey(pTmpSurface, SDL_SRCCOLORKEY, Amask);
- SDL_FillRect(pTmpSurface, NULL, Amask);
- } else {
- SDL_SetColorKey(pTmpSurface, SDL_SRCCOLORKEY, 0x0);
- SDL_FillRect(pTmpSurface, NULL, 0);
- }
- }
- SDL_BlitSurface(pTile, NULL, pDest, &dest);
- }
- }
-
- }
- if (++real_row >= map.ysize) {
- real_row = 0;
- }
- }
- real_row = row0;
- if (++real_col >= map.xsize) {
- real_col = 0;
- }
- }
-
- draw_units = draw_units_backup;
- draw_map_grid = draw_map_grid_backup;
-
- FREESURFACE(pTile);
-
-#endif
-
- int city_x, city_y;
- int map_x, map_y, canvas_x, canvas_y;
- int draw_units_backup = draw_units;
- SDL_Surface *pTile = NULL;
- SDL_Surface *pDest = create_surf(get_citydlg_canvas_width(),
- get_citydlg_canvas_height()
- + HALF_tileset_tile_height(tileset), SDL_SWSURFACE);
-
-
- /* turn off drawing units */
- draw_units = 0;
-
- /* We have to draw the tiles in a particular order, so its best
- to avoid using any iterator macro. */
- for (city_x = 0; city_x<CITY_MAP_SIZE; city_x++)
- {
- for (city_y = 0; city_y<CITY_MAP_SIZE; city_y++) {
- if (is_valid_city_coords(city_x, city_y)
- && city_map_to_map(&map_x, &map_y, pCity, city_x, city_y)
- && client_tile_get_known(map_x, map_y)
- && city_to_canvas_pos(&canvas_x, &canvas_y, city_x, city_y)) {
- draw_map_cell(pDest, canvas_x,
- canvas_y + HALF_tileset_tile_height(tileset), map_x, map_y,
1);
-
- if (get_worker_city(pCity, city_x, city_y) == C_TILE_UNAVAILABLE)
- {
-
- SDL_Rect dest = {canvas_x, canvas_y +
HALF_tileset_tile_height(tileset), tileset_tile_width(tileset),
tileset_tile_height(tileset)};
- if (!pTile) {
-
- /* fill pTile with Mask Color */
- SDL_FillRect(pTmpSurface, NULL,
- SDL_MapRGB(pTmpSurface->format, 255, 0, 255));
-
- /* make mask */
- SDL_BlitSurface(GET_SURF(sprites.black_tile),
- NULL, pTmpSurface, NULL);
-
- SDL_SetColorKey(pTmpSurface, SDL_SRCCOLORKEY,
- getpixel(pTmpSurface,
HALF_tileset_tile_width(tileset),
- HALF_tileset_tile_height(tileset)));
- /* create pTile */
- pTile = create_surf(tileset_tile_width(tileset),
- tileset_tile_height(tileset), SDL_SWSURFACE);
-
- /* fill pTile with RED */
- SDL_FillRect(pTile, NULL,
- SDL_MapRGBA(pTile->format, 255, 0, 0, 96));
-
- /* blit mask */
- SDL_BlitSurface(pTmpSurface, NULL, pTile, NULL);
-
- SDL_SetColorKey(pTile, SDL_SRCCOLORKEY | SDL_RLEACCEL,
- get_first_pixel(pTile));
-
- SDL_SetAlpha(pTile, SDL_SRCALPHA, 96);
-
- /* clear pTmpSurface */
- if (pTmpSurface->format->BytesPerPixel == 4 &&
- !pTmpSurface->format->Amask) {
- SDL_SetColorKey(pTmpSurface, SDL_SRCCOLORKEY, Amask);
- SDL_FillRect(pTmpSurface, NULL, Amask);
- } else {
- SDL_SetColorKey(pTmpSurface, SDL_SRCCOLORKEY, 0x0);
- SDL_FillRect(pTmpSurface, NULL, 0);
- }
- }
- SDL_BlitSurface(pTile, NULL, pDest, &dest);
- }
- }
- }
- }
- draw_units = draw_units_backup;
- FREESURFACE(pTile);
-
- return pDest;
-}
-
-/**************************************************************************
- ...
-**************************************************************************/
-static SDL_Surface * create_noiso_city_map(struct city *pCity)
-{
-
- int city_x, city_y;
- int map_x, map_y, canvas_x, canvas_y;
- int draw_units_backup = draw_units;
- struct canvas store;
- SDL_Surface *pDest = create_surf(get_citydlg_canvas_width(),
- get_citydlg_canvas_height(), SDL_SWSURFACE);
-
- store.surf = pDest;
-
- /* turn off drawing units */
- draw_units = 0;
-
- /* We have to draw the tiles in a particular order, so its best
- to avoid using any iterator macro. */
- for (city_x = 0; city_x<CITY_MAP_SIZE; city_x++)
- {
- for (city_y = 0; city_y<CITY_MAP_SIZE; city_y++) {
- if (is_valid_city_coords(city_x, city_y)
- && city_map_to_map(&map_x, &map_y, pCity, city_x, city_y)
- && client_tile_get_known(map_x, map_y)
- && city_to_canvas_pos(&canvas_x, &canvas_y, city_x, city_y)) {
- put_one_tile(&store, map_x, map_y, canvas_x, canvas_y, 1);
- if (get_worker_city(pCity, city_x, city_y) == C_TILE_UNAVAILABLE)
- {
- SDL_Color used = {255, 0, 0, 96};
- SDL_Rect dest = {canvas_x, canvas_y, tileset_tile_width(tileset),
tileset_tile_height(tileset)};
- SDL_FillRectAlpha(pDest, &dest, &used);
- }
- }
- }
- }
- draw_units = draw_units_backup;
-
- return pDest;
+ return city_map_canvas->surf;
}
-
-
-SDL_Surface * create_city_map(struct city *pCity)
+SDL_Surface *get_terrain_surface(struct tile *ptile)
{
+ /* tileset dimensions might have changed, so create a new canvas each time */
- if (tileset_is_isometric(tileset))
- {
- return create_iso_city_map(pCity);
+ if (!terrain_canvas) {
+ canvas_free(terrain_canvas);
}
- return create_noiso_city_map(pCity);
-}
-
-/**************************************************************************
- ...
-**************************************************************************/
-SDL_Surface * get_terrain_surface(int x , int y)
-{
- SDL_Surface *pSurf = create_surf(tileset_full_tile_width(tileset),
- tileset_full_tile_height(tileset),
- SDL_SWSURFACE);
- bool fg = draw_fog_of_war,
- ci = draw_cities ,
- tr = draw_terrain ,
- rr = draw_roads_rails,
- ir = draw_irrigation,
- un = draw_units,
- gr = draw_map_grid,
- pl = draw_pollution ,
- fa = draw_fortress_airbase,
- mi = draw_mines,
- bo = draw_borders;
-
- draw_fog_of_war = FALSE;
- draw_cities = FALSE;
- draw_terrain = TRUE;
- draw_roads_rails = FALSE;
- draw_irrigation = FALSE;
- draw_units = FALSE;
- draw_map_grid = FALSE;
- draw_pollution = FALSE;
- draw_fortress_airbase = FALSE;
- draw_mines = FALSE;
- draw_borders = FALSE;
-
- SDL_Client_Flags &= ~CF_DRAW_MAP_DITHER;
-
- draw_map_cell(pSurf, 0, tileset_tile_height(tileset) / 2, x , y , 0);
-
- SDL_SetColorKey(pSurf , SDL_SRCCOLORKEY|SDL_RLEACCEL , 0x0);
+ terrain_canvas = canvas_create(tileset_full_tile_width(tileset),
+ tileset_full_tile_height(tileset));
- SDL_Client_Flags |= CF_DRAW_MAP_DITHER;
-
- draw_fog_of_war = fg;
- draw_cities = ci;
- draw_terrain = tr;
- draw_roads_rails = rr;
- draw_irrigation = ir;
- draw_units = un;
- draw_map_grid = gr;
- draw_pollution = pl;
- draw_fortress_airbase = fa;
- draw_mines = mi;
- draw_borders = bo;
-
- return pSurf;
-}
-
-/* =====================================================================
- Init Functions
- ===================================================================== */
-
-/**************************************************************************
- ...
-**************************************************************************/
-static SDL_Surface * create_ocean_tile(void)
-{
- SDL_Surface *pOcean = create_surf(tileset_tile_width(tileset) ,
- tileset_tile_height(tileset) ,
- SDL_SWSURFACE);
- SDL_Rect des = { 0 , 0 , 0, 0 };
- SDL_Surface *pBuf[4];
+ put_terrain(ptile, terrain_canvas, 0, 0);
- /* top */
- des.y = 0;
- des.x = tileset_tile_width(tileset) / 4;
- SDL_BlitSurface(pBuf[0], NULL, pOcean, &des);
-
- /* bottom */
- des.y = tileset_tile_height(tileset) / 2;
- SDL_BlitSurface(pBuf[1], NULL, pOcean, &des);
-
- /* left */
- des.x = 0;
- des.y = tileset_tile_height(tileset) / 4;
- SDL_BlitSurface(pBuf[2], NULL, pOcean, &des);
-
- /* right */
- des.x = tileset_tile_width(tileset) / 2;
- SDL_BlitSurface(pBuf[3], NULL, pOcean, &des);
-
- SDL_SetColorKey(pOcean, SDL_SRCCOLORKEY|SDL_RLEACCEL, 0x0);
-
- return pOcean;
-}
-
-/**************************************************************************
- ...
-**************************************************************************/
-static void fill_dither_buffers(SDL_Surface **pDitherBufs, int x, int y,
- Terrain_type_id terrain)
-{
- Terrain_type_id __ter[8];
- enum direction8 dir;
- int x1, y1;
-
- /* Loop over all adjacent tiles. We should have an iterator for this. */
- for (dir = 0; dir < 8; dir++) {
-
- if (MAPSTEP(x1, y1, x, y, dir)) {
- __ter[dir] = tile_get_terrain(x1, y1);
- } else {
- /* We draw the edges of the map as if the same terrain just
- * continued off the edge of the map. */
-
- __ter[dir] = terrain;
- }
- }
-
- /* north */
- pDitherBufs[0] = pDithers[__ter[DIR8_NORTH]][0];
-
- /* south */
- pDitherBufs[1] = pDithers[__ter[DIR8_SOUTH]][1];
-
- /* east */
- pDitherBufs[2] = pDithers[__ter[DIR8_EAST]][2];
-
- /* weast */
- pDitherBufs[3] = pDithers[__ter[DIR8_WEST]][3];
-}
-
-/**************************************************************************
- ...
-**************************************************************************/
-static void init_dither_tiles(void)
-{
- Terrain_type_id terrain;
- int i , w = tileset_tile_width(tileset) / 2, h =
tileset_tile_height(tileset) / 2;
- SDL_Rect src = { 0 , 0 , w , h };
- SDL_Surface *pTerrain_Surface, *pBuf =
create_surf(tileset_tile_width(tileset),
- tileset_tile_height(tileset),
SDL_SWSURFACE);
- Uint32 color = SDL_MapRGB(pBuf->format, 255, 0, 255);
- SDL_FillRect(pBuf, NULL, color);
- SDL_SetColorKey(pBuf, SDL_SRCCOLORKEY, color);
-
- for (terrain = T_FIRST; terrain < T_COUNT; terrain++) {
-
- if (is_ocean(terrain) || terrain == T_UNKNOWN)
- {
- for(i = 0; i < 4; i++)
- {
- pDithers[terrain][i] = NULL;
- }
- continue;
- }
-
- pTerrain_Surface = GET_SURF(sprites.terrain[terrain]->layer[0].base);
-
- for( i = 0; i < 4; i++ )
- {
- pDithers[terrain][i] = create_surf(w, h , SDL_SWSURFACE);
- SDL_FillRect(pDithers[terrain][i], NULL, color);
- }
-
- /* north */
- dither_north(pTerrain_Surface, pDitherMask, pBuf);
-
- /* south */
- dither_south(pTerrain_Surface, pDitherMask, pBuf);
-
- /* east */
- dither_east(pTerrain_Surface, pDitherMask, pBuf);
-
- /* west */
- dither_west(pTerrain_Surface, pDitherMask, pBuf);
-
- /* north */
- src.x = w;
- SDL_BlitSurface(pBuf, &src, pDithers[terrain][0], NULL);
-
- /* south */
- src.x = 0;
- src.y = h;
- SDL_BlitSurface(pBuf, &src, pDithers[terrain][1], NULL);
-
- /* east */
- src.x = w;
- src.y = h;
- SDL_BlitSurface(pBuf, &src, pDithers[terrain][2], NULL);
-
- /* west */
- src.x = 0;
- src.y = 0;
- SDL_BlitSurface(pBuf, &src, pDithers[terrain][3], NULL);
-
- SDL_FillRect(pBuf, NULL, color);
-
- for(i = 0; i < 4; i++)
- {
- SDL_SetColorKey(pDithers[terrain][i] , SDL_SRCCOLORKEY|SDL_RLEACCEL,
color);
- }
-
- }
-
- FREESURFACE(pBuf);
-}
-
-/**************************************************************************
- ...
-**************************************************************************/
-static void free_dither_tiles(void)
-{
- Terrain_type_id terrain;
- int i;
-
- for (terrain = T_FIRST; terrain < T_COUNT; terrain++) {
- for(i = 0; i < 4; i++)
- {
- FREESURFACE(pDithers[terrain][i]);
- }
- }
-
-}
-
-/**************************************************************************
- ...
-**************************************************************************/
-static void clear_dither_tiles(void)
-{
- Terrain_type_id terrain;
- int i;
-
- for (terrain = T_FIRST; terrain < T_COUNT; terrain++) {
- for(i = 0; i < 4; i++)
- {
- pDithers[terrain][i] = NULL;
- }
- }
-}
-/* ================================================================ */
-
-/**************************************************************************
- ...
-**************************************************************************/
-void tmp_map_surfaces_init(void)
-{
-
- HALF_tileset_tile_height(tileset) = tileset_tile_height(tileset) / 2;
- HALF_tileset_tile_width(tileset) = tileset_tile_width(tileset) / 2;
-
- #if SDL_BYTEORDER == SDL_BIG_ENDIAN
- Amask = 0x000000ff;
- #else
- Amask = 0xff000000;
- #endif
-
- clear_dither_tiles();
-
- if(tileset_is_isometric(tileset)) {
-
- /* =========================== */
- pTmpSurface = create_surf(tileset_full_tile_width(tileset),
- tileset_full_tile_height(tileset),
- SDL_SWSURFACE);
- SDL_SetAlpha(pTmpSurface, 0x0, 0x0);
-
- /* if BytesPerPixel == 4 and Amask == 0 ( 24 bit coding ) alpha blit
- * functions; Set A = 255 in all pixels and then pixel val
- * ( r=0, g=0, b=0) != 0. Real val this pixel is 0xff000000/0x000000ff.
*/
- if (pTmpSurface->format->BytesPerPixel == 4
- && !pTmpSurface->format->Amask) {
- SDL_SetColorKey(pTmpSurface, SDL_SRCCOLORKEY, Amask);
- } else {
- SDL_SetColorKey(pTmpSurface, SDL_SRCCOLORKEY, 0x0);
- }
-
- /* ===================================================== */
-
- pOcean_Tile = create_ocean_tile();
-
- pOcean_Foged_Tile = create_surf(tileset_tile_width(tileset) ,
- tileset_tile_height(tileset) ,
- SDL_SWSURFACE);
-
- SDL_BlitSurface(pOcean_Tile , NULL , pOcean_Foged_Tile, NULL);
- SDL_FillRectAlpha(pOcean_Foged_Tile, NULL,
- get_game_colorRGB(COLOR_STD_FOG_OF_WAR));
- SDL_SetColorKey(pOcean_Foged_Tile , SDL_SRCCOLORKEY|SDL_RLEACCEL,
- get_first_pixel(pOcean_Foged_Tile));
-
- /* =========================================================== */
- /* create black grid */
- pMapGrid[0][0] = create_surf(tileset_tile_width(tileset) / 2,
- tileset_tile_height(tileset) / 2,
SDL_SWSURFACE);
- pMapGrid[0][1] = create_surf(tileset_tile_width(tileset) / 2,
- tileset_tile_height(tileset) / 2,
SDL_SWSURFACE);
- putline(pMapGrid[0][0], 0, pMapGrid[0][0]->h, pMapGrid[0][0]->w, 0, 64);
- putline(pMapGrid[0][1], 0, 0, pMapGrid[0][1]->w, pMapGrid[0][1]->h, 64);
- SDL_SetColorKey(pMapGrid[0][0] , SDL_SRCCOLORKEY|SDL_RLEACCEL, 0x0);
- SDL_SetColorKey(pMapGrid[0][1] , SDL_SRCCOLORKEY|SDL_RLEACCEL, 0x0);
-
- /* create white grid */
- pMapGrid[1][0] = create_surf(tileset_tile_width(tileset) / 2,
- tileset_tile_height(tileset) / 2,
SDL_SWSURFACE);
- pMapGrid[1][1] = create_surf(tileset_tile_width(tileset) / 2,
- tileset_tile_height(tileset) / 2,
SDL_SWSURFACE);
- putline(pMapGrid[1][0], 0, pMapGrid[1][0]->h, pMapGrid[1][0]->w, 0,
0xffffffff);
- putline(pMapGrid[1][1], 0, 0, pMapGrid[1][1]->w, pMapGrid[1][1]->h,
0xffffffff);
- SDL_SetColorKey(pMapGrid[1][0] , SDL_SRCCOLORKEY|SDL_RLEACCEL, 0x0);
- SDL_SetColorKey(pMapGrid[1][1] , SDL_SRCCOLORKEY|SDL_RLEACCEL, 0x0);
-
- /* create red grid */
- pMapGrid[2][0] = create_surf(tileset_tile_width(tileset) / 2,
- tileset_tile_height(tileset) / 2,
SDL_SWSURFACE);
- pMapGrid[2][1] = create_surf(tileset_tile_width(tileset) / 2,
- tileset_tile_height(tileset) / 2,
SDL_SWSURFACE);
- putline(pMapGrid[2][0], 0, pMapGrid[2][0]->h, pMapGrid[2][0]->w, 0,
- SDL_MapRGB(pMapGrid[2][0]->format, 255, 0,0));
- putline(pMapGrid[2][1], 0, 0, pMapGrid[2][1]->w, pMapGrid[2][1]->h,
- SDL_MapRGB(pMapGrid[2][1]->format, 255, 0,0));
- SDL_SetColorKey(pMapGrid[2][0] , SDL_SRCCOLORKEY|SDL_RLEACCEL, 0x0);
- SDL_SetColorKey(pMapGrid[2][1] , SDL_SRCCOLORKEY|SDL_RLEACCEL, 0x0);
-
- pBlinkSurfaceA =
- create_surf(tileset_full_tile_width(tileset),
tileset_full_tile_height(tileset), SDL_SWSURFACE);
-
- pBlinkSurfaceB =
- create_surf(tileset_full_tile_width(tileset),
tileset_full_tile_height(tileset), SDL_SWSURFACE);
-
-#ifdef SDL_CVS
- SDL_SetColorKey(pBlinkSurfaceB , SDL_SRCCOLORKEY|SDL_RLEACCEL, 0x0);
-#else
- SDL_SetColorKey(pBlinkSurfaceB , SDL_SRCCOLORKEY, 0x0);
-#endif
-
- } else {
- pTmpSurface = NULL;
- pOcean_Tile = NULL;
- pOcean_Foged_Tile = NULL;
- pBlinkSurfaceA = NULL;
- pBlinkSurfaceB = NULL;
- pMapGrid[0][0] = NULL;
- pMapGrid[0][1] = NULL;
- pMapGrid[1][0] = NULL;
- pMapGrid[1][1] = NULL;
- pMapGrid[2][0] = NULL;
- pMapGrid[2][1] = NULL;
- }
+ SDL_SetColorKey(terrain_canvas->surf , SDL_SRCCOLORKEY|SDL_RLEACCEL , 0x0);
+ return terrain_canvas->surf;
}
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/mapview.h
devel/client/gui-sdl/mapview.h
--- devel_distclean/client/gui-sdl/mapview.h 2005-10-17 17:15:35.000000000
+0200
+++ devel/client/gui-sdl/mapview.h 2005-11-15 06:52:45.000000000 +0100
@@ -28,12 +28,9 @@
#include "mapview_common.h"
void center_minimap_on_minimap_window(void);
-void tmp_map_surfaces_init(void);
void redraw_unit_info_label(struct unit *pUnit);
-void real_blink_active_unit(void);
SDL_Surface * create_city_map(struct city *pCity);
-SDL_Surface * get_terrain_surface(int x, int y);
-int correction_map_pos(int *pCol, int *pRow);
+SDL_Surface * get_terrain_surface(struct tile *ptile);
void put_unit_pixmap_draw(struct unit *pUnit, SDL_Surface *pDest,
Sint16 map_x, Sint16 map_y);
void rebuild_focus_anim_frames(void);
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/menu.c
devel/client/gui-sdl/menu.c
--- devel_distclean/client/gui-sdl/menu.c 2005-10-19 00:34:24.000000000
+0200
+++ devel/client/gui-sdl/menu.c 2005-11-15 06:57:09.000000000 +0100
@@ -50,6 +50,7 @@
#include "helpdlg.h"
#include "mapctrl.h" /* center_on_unit */
#include "mapview.h"
+#include "log.h"
#include "menu.h"
@@ -67,11 +68,11 @@
static struct GUI *pOrder_Trade_Button;
#define local_show(ID) \
- clear_wflag(get_widget_pointer_form_ID(pBeginOrderWidgetList, ID ), \
+ clear_wflag(get_widget_pointer_form_ID(pBeginOrderWidgetList, ID,
SCAN_FORWARD), \
WF_HIDDEN)
#define local_hide(ID) \
- set_wflag(get_widget_pointer_form_ID(pBeginOrderWidgetList, ID), \
+ set_wflag(get_widget_pointer_form_ID(pBeginOrderWidgetList, ID,
SCAN_FORWARD), \
WF_HIDDEN )
@@ -147,14 +148,14 @@
key_unit_wakeup_others();
break;
case ID_UNIT_ORDER_AUTOMATION:
- request_unit_auto(pUnit);
+ request_unit_autosettlers(pUnit);
break;
case ID_UNIT_ORDER_AUTO_EXPLORE:
key_unit_auto_explore();
break;
case ID_UNIT_ORDER_CONNECT:
#if 0
- /* TODO: multiple connect types */
+ /* TODO: different connect types */
key_unit_connect();
#endif
break;
@@ -204,10 +205,12 @@
/**************************************************************************
...
**************************************************************************/
+#if 0
static bool has_city_airport(struct city *pCity)
{
- return (pCity && city_got_building(pCity, B_AIRPORT));
+ return (pCity && (get_city_bonus(pCity, EFT_AIR_VETERAN) > 0));
}
+#endif
static Uint16 redraw_order_widgets(void)
{
@@ -260,22 +263,22 @@
int count = 0, lines = 1, w = 0, count_on_line;
if (SDL_Client_Flags & CF_MINI_MAP_SHOW) {
- xx = pMiniMap->size.x + pMiniMap->size.w + 10;
+ xx = pMiniMap->size.x + pMiniMap->size.w + adj_size(10);
} else {
- xx = pMiniMap->size.x + HIDDEN_MINI_MAP_W + 10;
+ xx = pMiniMap->size.x + HIDDEN_MINI_MAP_W + adj_size(10);
}
- w = (pInfoWind->size.x - 10) - xx;
+ w = (pInfoWind->size.x - adj_size(10)) - xx;
- if (w < (pTmpWidget->size.w + 10) * 2) {
+ if (w < (pTmpWidget->size.w + adj_size(10)) * 2) {
if(pMiniMap->size.h == pInfoWind->size.h) {
xx = 0;
w = Main.gui->w;
yy = pInfoWind->size.h;
} else {
if (pMiniMap->size.h > pInfoWind->size.h) {
- w = Main.gui->w - xx - 20;
- if (w < (pTmpWidget->size.w + 10) * 2) {
+ w = Main.gui->w - xx - adj_size(20);
+ if (w < (pTmpWidget->size.w + adj_size(10)) * 2) {
xx = 0;
w = pMiniMap->size.w;
yy = pMiniMap->size.h;
@@ -283,20 +286,20 @@
yy = pInfoWind->size.h;
}
} else {
- w = pInfoWind->size.x - 20;
- if (w < (pTmpWidget->size.w + 10) * 2) {
+ w = pInfoWind->size.x - adj_size(20);
+ if (w < (pTmpWidget->size.w + adj_size(10)) * 2) {
xx = pInfoWind->size.x;
w = pInfoWind->size.w;
yy = pInfoWind->size.h;
} else {
- xx = 10;
+ xx = adj_size(10);
yy = pMiniMap->size.h;
}
}
}
}
- count_on_line = w / (pTmpWidget->size.w + 5);
+ count_on_line = w / (pTmpWidget->size.w + adj_size(5));
/* find how many to reposition */
while (TRUE) {
@@ -323,9 +326,9 @@
}
- sx = xx + (w - count * (pTmpWidget->size.w + 5)) / 2;
+ sx = xx + (w - count * (pTmpWidget->size.w + adj_size(5))) / 2;
- sy = pTmpWidget->dst->h - yy - lines * (pTmpWidget->size.h + 5);
+ sy = pTmpWidget->dst->h - yy - lines * (pTmpWidget->size.h + adj_size(5));
while (TRUE) {
@@ -335,14 +338,14 @@
pTmpWidget->size.y = sy;
count--;
- sx += (pTmpWidget->size.w + 5);
+ sx += (pTmpWidget->size.w + adj_size(5));
if (!count) {
count = count_on_line;
lines--;
- sx = xx + (w - count * (pTmpWidget->size.w + 5)) / 2;
+ sx = xx + (w - count * (pTmpWidget->size.w + adj_size(5))) / 2;
- sy = pTmpWidget->dst->h - yy - lines * (pTmpWidget->size.h + 5);
+ sy = pTmpWidget->dst->h - yy - lines * (pTmpWidget->size.h +
adj_size(5));
}
}
@@ -368,132 +371,158 @@
Uint16 *unibuf;
size_t len;
+ /* No orders */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("No orders"), " (Space)");
pBuf = create_themeicon(pTheme->ODone_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_SPACE;
add_to_gui_list(ID_UNIT_ORDER_DONE, pBuf);
+ /* --------- */
+
pEndOrderWidgetList = pBuf;
+ /* Wait */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Wait"), " (W)");
pBuf = create_themeicon(pTheme->OWait_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_w;
add_to_gui_list(ID_UNIT_ORDER_WAIT, pBuf);
+ /* --------- */
+ /* Explode Nuclear */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Explode Nuclear"), " (Shift + N)");
pBuf = create_themeicon(pTheme->ONuke_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_n;
pBuf->mod = KMOD_SHIFT;
add_to_gui_list(ID_UNIT_ORDER_NUKE, pBuf);
+ /* --------- */
+ /* Diplomat|Spy Actions */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Diplomat|Spy Actions"), " (D)");
pBuf = create_themeicon(pTheme->OSpy_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_d;
add_to_gui_list(ID_UNIT_ORDER_DIPLOMAT_DLG, pBuf);
+ /* --------- */
+ /* Disband */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Disband"), " (Shift + D)");
pBuf = create_themeicon(pTheme->ODisband_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_d;
pBuf->mod = KMOD_SHIFT;
add_to_gui_list(ID_UNIT_ORDER_DISBAND, pBuf);
+ /* --------- */
+ /* Upgrade */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Upgrade"), " (Shift + U)");
pBuf = create_themeicon(pTheme->Order_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_u;
pBuf->mod = KMOD_SHIFT;
add_to_gui_list(ID_UNIT_ORDER_UPGRADE, pBuf);
+ /* --------- */
+ /* Return to nearest city */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Return to nearest city"), " (Shift
+ G)");
pBuf = create_themeicon(pTheme->OReturn_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_g;
pBuf->mod = KMOD_SHIFT;
add_to_gui_list(ID_UNIT_ORDER_RETURN, pBuf);
+ /* --------- */
+ /* Goto City */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Goto City"), " (L)");
pBuf = create_themeicon(pTheme->OGotoCity_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_l;
add_to_gui_list(ID_UNIT_ORDER_GOTO_CITY, pBuf);
+ /* --------- */
+ /* Airlift */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Airlift"), " (L)");
pBuf = create_themeicon(pTheme->Order_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_l;
add_to_gui_list(ID_UNIT_ORDER_AIRLIFT, pBuf);
+ /* --------- */
+ /* Goto location */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Goto location"), " (G)");
pBuf = create_themeicon(pTheme->OGoto_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_g;
add_to_gui_list(ID_UNIT_ORDER_GOTO, pBuf);
+ /* --------- */
+ /* Patrol */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Patrol"), " (Q)");
pBuf = create_themeicon(pTheme->OPatrol_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_q;
add_to_gui_list(ID_UNIT_ORDER_PATROL, pBuf);
+ /* --------- */
+ /* Connect */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Connect"), " (Shift + C)");
pBuf = create_themeicon(pTheme->OAutoConnect_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_c;
pBuf->mod = KMOD_SHIFT;
add_to_gui_list(ID_UNIT_ORDER_CONNECT, pBuf);
+ /* --------- */
+ /* Auto-Explore */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Auto-Explore"), " (X)");
pBuf = create_themeicon(pTheme->OAutoExp_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
@@ -501,10 +530,12 @@
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
pBuf->string16 =
- create_str16_from_char(cBuf, 10);
+ create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_x;
add_to_gui_list(ID_UNIT_ORDER_AUTO_EXPLORE, pBuf);
+ /* --------- */
+ /* Auto-Attack / Auto-Settler */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Auto-Attack"), " (A)");
len = strlen(cBuf);
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Auto-Settler"), " (A)");
@@ -518,145 +549,175 @@
len = (len + 1) * sizeof(Uint16);
unibuf = MALLOC(len);
convertcopy_to_utf16(unibuf, len, cBuf);
- pBuf->string16 = create_string16(unibuf, len, 10);
+ pBuf->string16 = create_string16(unibuf, len, adj_font(10));
pBuf->key = SDLK_a;
add_to_gui_list(ID_UNIT_ORDER_AUTOMATION, pBuf);
+
pOrder_Automate_Unit_Button = pBuf;
+ /* --------- */
+ /* Wake Up Others */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Wake Up Others"), " (Shift + W)");
pBuf = create_themeicon(pTheme->OWakeUp_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_w;
pBuf->mod = KMOD_SHIFT;
add_to_gui_list(ID_UNIT_ORDER_WAKEUP_OTHERS, pBuf);
+ /* --------- */
+ /* Unload */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Unload"), " (U)");
pBuf = create_themeicon(pTheme->OUnload_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_u;
add_to_gui_list(ID_UNIT_ORDER_UNLOAD, pBuf);
+ /* --------- */
+ /* Find Homecity */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Find Homecity"), " (H)");
pBuf = create_themeicon(pTheme->OHomeCity_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_h;
add_to_gui_list(ID_UNIT_ORDER_HOMECITY, pBuf);
+ /* --------- */
+ /* Pillage */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Pillage"), " (Shift + P)");
pBuf = create_themeicon(pTheme->OPillage_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_p;
pBuf->mod = KMOD_SHIFT;
add_to_gui_list(ID_UNIT_ORDER_PILLAGE, pBuf);
+ /* --------- */
+ /* Sentry */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Sentry"), " (S)");
pBuf = create_themeicon(pTheme->OSentry_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_s;
add_to_gui_list(ID_UNIT_ORDER_SENTRY, pBuf);
+ /* --------- */
+ /* Clean Nuclear Fallout */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Clean Nuclear Fallout"), " (N)");
pBuf = create_themeicon(pTheme->OFallout_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_n;
add_to_gui_list(ID_UNIT_ORDER_FALLOUT, pBuf);
+ /* --------- */
+ /* Paradrop */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Paradrop"), " (P)");
pBuf = create_themeicon(pTheme->OParaDrop_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_p;
add_to_gui_list(ID_UNIT_ORDER_PARADROP, pBuf);
+ /* --------- */
+ /* Clean Pollution */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Clean Pollution"), " (P)");
pBuf = create_themeicon(pTheme->OPollution_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_p;
add_to_gui_list(ID_UNIT_ORDER_POLLUTION, pBuf);
+ /* --------- */
+ /* Build Airbase */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Build Airbase"), " (E)");
pBuf = create_themeicon(pTheme->OAirBase_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_e;
add_to_gui_list(ID_UNIT_ORDER_AIRBASE, pBuf);
+ /* --------- */
+ /* Fortify */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Fortify"), " (F)");
pBuf = create_themeicon(pTheme->OFortify_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_f;
add_to_gui_list(ID_UNIT_ORDER_FORTIFY, pBuf);
+ /* --------- */
+ /* Build Fortress */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Build Fortress"), " (F)");
pBuf = create_themeicon(pTheme->OFortress_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_f;
add_to_gui_list(ID_UNIT_ORDER_FORTRESS, pBuf);
+ /* --------- */
+ /* Transform Tile */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Transform Tile"), " (O)");
pBuf = create_themeicon(pTheme->OTransform_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_o;
pOrder_Transform_Button = pBuf;
add_to_gui_list(ID_UNIT_ORDER_TRANSFORM, pBuf);
+ /* --------- */
+ /* Build Mine */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Build Mine"), " (M)");
pBuf = create_themeicon(pTheme->OMine_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_m;
add_to_gui_list(ID_UNIT_ORDER_MINE, pBuf);
+
pOrder_Mine_Button = pBuf;
+ /* --------- */
+ /* Build Irrigation */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Build Irrigation"), " (I)");
pBuf = create_themeicon(pTheme->OIrrigation_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
@@ -664,21 +725,27 @@
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
pBuf->key = SDLK_i;
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
add_to_gui_list(ID_UNIT_ORDER_IRRIGATE, pBuf);
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+
pOrder_Irrigation_Button = pBuf;
+ /* --------- */
+ /* Form Traderoute */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Form Traderoute"), " (R)");
pBuf = create_themeicon(pTheme->OTrade_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_r;
- pOrder_Trade_Button = pBuf;
add_to_gui_list(ID_UNIT_ORDER_TRADEROUTE, pBuf);
+ pOrder_Trade_Button = pBuf;
+ /* --------- */
+
+ /* Build (Rail-)Road */
my_snprintf(cBuf, sizeof(cBuf),"%s%s %d %s",
_("Build Railroad"), " (R)", 999,
PL_("turn", "turns", 999));
@@ -696,21 +763,26 @@
len = (len + 1) * sizeof(Uint16);
unibuf = MALLOC(len);
convertcopy_to_utf16(unibuf, len, cBuf);
- pBuf->string16 = create_string16(unibuf, len, 10);
+ pBuf->string16 = create_string16(unibuf, len, adj_font(10));
pBuf->key = SDLK_r;
- pOrder_Road_Button = pBuf;
add_to_gui_list(ID_UNIT_ORDER_ROAD, pBuf);
+ pOrder_Road_Button = pBuf;
+ /* --------- */
+
+ /* Help Build Wonder */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Help Build Wonder"), " (B)");
pBuf = create_themeicon(pTheme->OWonder_Icon, Main.gui,
(WF_HIDDEN | WF_DRAW_THEME_TRANSPARENT |
WF_WIDGET_HAS_INFO_LABEL));
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = unit_order_callback;
- pBuf->string16 = create_str16_from_char(cBuf, 10);
+ pBuf->string16 = create_str16_from_char(cBuf, adj_font(10));
pBuf->key = SDLK_b;
add_to_gui_list(ID_UNIT_ORDER_BUILD_WONDER, pBuf);
+ /* --------- */
+ /* Add to City / Build New City */
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Add to City"), " (B)");
len = strlen(cBuf);
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Build New City"), " (B)");
@@ -724,12 +796,14 @@
len = (len + 1) * sizeof(Uint16);
unibuf = MALLOC(len);
convertcopy_to_utf16(unibuf, len, cBuf);
- pBuf->string16 = create_string16(unibuf, len, 10);
+ pBuf->string16 = create_string16(unibuf, len, adj_font(10));
pBuf->key = SDLK_b;
add_to_gui_list(ID_UNIT_ORDER_BUILD_CITY, pBuf);
+
pOrder_Build_AddTo_City_Button = pBuf;
- pBeginOrderWidgetList = pBuf;
+ /* --------- */
+ pBeginOrderWidgetList = pBuf;
SDL_Client_Flags |= CF_ORDERS_WIDGETS_CREATED;
}
@@ -803,7 +877,7 @@
struct unit *pUnit = NULL;
static char cBuf[128];
- if (get_client_state() != CLIENT_GAME_RUNNING_STATE) {
+ if ((get_client_state() != CLIENT_GAME_RUNNING_STATE)) {
SDL_Client_Flags |= CF_GANE_JUST_STARTED;
@@ -865,7 +939,80 @@
hide_group(pBeginOrderWidgetList, pEndOrderWidgetList);
}
+ } else if (!game.player_ptr) {
+
+ if (SDL_Client_Flags & CF_MAP_UNIT_W_CREATED) {
+ struct GUI *pWidget = get_unit_info_window_widget();
+
+ clear_wflag(pOptions_Button, WF_HIDDEN);
+ real_redraw_icon(pOptions_Button);
+ sdl_dirty_rect(pOptions_Button->size);
+
+ /* economy button */
+ pWidget = pWidget->prev;
+ clear_wflag(pWidget, WF_HIDDEN);
+ set_wstate(pWidget, FC_WS_DISABLED);
+
+ /* research button */
+ pWidget = pWidget->prev;
+ clear_wflag(pWidget, WF_HIDDEN);
+ set_wstate(pWidget, FC_WS_DISABLED);
+
+ /* revolution button */
+ pWidget = pWidget->prev;
+ clear_wflag(pWidget, WF_HIDDEN);
+ set_wstate(pWidget, FC_WS_DISABLED);
+
+ /* show/hide unit's window button */
+ pWidget = pWidget->prev;
+ clear_wflag(pWidget, WF_HIDDEN);
+ set_wstate(pWidget, FC_WS_NORMAL);
+
+ /* ------------------------------------ */
+ /* mini map window */
+ pWidget = pWidget->prev;
+
+ /* new turn button */
+ pWidget = pWidget->prev;
+ clear_wflag(pWidget, WF_HIDDEN);
+ set_wstate(pWidget, FC_WS_DISABLED);
+
+ /* players button */
+ pWidget = pWidget->prev;
+ clear_wflag(pWidget, WF_HIDDEN);
+ set_wstate(pWidget, FC_WS_DISABLED);
+
+ /* find city button */
+ pWidget = pWidget->prev;
+ clear_wflag(pWidget, WF_HIDDEN);
+ set_wstate(pWidget, FC_WS_DISABLED);
+
+ /* units button */
+ pWidget = pWidget->prev;
+ clear_wflag(pWidget, WF_HIDDEN);
+ set_wstate(pWidget, FC_WS_DISABLED);
+
+ /* show/hide log window button */
+ pWidget = pWidget->prev;
+ clear_wflag(pWidget, WF_HIDDEN);
+ set_wstate(pWidget, FC_WS_DISABLED);
+
+ /* toggle minimap mode button */
+ pWidget = pWidget->prev;
+ clear_wflag(pWidget, WF_HIDDEN);
+ set_wstate(pWidget, FC_WS_DISABLED);
+
+ /* show/hide minimap button */
+ pWidget = pWidget->prev;
+ clear_wflag(pWidget, WF_HIDDEN);
+ set_wstate(pWidget, FC_WS_NORMAL);
+
+ }
+
+ return;
+
} else {
+
if (get_wstate(pEndOrderWidgetList) == FC_WS_DISABLED) {
enable_group(pBeginOrderWidgetList, pEndOrderWidgetList);
}
@@ -945,8 +1092,7 @@
if (pUnit && !pUnit->ai.control) {
struct city *pHomecity;
int time;
- struct tile *pTile = map_get_tile(pUnit->x, pUnit->y);
- Terrain_type_id terrain = pTile->terrain;
+ struct tile *pTile = pUnit->tile;
if (!counter) {
local_show(ID_UNIT_ORDER_GOTO);
@@ -980,13 +1126,13 @@
time = can_unit_do_activity(pUnit, ACTIVITY_RAILROAD);
if (can_unit_do_activity(pUnit, ACTIVITY_ROAD) || time) {
if(time) {
- time = map_build_rail_time(pUnit->x, pUnit->y);
+ time = tile_activity_time(ACTIVITY_RAILROAD, pUnit->tile);
my_snprintf(cBuf, sizeof(cBuf),"%s%s %d %s",
_("Build Railroad"), " (R)", time ,
PL_("turn", "turns", time));
pOrder_Road_Button->theme = pTheme->ORailRoad_Icon;
} else {
- time = map_build_road_time(pUnit->x, pUnit->y);
+ time = tile_activity_time(ACTIVITY_ROAD, pUnit->tile);
my_snprintf(cBuf, sizeof(cBuf),"%s%s %d %s",
_("Build Road"), " (R)", time ,
PL_("turn", "turns", time));
@@ -1021,34 +1167,30 @@
}
if (can_unit_do_activity(pUnit, ACTIVITY_IRRIGATE)) {
- time = map_build_irrigation_time(pUnit->x, pUnit->y);
- switch (terrain) {
+ time = tile_activity_time(ACTIVITY_IRRIGATE, pUnit->tile);
+
+ if (!strcmp(pTile->terrain->name, "Forest") ||
+ !strcmp(pTile->terrain->name, "Jungle")) {
/* set Crop Forest Icon */
- case T_FOREST:
- case T_JUNGLE:
my_snprintf(cBuf, sizeof(cBuf),"%s %s%s %d %s",
_("Cut Down to"),
- terrains[terrains[terrain].irrigation_result
- ].name
+ pTile->terrain->irrigation_result->name
," (I)", time , PL_("turn", "turns", time));
pOrder_Irrigation_Button->theme = pTheme->OCutDownForest_Icon;
- break;
- case T_SWAMP:
+ } else if (!strcmp(pTile->terrain->name, "Swamp")) {
my_snprintf(cBuf, sizeof(cBuf),"%s %s%s %d %s",
_("Irrigate to"),
- terrains[terrains[terrain].irrigation_result
- ].name
+ pTile->terrain->irrigation_result->name
," (I)", time , PL_("turn", "turns", time));
pOrder_Irrigation_Button->theme = pTheme->OIrrigation_Icon;
- break;
+ } else {
/* set Irrigation Icon */
- default:
my_snprintf(cBuf, sizeof(cBuf),"%s%s %d %s",
_("Build Irrigation"), " (I)", time ,
PL_("turn", "turns", time));
pOrder_Irrigation_Button->theme = pTheme->OIrrigation_Icon;
- break;
}
+
copy_chars_to_string16(pOrder_Irrigation_Button->string16, cBuf);
clear_wflag(pOrder_Irrigation_Button, WF_HIDDEN);
} else {
@@ -1056,35 +1198,33 @@
}
if (can_unit_do_activity(pUnit, ACTIVITY_MINE)) {
- time = map_build_mine_time(pUnit->x, pUnit->y);
- switch (terrain) {
+ time = tile_activity_time(ACTIVITY_MINE, pUnit->tile);
+
+ if (!strcmp(pTile->terrain->name, "Forest")) {
/* set Irrigate Icon -> make swamp */
- case T_FOREST:
my_snprintf(cBuf, sizeof(cBuf),"%s %s%s %d %s",
_("Irrigate to"),
- terrains[terrains[terrain].mining_result
- ].name
+ pTile->terrain->mining_result->name
," (M)", time , PL_("turn", "turns", time));
pOrder_Mine_Button->theme = pTheme->OIrrigation_Icon;
- break;
+ } else if (!strcmp(pTile->terrain->name, "Jungle") ||
+ !strcmp(pTile->terrain->name, "Plains") ||
+ !strcmp(pTile->terrain->name, "Grassland") ||
+ !strcmp(pTile->terrain->name, "Swamp")) {
/* set Forest Icon -> plant Forrest*/
- case T_JUNGLE:
- case T_PLAINS:
- case T_GRASSLAND:
- case T_SWAMP:
my_snprintf(cBuf, sizeof(cBuf),"%s%s %d %s",
_("Plant Forest"), " (M)", time ,
PL_("turn", "turns", time));
pOrder_Mine_Button->theme = pTheme->OPlantForest_Icon;
- break;
+
+ } else {
/* set Mining Icon */
- default:
my_snprintf(cBuf, sizeof(cBuf),"%s%s %d %s",
_("Build Mine"), " (M)", time ,
PL_("turn", "turns", time));
pOrder_Mine_Button->theme = pTheme->OMine_Icon;
- break;
}
+
copy_chars_to_string16(pOrder_Mine_Button->string16, cBuf);
clear_wflag(pOrder_Mine_Button, WF_HIDDEN);
} else {
@@ -1092,10 +1232,10 @@
}
if (can_unit_do_activity(pUnit, ACTIVITY_TRANSFORM)) {
- time = map_transform_time(pUnit->x, pUnit->y);
+ time = tile_activity_time(ACTIVITY_TRANSFORM, pUnit->tile);
my_snprintf(cBuf, sizeof(cBuf),"%s %s%s %d %s",
_("Transform to"),
- terrains[terrains[terrain].transform_result].name,
+ pTile->terrain->transform_result->name,
" (M)", time ,
PL_("turn", "turns", time));
copy_chars_to_string16(pOrder_Transform_Button->string16, cBuf);
@@ -1165,13 +1305,13 @@
local_hide(ID_UNIT_ORDER_UNLOAD);
}
- if (is_unit_activity_on_tile(ACTIVITY_SENTRY, pUnit->x, pUnit->y)) {
+ if (is_unit_activity_on_tile(ACTIVITY_SENTRY, pUnit->tile)) {
local_show(ID_UNIT_ORDER_WAKEUP_OTHERS);
} else {
local_hide(ID_UNIT_ORDER_WAKEUP_OTHERS);
}
- if (can_unit_do_auto(pUnit)) {
+ if (can_unit_do_autosettlers(pUnit)) {
if (unit_flag(pUnit, F_SETTLERS)) {
if(pOrder_Automate_Unit_Button->theme != pTheme->OAutoSett_Icon) {
my_snprintf(cBuf, sizeof(cBuf),"%s%s", _("Auto-Settler"), " (A)");
@@ -1203,8 +1343,7 @@
}
if (is_diplomat_unit(pUnit) &&
- diplomat_can_do_action(pUnit, DIPLOMAT_ANY_ACTION, pUnit->x,
- pUnit->y)) {
+ diplomat_can_do_action(pUnit, DIPLOMAT_ANY_ACTION, pUnit->tile)) {
local_show(ID_UNIT_ORDER_DIPLOMAT_DLG);
} else {
local_hide(ID_UNIT_ORDER_DIPLOMAT_DLG);
@@ -1216,7 +1355,8 @@
local_hide(ID_UNIT_ORDER_NUKE);
}
- if (pTile->city && has_city_airport(pTile->city) &&
pTile->city->airlift) {
+/* if (pTile->city && has_city_airport(pTile->city) &&
pTile->city->airlift) {*/
+ if (pTile->city && pTile->city->airlift) {
local_show(ID_UNIT_ORDER_AIRLIFT);
hide(ID_UNIT_ORDER_GOTO_CITY);
} else {
@@ -1224,7 +1364,7 @@
local_hide(ID_UNIT_ORDER_AIRLIFT);
}
- if (pTile->city && can_upgrade_unittype(game.player_ptr, pUnit->type) !=
-1) {
+ if (pTile->city && can_upgrade_unittype(game.player_ptr, pUnit->type)) {
local_show(ID_UNIT_ORDER_UPGRADE);
} else {
local_hide(ID_UNIT_ORDER_UPGRADE);
diff -u -r -b -B -X devel/diff_ignore
devel_distclean/client/gui-sdl/messagewin.c devel/client/gui-sdl/messagewin.c
--- devel_distclean/client/gui-sdl/messagewin.c 2005-10-17 21:15:06.000000000
+0200
+++ devel/client/gui-sdl/messagewin.c 2005-11-15 06:52:45.000000000 +0100
@@ -52,33 +52,20 @@
#include "gui_tilespec.h"
#include "mapview.h"
#include "options.h"
+#include "log.h"
#include "messagewin.h"
-#define N_MSG_VIEW 7 /* max before scrolling happens
*/
-#define PTSIZE_LOG_FONT 10
-
-static struct ADVANCED_DLG *pMsg_Dlg = NULL;
+#ifdef SMALL_SCREEN
+#define N_MSG_VIEW 3 /* max before scrolling happens */
+#else
+#define N_MSG_VIEW 6
+#endif
-#ifdef UNUSED
-/**************************************************************************
- Turn off updating of message window
-**************************************************************************/
-void meswin_update_delay_on(void)
-{
- freelog(LOG_DEBUG, "meswin_update_delay_on : PORT ME");
-}
+#define PTSIZE_LOG_FONT adj_font(10)
-/**************************************************************************
- Turn on updating of message window
-**************************************************************************/
-void meswin_update_delay_off(void)
-{
- /* dissconect_from_server call this */
- freelog(LOG_DEBUG, "meswin_update_delay_off : PORT ME");
-}
-#endif
+static struct ADVANCED_DLG *pMsg_Dlg = NULL;
/**************************************************************************
Called from default clicks on a message.
@@ -94,12 +81,10 @@
if (pMsg->city_ok
&& is_city_event(pMsg->event)) {
- int x = pMsg->x;
- int y = pMsg->y;
- struct city *pCity = tile_get_city(x, y);
+ struct city *pCity = tile_get_city(pMsg->tile);
if (center_when_popup_city) {
- center_tile_mapcanvas(x, y);
+ center_tile_mapcanvas(pMsg->tile);
}
if (pCity) {
@@ -107,7 +92,7 @@
* and we'd better not try to pop it up. In this case, it would
* be better if the popup button weren't highlighted at all, but
* that's OK. */
- popup_city_dialog(pCity, FALSE);
+ popup_city_dialog(pCity);
}
if (center_when_popup_city || pCity) {
@@ -115,7 +100,7 @@
}
} else if (pMsg->location_ok) {
- center_tile_mapcanvas(pMsg->x, pMsg->y);
+ center_tile_mapcanvas(pMsg->tile);
flush_dirty();
}
@@ -141,6 +126,7 @@
{
int msg_count = get_num_messages();
int i = pMsg_Dlg->pScroll->count;
+
struct message *pMsg = NULL;
struct GUI *pBuf = NULL, *pWindow = pMsg_Dlg->pEndWidgetList;
SDL_String16 *pStr = NULL;
@@ -168,7 +154,7 @@
for(; i<msg_count; i++)
{
pMsg = get_message(i);
- pStr = create_str16_from_char(pMsg->descr , 10);
+ pStr = create_str16_from_char(pMsg->descr , PTSIZE_LOG_FONT);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
(WF_DRAW_THEME_TRANSPARENT|WF_DRAW_TEXT_LABEL_WITH_SPACE));
@@ -179,7 +165,7 @@
pBuf->size.w = w;
pBuf->data.ptr = (void *)pMsg;
pBuf->action = msg_callback;
- if(pMsg->x != -1) {
+ if(pMsg->tile) {
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->string16->fgcol = active_color;
}
@@ -191,13 +177,13 @@
add_widget_to_vertical_scroll_widget_list(pMsg_Dlg,
pBuf, pWindow, FALSE,
pWindow->size.x + FRAME_WH,
- pWindow->size.y + WINDOW_TILE_HIGH + 2);
+ pWindow->size.y + WINDOW_TILE_HIGH +
adj_size(2));
create = FALSE;
} else {
add_widget_to_vertical_scroll_widget_list(pMsg_Dlg,
pBuf, pMsg_Dlg->pBeginActiveWidgetList, FALSE,
pWindow->size.x + FRAME_WH,
- pWindow->size.y + WINDOW_TILE_HIGH + 2);
+ pWindow->size.y + WINDOW_TILE_HIGH +
adj_size(2));
}
@@ -211,12 +197,13 @@
/**************************************************************************
Popup (or raise) the message dialog; typically triggered by 'F10'.
**************************************************************************/
-void popup_meswin_dialog(void)
+void popup_meswin_dialog(bool raise)
{
- Sint16 start_x = (Main.screen->w - 520) / 2;
- Sint16 start_y = 25;
- Uint16 w = 520;
- Uint16 h = 124;
+ Sint16 start_x = (Main.screen->w - adj_size(520)) / 2;
+ Sint16 start_y = adj_size(25);
+ Uint16 w = adj_size(520);
+ Uint16 h = adj_size(8) + WINDOW_TILE_HIGH
+ + N_MSG_VIEW * str16size(create_str16_from_char("M",
PTSIZE_LOG_FONT)).h;
int len, i = 0;
struct message *pMsg = NULL;
struct GUI *pWindow = NULL, *pBuf = NULL;
@@ -260,17 +247,14 @@
WINDOW_TILE_HIGH, w - 1, WINDOW_TILE_HIGH, 0xFF000000);
/* create static text on window */
- pStr = create_str16_from_char(_("Log"), 12);
+ pStr = create_str16_from_char(_("Log"), adj_font(12));
pStr->style = TTF_STYLE_BOLD;
pStr->render = 3;
- SDL_GetRGBA(get_first_pixel(pWindow->theme), pWindow->theme->format,
- &pStr->bgcol.r, &pStr->bgcol.g,
- &pStr->bgcol.b, &pStr->bgcol.unused);
+ pStr->bgcol = (SDL_Color) {0, 0, 0, 0};
pSurf = create_text_surf_from_str16(pStr);
- area.x += 10;
+ area.x += adj_size(10);
area.y += ((WINDOW_TILE_HIGH - pSurf->h) / 2);
- SDL_SetAlpha(pSurf, 0x0, 0x0);
SDL_BlitSurface(pSurf, NULL, pWindow->theme, &area);
FREESURFACE(pSurf);
FREESTRING16(pStr);
@@ -290,7 +274,7 @@
for(i=0; i<msg_count; i++)
{
pMsg = get_message(i);
- pStr = create_str16_from_char(pMsg->descr , 10);
+ pStr = create_str16_from_char(pMsg->descr , PTSIZE_LOG_FONT);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
(WF_DRAW_THEME_TRANSPARENT|WF_DRAW_TEXT_LABEL_WITH_SPACE));
@@ -301,7 +285,7 @@
pBuf->size.w = w;
pBuf->data.ptr = (void *)pMsg;
pBuf->action = msg_callback;
- if(pMsg->x != -1) {
+ if(pMsg->tile) {
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->string16->fgcol = active_color;
}
@@ -322,7 +306,7 @@
len = create_vertical_scrollbar(pMsg_Dlg, 1, N_MSG_VIEW, TRUE, TRUE);
setup_vertical_scrollbar_area(pMsg_Dlg->pScroll,
- start_x + w - 1, start_y + 1, h -2, TRUE);
+ start_x + w - 1, start_y + 1, h - adj_size(2), TRUE);
if(i>N_MSG_VIEW-1) {
/* find pActiveWidgetList to draw last seen part of list */
@@ -358,7 +342,7 @@
}
setup_vertical_widgets_position(1,
- start_x + FRAME_WH, start_y + WINDOW_TILE_HIGH + 2, len, 0,
+ start_x + FRAME_WH, start_y + WINDOW_TILE_HIGH + adj_size(2), len, 0,
pMsg_Dlg->pBeginActiveWidgetList, pBuf);
}
diff -u -r -b -B -X devel/diff_ignore
devel_distclean/client/gui-sdl/optiondlg.c devel/client/gui-sdl/optiondlg.c
--- devel_distclean/client/gui-sdl/optiondlg.c 2005-10-16 21:48:59.000000000
+0200
+++ devel/client/gui-sdl/optiondlg.c 2005-11-15 06:52:45.000000000 +0100
@@ -179,7 +179,7 @@
(get_wstate(pOption_Dlg->pADlg->pBeginActiveWidgetList) ==
FC_WS_DISABLED)) {
set_wstate(pOption_Dlg->pADlg->pBeginActiveWidgetList, FC_WS_NORMAL);
pOption_Dlg->pADlg->pBeginActiveWidgetList->string16->fgcol =
- *(get_game_colorRGB(COLOR_STD_BLACK));
+ (SDL_Color){0, 0, 0, 255};
}
redraw_group(pOption_Dlg->pBeginOptionsWidgetList,
@@ -228,7 +228,7 @@
/* create list element */
pNew_WorkList_Widget = create_iconlabel_from_chars(NULL, pWidget->dst,
- game.player_ptr->worklists[j].name, 12,
WF_DRAW_THEME_TRANSPARENT);
+ game.player_ptr->worklists[j].name, adj_font(12),
WF_DRAW_THEME_TRANSPARENT);
pNew_WorkList_Widget->ID = MAX_ID - j;
pNew_WorkList_Widget->string16->style |= SF_CENTER;
set_wstate(pNew_WorkList_Widget, FC_WS_NORMAL);
@@ -239,8 +239,8 @@
redraw_all = add_widget_to_vertical_scroll_widget_list(pOption_Dlg->pADlg,
pNew_WorkList_Widget,
pWidget, TRUE,
- pWindow->size.x + 20,
- pWindow->size.y + WINDOW_TILE_HIGH + 1 + 20);
+ pWindow->size.x + adj_size(20),
+ pWindow->size.y + WINDOW_TILE_HIGH + 1 + adj_size(20));
/* find if there was scrollbar shown */
if(scroll && pOption_Dlg->pADlg->pActiveWidgetList != NULL) {
@@ -296,10 +296,11 @@
{
struct GUI *pBuf = NULL, *pWindow = pOption_Dlg->pEndOptionsWidgetList;
int i , count = 0, len;
- SDL_Rect area = {pWindow->size.x + 15,
- pWindow->size.y + WINDOW_TILE_HIGH + 1 + 15,
- pWindow->size.w - 30,
- pWindow->size.h - WINDOW_TILE_HIGH - 2 - 30};
+ SDL_Color c;
+ SDL_Rect area = {pWindow->size.x + adj_size(15),
+ pWindow->size.y + WINDOW_TILE_HIGH + 1 + adj_size(15),
+ pWindow->size.w - adj_size(30),
+ pWindow->size.h - WINDOW_TILE_HIGH - adj_size(2) -
adj_size(30)};
/* clear flag */
SDL_Client_Flags &= ~CF_OPTION_MAIN;
@@ -312,7 +313,8 @@
pBuf = create_iconlabel(create_surf(area.w, area.h - 30, SDL_SWSURFACE),
pWindow->dst, NULL, WF_FREE_THEME);
pBuf->size = area;
- SDL_FillRect(pBuf->theme, NULL, get_game_color(COLOR_STD_WHITE,
pBuf->theme));
+ c = (SDL_Color){255, 255, 255, 255};
+ SDL_FillRect(pBuf->theme, NULL, SDL_MapRGBA(pBuf->theme->format, c.r, c.g,
c.b, c.unused));
SDL_SetAlpha(pBuf->theme, SDL_SRCALPHA, 128);
putframe(pBuf->theme, 0, 0, pBuf->theme->w - 1, pBuf->theme->h - 1, 0x0);
add_to_gui_list(ID_LABEL, pBuf);
@@ -321,7 +323,7 @@
for (i = 0; i < MAX_NUM_WORKLISTS; i++) {
if (game.player_ptr->worklists[i].is_valid) {
pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,
- game.player_ptr->worklists[i].name, 12,
+ game.player_ptr->worklists[i].name, adj_font(12),
WF_DRAW_THEME_TRANSPARENT);
set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(MAX_ID - i, pBuf);
@@ -337,7 +339,7 @@
if(count < MAX_NUM_WORKLISTS) {
pBuf = create_iconlabel_from_chars(NULL, pWindow->dst,
- _("Add new worklist"), 12, WF_DRAW_THEME_TRANSPARENT);
+ _("Add new worklist"), adj_font(12), WF_DRAW_THEME_TRANSPARENT);
set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(ID_ADD_NEW_WORKLIST, pBuf);
pBuf->action = add_new_worklist_callback;
@@ -369,7 +371,7 @@
len = create_vertical_scrollbar(pOption_Dlg->pADlg,
1, 13, TRUE, TRUE);
setup_vertical_scrollbar_area(pOption_Dlg->pADlg->pScroll,
- area.x + area.w - 1, area.y + 1, area.h - 32, TRUE);
+ area.x + area.w - 1, area.y + 1, area.h - adj_size(32), TRUE);
if(count>13) {
pOption_Dlg->pADlg->pActiveWidgetList =
@@ -380,9 +382,9 @@
}
/* ----------------------------- */
- setup_vertical_widgets_position(1, pWindow->size.x + 20,
- pWindow->size.y + WINDOW_TILE_HIGH + 1 + 20,
- area.w - 10 - len, 0,
+ setup_vertical_widgets_position(1, pWindow->size.x + adj_size(20),
+ pWindow->size.y + WINDOW_TILE_HIGH + 1 + adj_size(20),
+ area.w - adj_size(10) - len, 0,
pOption_Dlg->pADlg->pBeginActiveWidgetList,
pOption_Dlg->pADlg->pEndActiveWidgetList);
@@ -484,6 +486,10 @@
set_new_mini_map_window_pos();
set_new_order_widgets_dest_buffers();
+ if (get_client_state() == CLIENT_GAME_RUNNING_STATE) {
+ map_canvas_resized(Main.screen->w, Main.screen->h);
+ }
+
/* Options Dlg Window */
pWindow = pOption_Dlg->pEndOptionsWidgetList;
@@ -510,6 +516,30 @@
/**************************************************************************
...
**************************************************************************/
+#if defined UNDER_CE && defined SMALL_SCREEN
+
+/* under Windows CE with 320x240 resolution there's no need to switch
resolutions,
+ but to switch between window mode and full screen mode, because in full
screen
+ mode you can't access the software keyboard, but in window mode you have a
+ disturbing title bar, so you would switch to window mode if you need the
+ keyboard and go back to full screen if you've finished typing
+*/
+
+static int togle_fullscreen_callback(struct GUI *pWidget)
+{
+ SDL_Client_Flags ^= CF_TOGGLED_FULLSCREEN;
+
+ if (SDL_Client_Flags & CF_TOGGLED_FULLSCREEN) {
+ set_video_mode(320, 240, SDL_SWSURFACE | SDL_ANYFORMAT | SDL_FULLSCREEN);
+ } else {
+ set_video_mode(320, 240, SDL_SWSURFACE | SDL_ANYFORMAT);
+ }
+
+ flush_all();
+
+ return -1;
+}
+#else
static int togle_fullscreen_callback(struct GUI *pWidget)
{
int i = 0;
@@ -570,7 +600,7 @@
return -1;
}
-
+#endif
/**************************************************************************
...
**************************************************************************/
@@ -583,6 +613,8 @@
SDL_String16 *pStr;
struct GUI *pTmpGui = NULL, *pWindow = pOption_Dlg->pEndOptionsWidgetList;
+#if !defined UNDER_CE || !defined SMALL_SCREEN
+
/* don't free this */
SDL_Rect **pModes_Rect =
SDL_ListModes(NULL, SDL_FULLSCREEN | Main.screen->flags);
@@ -599,6 +631,7 @@
return 0;
/* fix ME */
}
+#endif
/* clear flag */
SDL_Client_Flags &= ~CF_OPTION_MAIN;
@@ -617,7 +650,7 @@
}
pTmpGui = create_iconlabel(NULL, pWindow->dst,
- create_str16_from_char(cBuf, 10), 0);
+ create_str16_from_char(cBuf, adj_font(10)), 0);
pTmpGui->string16->style |= (TTF_STYLE_BOLD|SF_CENTER);
pTmpGui->string16->fgcol.r = 255;
pTmpGui->string16->fgcol.g = 255;
@@ -627,21 +660,21 @@
pTmpGui->size.w = pWindow->size.w;
pTmpGui->size.x = pWindow->size.x;
- pTmpGui->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 6;
+ pTmpGui->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(6);
add_to_gui_list(ID_OPTIONS_RESOLUTION_LABEL, pTmpGui);
- pStr = create_str16_from_char(_("Fullscreen Mode"), 10);
+ pStr = create_str16_from_char(_("Fullscreen Mode"), adj_font(10));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER_RIGHT);
/* fullscreen mode label */
pTmpGui =
- create_themelabel(create_filled_surface(150, 30, SDL_SWSURFACE, NULL),
- pWindow->dst, pStr, 150, 30, 0);
+ create_themelabel(create_filled_surface(adj_size(150), adj_size(30),
SDL_SWSURFACE, NULL),
+ pWindow->dst, pStr, adj_size(150), adj_size(30), 0);
xxx = pTmpGui->size.x = pWindow->size.x +
((pWindow->size.w - pTmpGui->size.w) / 2);
- pTmpGui->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 40;
+ pTmpGui->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(40);
add_to_gui_list(ID_OPTIONS_FULLSCREEN_LABEL, pTmpGui);
@@ -653,27 +686,30 @@
pTmpGui->action = togle_fullscreen_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = xxx + 5;
- pTmpGui->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 45;
+ pTmpGui->size.x = xxx + adj_size(5);
+ pTmpGui->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(45);
add_to_gui_list(ID_OPTIONS_TOGGLE_FULLSCREEN_CHECKBOX, pTmpGui);
/* ------------------------- */
+#if !defined UNDER_CE || !defined SMALL_SCREEN
+
/* create modes buttons */
for (i = 0; pModes_Rect[i]; i++) {
- if (i && ((pModes_Rect[i]->w == pModes_Rect[i - 1]->w) ||
- (pModes_Rect[i]->w < 640 && pModes_Rect[i]->h < 480))) {
+ if (i && ((pModes_Rect[i]->w == pModes_Rect[i - 1]->w)
+ || ((pModes_Rect[i]->w < 640 && pModes_Rect[i]->h < 480)
+ && !(pModes_Rect[i]->w == 320 && pModes_Rect[i]->h == 240)))) {
continue;
}
my_snprintf(cBuf, sizeof(cBuf), "%dx%d",
pModes_Rect[i]->w, pModes_Rect[i]->h);
- pTmpGui = create_icon_button_from_chars(NULL, pWindow->dst, cBuf, 14, 0);
+ pTmpGui = create_icon_button_from_chars(NULL, pWindow->dst, cBuf,
adj_font(14), 0);
if (len) {
pTmpGui->size.w = len;
} else {
- pTmpGui->size.w += 6;
+ pTmpGui->size.w += adj_size(6);
len = pTmpGui->size.w;
}
@@ -693,7 +729,7 @@
if ((i == 1) && (pModes_Rect[0]->w > 640))
{
pTmpGui = create_icon_button_from_chars(NULL,
- pWindow->dst, "640x480", 14, 0);
+ pWindow->dst, "640x480", adj_font(14),
0);
if (len) {
pTmpGui->size.w = len;
@@ -713,10 +749,11 @@
/* ugly hack */
add_to_gui_list((MAX_ID - 1), pTmpGui);
}
+#endif
/* ------------------------- */
pOption_Dlg->pBeginOptionsWidgetList = pTmpGui;
-
+#if !defined UNDER_CE || !defined SMALL_SCREEN
if(count % 5) {
count /= 5;
count++;
@@ -729,22 +766,22 @@
pTmpGui->size.x =
pWindow->size.x +
- (pWindow->size.w - count * (pTmpGui->size.w + 10) - 10) / 2;
- pTmpGui->size.y = pWindow->size.y + 110;
+ (pWindow->size.w - count * (pTmpGui->size.w + adj_size(10)) -
adj_size(10)) / 2;
+ pTmpGui->size.y = pWindow->size.y + adj_size(110);
count = 0;
for (pTmpGui = pTmpGui->prev; pTmpGui; pTmpGui = pTmpGui->prev) {
if(count < 4) {
pTmpGui->size.x = pTmpGui->next->size.x;
- pTmpGui->size.y = pTmpGui->next->size.y + pTmpGui->next->size.h + 10;
+ pTmpGui->size.y = pTmpGui->next->size.y + pTmpGui->next->size.h +
adj_size(10);
count++;
} else {
- pTmpGui->size.x = pTmpGui->next->size.x + pTmpGui->size.w + 10;
- pTmpGui->size.y = pWindow->size.y + 110;
+ pTmpGui->size.x = pTmpGui->next->size.x + pTmpGui->size.w + adj_size(10);
+ pTmpGui->size.y = pWindow->size.y + adj_size(110);
count = 0;
}
}
-
+#endif
redraw_group(pOption_Dlg->pBeginOptionsWidgetList,
pOption_Dlg->pEndOptionsWidgetList, 0);
flush_rect(pWindow->size);
@@ -900,18 +937,18 @@
pTmpGui->action = sound_bell_at_new_turn_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
- pTmpGui->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 6;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
+ pTmpGui->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(6);
add_to_gui_list(ID_OPTIONS_LOCAL_SOUND_CHECKBOX, pTmpGui);
/* 'sound befor new turn' label */
- pStr = create_str16_from_char(_("Sound bell at new turn"), 10);
+ pStr = create_str16_from_char(_("Sound bell at new turn"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_OPTIONS_LOCAL_SOUND_LABEL, pTmpGui);
@@ -922,23 +959,23 @@
/* edit */
my_snprintf(cBuf, sizeof(cBuf), "%d", smooth_move_unit_msec);
- pTmpGui = create_edit_from_chars(NULL, pWindow->dst, cBuf, 11, 25,
+ pTmpGui = create_edit_from_chars(NULL, pWindow->dst, cBuf, adj_font(11),
adj_size(25),
WF_DRAW_THEME_TRANSPARENT);
-
pTmpGui->action = smooth_move_unit_msec_callback;
+ set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 12;
+ pTmpGui->size.x = pWindow->size.x + adj_size(12);
add_to_gui_list(ID_OPTIONS_LOCAL_MOVE_STEP_EDIT, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("Smooth unit move steps"), 10);
+ pStr = create_str16_from_char(_("Smooth unit move steps"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_OPTIONS_LOCAL_MOVE_STEP_LABEL, pTmpGui);
@@ -954,18 +991,18 @@
pTmpGui->action = do_combat_animation_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
add_to_gui_list(ID_OPTIONS_LOCAL_COMBAT_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("Show combat animation"), 10);
+ pStr = create_str16_from_char(_("Show combat animation"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_OPTIONS_LOCAL_COMBAT_LABEL, pTmpGui);
@@ -981,18 +1018,18 @@
pTmpGui->action = do_focus_animation_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
add_to_gui_list(ID_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("Show focus animation"), 10);
+ pStr = create_str16_from_char(_("Show focus animation"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_LABEL, pTmpGui);
@@ -1008,18 +1045,18 @@
pTmpGui->action = do_cursor_animation_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
add_to_gui_list(ID_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("Show cursors animation"), 10);
+ pStr = create_str16_from_char(_("Show cursors animation"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_LABEL, pTmpGui);
@@ -1034,18 +1071,18 @@
pTmpGui->action = auto_center_on_unit_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
add_to_gui_list(ID_OPTIONS_LOCAL_ACENTER_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("Auto Center on Units"), 10);
+ pStr = create_str16_from_char(_("Auto Center on Units"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_OPTIONS_LOCAL_ACENTER_LABEL, pTmpGui);
@@ -1060,18 +1097,18 @@
pTmpGui->action = auto_center_on_combat_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
add_to_gui_list(ID_OPTIONS_LOCAL_COMBAT_CENTER_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("Auto Center on Combat"), 10);
+ pStr = create_str16_from_char(_("Auto Center on Combat"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_OPTIONS_LOCAL_COMBAT_CENTER_LABEL, pTmpGui);
@@ -1087,18 +1124,18 @@
pTmpGui->action = wakeup_focus_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
add_to_gui_list(ID_OPTIONS_LOCAL_ACTIVE_UNITS_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("Focus on Awakened Units"), 10);
+ pStr = create_str16_from_char(_("Focus on Awakened Units"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_OPTIONS_LOCAL_ACTIVE_UNITS_LABEL, pTmpGui);
@@ -1113,18 +1150,18 @@
pTmpGui->action = popup_new_cities_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
add_to_gui_list(ID_OPTIONS_LOCAL_CITY_CENTER_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("Pop up city dialog for new cities"), 10);
+ pStr = create_str16_from_char(_("Pop up city dialog for new cities"),
adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_OPTIONS_LOCAL_CITY_CENTER_LABEL, pTmpGui);
@@ -1139,18 +1176,18 @@
pTmpGui->action = ask_city_names_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
add_to_gui_list(ID_OPTIONS_LOCAL_CITY_CENTER_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("Prompt for city names"), 10);
+ pStr = create_str16_from_char(_("Prompt for city names"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_OPTIONS_LOCAL_CITY_CENTER_LABEL, pTmpGui);
@@ -1165,18 +1202,18 @@
pTmpGui->action = auto_turn_done_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
add_to_gui_list(ID_OPTIONS_LOCAL_END_TURN_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("End Turn when done moving"), 10);
+ pStr = create_str16_from_char(_("End Turn when done moving"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_OPTIONS_LOCAL_END_TURN_LABEL, pTmpGui);
@@ -1401,17 +1438,6 @@
/**************************************************************************
...
**************************************************************************/
-static int draw_civ3_city_text_style_callback(struct GUI *pWidget)
-{
- redraw_icon(pWidget);
- flush_rect(pWidget->size);
- SDL_Client_Flags ^= CF_CIV3_CITY_TEXT_STYLE;
- return -1;
-}
-
-/**************************************************************************
- ...
-**************************************************************************/
static int map_setting_callback(struct GUI *pWidget)
{
SDL_Color text_color = {255, 255, 0, 255};
@@ -1433,18 +1459,18 @@
pTmpGui->action = draw_city_names_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
- pTmpGui->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 6;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
+ pTmpGui->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(6);
add_to_gui_list(ID_OPTIONS_MAP_CITY_NAMES_CHECKBOX, pTmpGui);
/* label */
- pStr = create_str16_from_char(_("City Names"), 10);
+ pStr = create_str16_from_char(_("City Names"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_OPTIONS_MAP_CITY_NAMES_LABEL, pTmpGui);
@@ -1459,18 +1485,18 @@
pTmpGui->action = draw_city_productions_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
add_to_gui_list(ID_OPTIONS_MAP_CITY_PROD_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("City Production"), 10);
+ pStr = create_str16_from_char(_("City Production"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_OPTIONS_MAP_CITY_NAMES_LABEL, pTmpGui);
@@ -1485,18 +1511,18 @@
pTmpGui->action = borders_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
add_to_gui_list(ID_OPTIONS_MAP_BORDERS_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("National Borders"), 10);
+ pStr = create_str16_from_char(_("National Borders"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_OPTIONS_MAP_BORDERS_LABEL, pTmpGui);
@@ -1511,18 +1537,18 @@
pTmpGui->action = draw_terrain_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
add_to_gui_list(ID_OPTIONS_MAP_CITY_PROD_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("Terrain"), 10);
+ pStr = create_str16_from_char(_("Terrain"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_LABEL, pTmpGui);
@@ -1537,18 +1563,18 @@
pTmpGui->action = map_grid_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
add_to_gui_list(ID_OPTIONS_MAP_GRID_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* 'sound befor new turn' label */
- pStr = create_str16_from_char(_("Map Grid"), 10);
+ pStr = create_str16_from_char(_("Map Grid"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_OPTIONS_MAP_GRID_LABEL, pTmpGui);
@@ -1565,18 +1591,18 @@
if (draw_map_grid) {
set_wstate(pTmpGui, FC_WS_NORMAL);
}
- pTmpGui->size.x = pWindow->size.x + 35;
+ pTmpGui->size.x = pWindow->size.x + adj_size(35);
add_to_gui_list(ID_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("Draw city map grid"), 10);
+ pStr = create_str16_from_char(_("Draw city map grid"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 75;
+ pTmpGui->size.x = pWindow->size.x + adj_size(75);
add_to_gui_list(ID_LABEL, pTmpGui);
@@ -1595,18 +1621,18 @@
set_wstate(pTmpGui, FC_WS_NORMAL);
}
- pTmpGui->size.x = pWindow->size.x + 35;
+ pTmpGui->size.x = pWindow->size.x + adj_size(35);
add_to_gui_list(ID_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("Draw city worker map grid"), 10);
+ pStr = create_str16_from_char(_("Draw city worker map grid"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 75;
+ pTmpGui->size.x = pWindow->size.x + adj_size(75);
add_to_gui_list(ID_LABEL, pTmpGui);
@@ -1622,18 +1648,18 @@
pTmpGui->action = draw_specials_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_SPEC_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("Special Resources"), 10);
+ pStr = create_str16_from_char(_("Special Resources"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_SPEC_LABEL, pTmpGui);
@@ -1649,18 +1675,18 @@
pTmpGui->action = draw_pollution_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_POLL_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("Pollution"), 10);
+ pStr = create_str16_from_char(_("Pollution"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_POLL_LABEL, pTmpGui);
@@ -1676,18 +1702,18 @@
pTmpGui->action = draw_cities_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_CITY_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("Cities"), 10);
+ pStr = create_str16_from_char(_("Cities"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_CITY_LABEL, pTmpGui);
@@ -1703,18 +1729,18 @@
pTmpGui->action = draw_units_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_UNITS_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 3;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(3);
/* label */
- pStr = create_str16_from_char(_("Units"), 10);
+ pStr = create_str16_from_char(_("Units"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_UNITS_LABEL, pTmpGui);
@@ -1730,18 +1756,18 @@
pTmpGui->action = draw_fog_of_war_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 15;
+ pTmpGui->size.x = pWindow->size.x + adj_size(15);
add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_FOG_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 3;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(3);
/* label */
- pStr = create_str16_from_char(_("Fog of War"), 10);
+ pStr = create_str16_from_char(_("Fog of War"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 55;
+ pTmpGui->size.x = pWindow->size.x + adj_size(55);
add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_FOG_LABEL, pTmpGui);
@@ -1756,18 +1782,18 @@
pTmpGui->action = draw_roads_rails_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 170;
- pTmpGui->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 6;
+ pTmpGui->size.x = pWindow->size.x + adj_size(170);
+ pTmpGui->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(6);
add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_RR_CHECKBOX, pTmpGui);
/* label */
- pStr = create_str16_from_char(_("Roads and Rails"), 10);
+ pStr = create_str16_from_char(_("Roads and Rails"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 210;
+ pTmpGui->size.x = pWindow->size.x + adj_size(210);
add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_RR_LABEL, pTmpGui);
@@ -1782,18 +1808,18 @@
pTmpGui->action = draw_irrigation_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 170;
+ pTmpGui->size.x = pWindow->size.x + adj_size(170);
add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_IR_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("Irrigation"), 10);
+ pStr = create_str16_from_char(_("Irrigation"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 210;
+ pTmpGui->size.x = pWindow->size.x + adj_size(210);
add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_IR_LABEL, pTmpGui);
@@ -1809,18 +1835,18 @@
pTmpGui->action = draw_mines_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 170;
+ pTmpGui->size.x = pWindow->size.x + adj_size(170);
add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_M_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("Mines"), 10);
+ pStr = create_str16_from_char(_("Mines"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 210;
+ pTmpGui->size.x = pWindow->size.x + adj_size(210);
add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_M_LABEL, pTmpGui);
@@ -1835,24 +1861,25 @@
pTmpGui->action = draw_fortress_airbase_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 170;
+ pTmpGui->size.x = pWindow->size.x + adj_size(170);
add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_FA_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("Fortress and Airbase"), 10);
+ pStr = create_str16_from_char(_("Fortress and Airbase"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 210;
+ pTmpGui->size.x = pWindow->size.x + adj_size(210);
add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_FA_LABEL, pTmpGui);
pTmpGui->size.y = pTmpGui->next->size.y +
(pTmpGui->next->size.h - pTmpGui->size.h) / 2;
+#if 0
/* Civ3 / Classic CITY Text Style */
/* check box */
pTmpGui = create_checkbox(pWindow->dst,
@@ -1862,24 +1889,24 @@
pTmpGui->action = draw_civ3_city_text_style_callback;
set_wstate(pTmpGui, FC_WS_NORMAL);
- pTmpGui->size.x = pWindow->size.x + 170;
+ pTmpGui->size.x = pWindow->size.x + adj_size(170);
add_to_gui_list(ID_OPTIONS_MAP_CITY_CIV3_TEXT_STYLE_CHECKBOX, pTmpGui);
- pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + 4;
+ pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h +
adj_size(4);
/* label */
- pStr = create_str16_from_char(_("Civ3 city text style"), 10);
+ pStr = create_str16_from_char(_("Civ3 city text style"), adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->fgcol = text_color;
pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0);
- pTmpGui->size.x = pWindow->size.x + 210;
+ pTmpGui->size.x = pWindow->size.x + adj_size(210);
add_to_gui_list(ID_OPTIONS_MAP_CITY_CIV3_TEXT_STYLE_LABEL, pTmpGui);
pTmpGui->size.y = pTmpGui->next->size.y +
(pTmpGui->next->size.h - pTmpGui->size.h) / 2;
-
+#endif
/* ================================================== */
pOption_Dlg->pBeginOptionsWidgetList = pTmpGui;
@@ -1959,7 +1986,10 @@
pOption_Dlg->pBeginCoreOptionsWidgetList->prev);
SDL_Client_Flags |= CF_OPTION_MAIN;
+
+ #if !(defined UNDER_CE && defined SMALL_SCREEN)
SDL_Client_Flags &= ~CF_TOGGLED_FULLSCREEN;
+ #endif
redraw_group(pOption_Dlg->pBeginOptionsWidgetList,
pOption_Dlg->pEndOptionsWidgetList, 0);
@@ -1972,7 +2002,7 @@
/**************************************************************************
...
**************************************************************************/
-static int optiondlg_callback(struct GUI *pButton)
+int optiondlg_callback(struct GUI *pButton)
{
set_wstate(pButton, FC_WS_DISABLED);
SDL_FillRect(pButton->dst, &pButton->size, 0x0);
@@ -1993,14 +2023,17 @@
pOptions_Button = create_themeicon(pTheme->Options_Icon, Main.gui,
(WF_WIDGET_HAS_INFO_LABEL |
WF_DRAW_THEME_TRANSPARENT));
- pOptions_Button->size.x = 5;
- pOptions_Button->size.y = 5;
+ pOptions_Button->size.x = adj_size(5);
+ pOptions_Button->size.y = adj_size(5);
pOptions_Button->action = optiondlg_callback;
- pOptions_Button->string16 = create_str16_from_char(_("Options"), 12);
+ pOptions_Button->string16 = create_str16_from_char(_("Options"),
adj_font(12));
pOptions_Button->key = SDLK_TAB;
set_wstate(pOptions_Button, FC_WS_NORMAL);
set_wflag(pOptions_Button, WF_HIDDEN);
+
+ #ifndef SMALL_SCREEN
add_to_gui_list(ID_CLIENT_OPTIONS, pOptions_Button);
+ #endif
}
static int exit_callback(struct GUI *pWidget)
@@ -2032,10 +2065,10 @@
pLogo = get_logo_gfx();
/* create window widget */
- pStr = create_str16_from_char(_("Options"), 12);
+ pStr = create_str16_from_char(_("Options"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 10, 10, 0);
+ pWindow = create_window(NULL, pStr, adj_size(10), adj_size(10), 0);
pWindow->action = main_optiondlg_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -2045,8 +2078,8 @@
w = 0;
/* create exit button */
pQuit = create_themeicon_button_from_chars(pTheme->CANCEL_Icon,
- pWindow->dst, _("Quit"), 12, 0);
- w += 10 + pQuit->size.w;
+ pWindow->dst, _("Quit"), adj_font(12), 0);
+ w += adj_size(10) + pQuit->size.w;
pQuit->action = exit_callback;
pQuit->key = SDLK_q;
set_wstate(pQuit, FC_WS_NORMAL);
@@ -2055,8 +2088,8 @@
/* create disconnection button */
if(aconnection.established) {
pDisconnect = create_themeicon_button_from_chars(pTheme->BACK_Icon,
- pWindow->dst, _("Disconnect"), 12, 0);
- w += 10 + pDisconnect->size.w + 10;
+ pWindow->dst, _("Disconnect"), adj_font(12), 0);
+ w += adj_size(10) + pDisconnect->size.w + adj_size(10);
pDisconnect->action = disconnect_callback;
set_wstate(pDisconnect, FC_WS_NORMAL);
add_to_gui_list(ID_OPTIONS_DISC_BUTTON, pDisconnect);
@@ -2064,8 +2097,8 @@
/* create back button */
pBack = create_themeicon_button_from_chars(pTheme->BACK_Icon,
- pWindow->dst, _("Back"), 12, 0);
- w += pBack->size.w + 10;
+ pWindow->dst, _("Back"), adj_font(12), 0);
+ w += pBack->size.w + adj_size(10);
pBack->action = back_callback;
pBack->key = SDLK_ESCAPE;
set_wstate(pBack, FC_WS_NORMAL);
@@ -2073,8 +2106,8 @@
pOption_Dlg->pBeginCoreOptionsWidgetList = pBack;
/* ------------------------------------------------------ */
- w = MAX(w, 360);
- h = 350;
+ w = MAX(w, adj_size(360));
+ h = adj_size(350);
start_x = (Main.screen->w - w) / 2;
start_y = (Main.screen->h - h) / 2;
@@ -2087,30 +2120,30 @@
if(aconnection.established) {
pDisconnect->size.x = start_x + (w - pDisconnect->size.w) / 2;
- pDisconnect->size.y = start_y + h - pDisconnect->size.h - 10;
+ pDisconnect->size.y = start_y + h - pDisconnect->size.h - adj_size(10);
- pBack->size.x = pDisconnect->size.x - 10 - pBack->size.w;
- pBack->size.y = start_y + h - pBack->size.h - 10;
+ pBack->size.x = pDisconnect->size.x - adj_size(10) - pBack->size.w;
+ pBack->size.y = start_y + h - pBack->size.h - adj_size(10);
- pQuit->size.x = pDisconnect->size.x + pDisconnect->size.w + 10;
- pQuit->size.y = start_y + h - pQuit->size.h - 10;
+ pQuit->size.x = pDisconnect->size.x + pDisconnect->size.w + adj_size(10);
+ pQuit->size.y = start_y + h - pQuit->size.h - adj_size(10);
} else {
- pBack->size.x = start_x + 10;
- pBack->size.y = start_y + h - pBack->size.h - 10;
+ pBack->size.x = start_x + adj_size(10);
+ pBack->size.y = start_y + h - pBack->size.h - adj_size(10);
- pQuit->size.x = start_x + w - pQuit->size.w - 10;
- pQuit->size.y = start_y + h - pQuit->size.h - 10;
+ pQuit->size.x = start_x + w - pQuit->size.w - adj_size(10);
+ pQuit->size.y = start_y + h - pQuit->size.h - adj_size(10);
}
/* ============================================================= */
/* create video button widget */
pTmp_GUI = create_icon_button_from_chars(NULL,
- pWindow->dst, _("Video options"), 12, 0);
- pTmp_GUI->size.y = start_y + 60;
+ pWindow->dst, _("Video options"), adj_font(12), 0);
+ pTmp_GUI->size.y = start_y + adj_size(60);
pTmp_GUI->action = video_callback;
set_wstate(pTmp_GUI, FC_WS_NORMAL);
- pTmp_GUI->size.h += 4;
+ pTmp_GUI->size.h += adj_size(4);
longest = MAX(longest, pTmp_GUI->size.w);
@@ -2118,11 +2151,11 @@
/* create sound button widget */
pTmp_GUI = create_icon_button_from_chars(NULL,
- pWindow->dst, _("Sound options"), 12, 0);
- pTmp_GUI->size.y = start_y + 90;
+ pWindow->dst, _("Sound options"), adj_font(12),
0);
+ pTmp_GUI->size.y = start_y + adj_size(90);
pTmp_GUI->action = sound_callback;
/* set_wstate( pTmp_GUI, FC_WS_NORMAL ); */
- pTmp_GUI->size.h += 4;
+ pTmp_GUI->size.h += adj_size(4);
longest = MAX(longest, pTmp_GUI->size.w);
add_to_gui_list(ID_OPTIONS_SOUND_BUTTON, pTmp_GUI);
@@ -2131,22 +2164,22 @@
/* create local button widget */
pTmp_GUI =
create_icon_button_from_chars(NULL, pWindow->dst,
- _("Game options"), 12, 0);
- pTmp_GUI->size.y = start_y + 120;
+ _("Game options"), adj_font(12), 0);
+ pTmp_GUI->size.y = start_y + adj_size(120);
pTmp_GUI->action = local_setting_callback;
set_wstate(pTmp_GUI, FC_WS_NORMAL);
- pTmp_GUI->size.h += 4;
+ pTmp_GUI->size.h += adj_size(4);
longest = MAX(longest, pTmp_GUI->size.w);
add_to_gui_list(ID_OPTIONS_LOCAL_BUTTON, pTmp_GUI);
/* create map button widget */
pTmp_GUI = create_icon_button_from_chars(NULL,
- pWindow->dst, _("Map options"), 12, 0);
- pTmp_GUI->size.y = start_y + 150;
+ pWindow->dst, _("Map options"), adj_font(12),
0);
+ pTmp_GUI->size.y = start_y + adj_size(150);
pTmp_GUI->action = map_setting_callback;
set_wstate(pTmp_GUI, FC_WS_NORMAL);
- pTmp_GUI->size.h += 4;
+ pTmp_GUI->size.h += adj_size(4);
longest = MAX(longest, pTmp_GUI->size.w);
add_to_gui_list(ID_OPTIONS_MAP_BUTTON, pTmp_GUI);
@@ -2154,15 +2187,15 @@
/* create work lists widget */
pTmp_GUI = create_icon_button_from_chars(NULL,
- pWindow->dst, _("Worklists"), 12, 0);
- pTmp_GUI->size.y = start_y + 180;
+ pWindow->dst, _("Worklists"), adj_font(12), 0);
+ pTmp_GUI->size.y = start_y + adj_size(180);
pTmp_GUI->action = work_lists_callback;
if (get_client_state() == CLIENT_GAME_RUNNING_STATE) {
set_wstate(pTmp_GUI, FC_WS_NORMAL);
}
- pTmp_GUI->size.h += 4;
+ pTmp_GUI->size.h += adj_size(4);
longest = MAX(longest, pTmp_GUI->size.w);
add_to_gui_list(ID_OPTIONS_WORKLIST_BUTTON, pTmp_GUI);
@@ -2184,7 +2217,10 @@
sdl_dirty_rect(pWindow->size);
SDL_Client_Flags |= (CF_OPTION_MAIN | CF_OPTION_OPEN);
+
+ #if !(defined UNDER_CE && defined SMALL_SCREEN)
SDL_Client_Flags &= ~CF_TOGGLED_FULLSCREEN;
+ #endif
disable_main_widgets();
@@ -2199,8 +2235,13 @@
if (pOption_Dlg) {
popdown_window_group_dialog(pOption_Dlg->pBeginOptionsWidgetList,
pOption_Dlg->pEndOptionsWidgetList);
- SDL_Client_Flags &= ~(CF_OPTION_MAIN | CF_OPTION_OPEN |
- CF_TOGGLED_FULLSCREEN);
+
+ SDL_Client_Flags &= ~(CF_OPTION_MAIN | CF_OPTION_OPEN);
+
+ #if !(defined UNDER_CE && defined SMALL_SCREEN)
+ SDL_Client_Flags &= ~CF_TOGGLED_FULLSCREEN;
+ #endif
+
FREE(pOption_Dlg);
enable_main_widgets();
}
diff -u -r -b -B -X devel/diff_ignore
devel_distclean/client/gui-sdl/optiondlg.h devel/client/gui-sdl/optiondlg.h
--- devel_distclean/client/gui-sdl/optiondlg.h 2005-10-15 23:27:27.000000000
+0200
+++ devel/client/gui-sdl/optiondlg.h 2005-11-15 06:52:45.000000000 +0100
@@ -22,8 +22,11 @@
#ifndef FC__OPTIONDLG_H
#define FC__OPTIONDLG_H
+struct GUI *pOptions_Button;
+
void init_options_button(void);
void popup_optiondlg(void);
void podown_optiondlg(void);
+int optiondlg_callback(struct GUI *pButton);
#endif /* FC__OPTIONDLG_H */
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/pages.c
devel/client/gui-sdl/pages.c
--- devel_distclean/client/gui-sdl/pages.c 2005-10-15 20:41:57.000000000
+0200
+++ devel/client/gui-sdl/pages.c 2005-11-15 06:52:45.000000000 +0100
@@ -15,6 +15,9 @@
#include <config.h>
#endif
+#include "connectdlg_g.h"
+#include "log.h"
+
#include "pages.h"
/**************************************************************************
@@ -24,5 +27,35 @@
void set_client_page(enum client_pages page)
{
/* PORTME */
+ freelog(LOG_DEBUG, "PORT ME: set_client_page()");
+}
+
+/****************************************************************************
+ Set the list of available rulesets. The default ruleset should be
+ "default", and if the user changes this then set_ruleset() should be
+ called.
+****************************************************************************/
+void gui_set_rulesets(int num_rulesets, char **rulesets)
+{
+ /* PORTME */
+ freelog(LOG_DEBUG, "PORT ME: gui_set_rulesets()");
+}
+
+/**************************************************************************
+ Returns current client page
+**************************************************************************/
+enum client_pages get_client_page(void)
+{
+ /* PORTME*/
+ freelog(LOG_DEBUG, "PORT ME: get_client_page()");
+ return PAGE_MAIN;
}
+/**************************************************************************
+ update the start page.
+**************************************************************************/
+void update_start_page(void)
+{
+ /* PORTME*/
+ freelog(LOG_DEBUG, "PORT ME: update_start_page()");
+}
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/plrdlg.c
devel/client/gui-sdl/plrdlg.c
--- devel_distclean/client/gui-sdl/plrdlg.c 2005-10-18 00:31:10.000000000
+0200
+++ devel/client/gui-sdl/plrdlg.c 2005-11-15 06:52:45.000000000 +0100
@@ -191,6 +191,7 @@
struct player *pPlayer;
char cBuf[128], *state, *team;
int idle, x0, y0, x1, y1;
+ SDL_Color c;
/* redraw window */
redraw_widget(pPlayers_Dlg->pEndWidgetList);
@@ -203,8 +204,8 @@
pPlayer = pPlayer0->data.player;
/* the team */
- if (pPlayer->team != TEAM_NONE) {
- team = team_get_by_id(pPlayer->team)->name;
+ if (pPlayer->team) {
+ team = _(team_get_name(pPlayer->team));
} else {
team = _("none");
}
@@ -214,7 +215,7 @@
state = _("AI");
} else {
if (pPlayer->is_connected) {
- if (pPlayer->turn_done) {
+ if (pPlayer->phase_done) {
state = _("done");
} else {
state = _("moving");
@@ -235,11 +236,10 @@
}
my_snprintf(cBuf, sizeof(cBuf), _("Name : %s\nNation : %s\nTeam : %s\n"
- "Reputation : %s\nEmbassy :%s\n"
+ "Embassy :%s\n"
"State : %s\nIdle : %d %s"),
pPlayer->name, get_nation_name(pPlayer->nation),
- team, reputation_text(pPlayer->reputation),
- get_embassy_status(game.player_ptr, pPlayer),
+ team, get_embassy_status(game.player_ptr, pPlayer),
state, idle, PL_("turn", "turns", idle));
copy_chars_to_string16(pPlayer0->string16, cBuf);
@@ -262,26 +262,30 @@
break;
case DS_WAR:
if(SDL_Client_Flags & CF_DRAW_PLAYERS_WAR_STATUS) {
+ c = (SDL_Color){255, 0, 0, 255};
putline(pPlayer1->dst, x0, y0, x1, y1,
- get_game_color(COLOR_STD_RED, pPlayer1->dst));
+ SDL_MapRGBA(pPlayer1->dst->format, c.r, c.g, c.b,
c.unused));
}
break;
case DS_CEASEFIRE:
if (SDL_Client_Flags & CF_DRAW_PLAYERS_CEASEFIRE_STATUS) {
+ c = (SDL_Color){255, 255, 0, 255};
putline(pPlayer1->dst, x0, y0, x1, y1,
- get_game_color(COLOR_STD_YELLOW, pPlayer1->dst));
+ SDL_MapRGBA(pPlayer1->dst->format, c.r, c.g, c.b,
c.unused));
}
break;
case DS_PEACE:
if (SDL_Client_Flags & CF_DRAW_PLAYERS_PEACE_STATUS) {
+ c = (SDL_Color){0, 200, 0, 255};
putline(pPlayer1->dst, x0, y0, x1, y1,
- get_game_color(COLOR_STD_GROUND, pPlayer1->dst));
+ SDL_MapRGBA(pPlayer1->dst->format, c.r, c.g, c.b,
c.unused));
}
break;
case DS_ALLIANCE:
if (SDL_Client_Flags & CF_DRAW_PLAYERS_ALLIANCE_STATUS) {
+ c = *get_game_colorRGB(COLOR_STD_CITY_GOLD);
putline(pPlayer1->dst, x0, y0, x1, y1,
- get_game_color(COLOR_STD_CITY_GOLD, pPlayer1->dst));
+ SDL_MapRGBA(pPlayer1->dst->format, c.r, c.g, c.b,
c.unused));
}
break;
default:
@@ -308,7 +312,7 @@
/**************************************************************************
Popup (or raise) the player list dialog.
**************************************************************************/
-void popup_players_dialog(void)
+void popup_players_dialog(bool raise)
{
struct GUI *pWindow = NULL, *pBuf = NULL;
SDL_Surface *pLogo = NULL, *pZoomed = NULL;
@@ -336,10 +340,10 @@
pPlayers_Dlg = MALLOC(sizeof(struct SMALL_DLG));
- pStr = create_str16_from_char(_("Players"), 12);
+ pStr = create_str16_from_char(_("Players"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 10, 10, WF_DRAW_THEME_TRANSPARENT);
+ pWindow = create_window(NULL, pStr, adj_size(10), adj_size(10),
WF_DRAW_THEME_TRANSPARENT);
pWindow->action = players_window_dlg_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -411,10 +415,10 @@
continue;
}
- pStr = create_string16(NULL, 0, 10);
+ pStr = create_string16(NULL, 0, adj_font(10));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
- pLogo = GET_SURF(get_nation_by_idx(pPlayer->nation)->flag_sprite);
+ pLogo = GET_SURF(get_nation_flag_sprite(tileset, pPlayer->nation));
pLogo = make_flag_surface_smaler(pLogo);
pZoomed = ZoomSurface(pLogo, 3.0 - n * 0.05, 3.0 - n * 0.05 , 1);
SDL_SetColorKey(pZoomed, SDL_SRCCOLORKEY|SDL_RLEACCEL,
@@ -427,9 +431,9 @@
pBuf->string16 = pStr;
if(!pPlayer->is_alive) {
- pStr = create_str16_from_char("R.I.P" , 10);
+ pStr = create_str16_from_char("R.I.P" , adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
- pStr->fgcol = *(get_game_colorRGB(COLOR_STD_WHITE));
+ pStr->fgcol = (SDL_Color){255, 255, 255, 255};
pLogo = create_text_surf_from_str16(pStr);
FREESTRING16(pStr);
@@ -453,8 +457,8 @@
pPlayers_Dlg->pBeginWidgetList = pBuf;
- w = 500;
- h = 400;
+ w = adj_size(500);
+ h = adj_size(400);
r = MIN(w,h);
r -= ((MAX(pBuf->size.w, pBuf->size.h) * 2) + WINDOW_TILE_HIGH + FRAME_WH);
r /= 2;
@@ -473,24 +477,24 @@
pBuf->size.x = pWindow->size.x + pWindow->size.w-pBuf->size.w-FRAME_WH-1;
pBuf->size.y = pWindow->size.y + 1;
- n = WINDOW_TILE_HIGH + 4;
- pStr = create_string16(NULL, 0, 10);
+ n = WINDOW_TILE_HIGH + adj_size(4);
+ pStr = create_string16(NULL, 0, adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pStr->render = 3;
pStr->bgcol.unused = 128;
for(i = 0; i<DS_LAST; i++) {
switch (i) {
case DS_NEUTRAL:
- pStr->fgcol = *(get_game_colorRGB(COLOR_STD_BLACK));
+ pStr->fgcol = (SDL_Color){0, 0, 0, 255};
break;
case DS_WAR:
- pStr->fgcol = *(get_game_colorRGB(COLOR_STD_RED));
+ pStr->fgcol = (SDL_Color){255, 0, 0, 255};
break;
case DS_CEASEFIRE:
- pStr->fgcol = *(get_game_colorRGB(COLOR_STD_YELLOW));
+ pStr->fgcol = (SDL_Color){255, 255, 0, 255};
break;
case DS_PEACE:
- pStr->fgcol = *(get_game_colorRGB(COLOR_STD_GROUND));
+ pStr->fgcol = (SDL_Color){0, 200, 0, 255};
break;
case DS_ALLIANCE:
pStr->fgcol = *(get_game_colorRGB(COLOR_STD_CITY_GOLD));
@@ -507,10 +511,10 @@
pBuf = pBuf->prev;
h = MAX(pBuf->size.h, pLogo->h);
- pBuf->size.x = pWindow->size.x + 5;
+ pBuf->size.x = pWindow->size.x + adj_size(5);
pBuf->size.y = pWindow->size.y + n + (h - pBuf->size.h) / 2;
- dst.x = 5 + pBuf->size.w + 6;
+ dst.x = adj_size(5) + pBuf->size.w + adj_size(6);
dst.y = n + (h - pLogo->h) / 2;
SDL_BlitSurface(pLogo, NULL, pWindow->theme, &dst);
n += h;
@@ -587,7 +591,7 @@
}
break;
default:
- if(pPlayer->player_no != game.player_idx) {
+ if(pPlayer->player_no != game.info.player_idx) {
popup_diplomacy_dialog(pPlayer);
}
break;
@@ -613,14 +617,14 @@
return;
}
- h = WINDOW_TILE_HIGH + 3 + FRAME_WH;
+ h = WINDOW_TILE_HIGH + adj_size(3) + FRAME_WH;
pShort_Players_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
- pStr = create_str16_from_char(_("Nations") , 12);
+ pStr = create_str16_from_char(_("Nations") , adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 10, 10, WF_DRAW_THEME_TRANSPARENT);
+ pWindow = create_window(NULL, pStr, adj_size(10), adj_size(10),
WF_DRAW_THEME_TRANSPARENT);
pWindow->action = players_nations_window_dlg_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -632,7 +636,7 @@
/* exit button */
pBuf = create_themeicon(pTheme->Small_CANCEL_Icon, pWindow->dst,
WF_DRAW_THEME_TRANSPARENT);
- w += pBuf->size.w + 10;
+ w += pBuf->size.w + adj_size(10);
pBuf->action = exit_players_nations_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
@@ -641,7 +645,7 @@
/* ---------- */
for(i=0; i<game.info.nplayers; i++) {
- if(i != game.player_idx) {
+ if(i != game.info.player_idx) {
pPlayer = get_player(i);
if(!pPlayer->is_alive || is_barbarian(pPlayer)) {
@@ -654,7 +658,7 @@
state = _("AI");
} else {
if (pPlayer->is_connected) {
- if (pPlayer->turn_done) {
+ if (pPlayer->phase_done) {
state = _("done");
} else {
state = _("moving");
@@ -673,10 +677,10 @@
get_nation_name(pPlayer->nation), state);
}
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
- pLogo = GET_SURF(get_nation_by_idx(pPlayer->nation)->flag_sprite);
+ pLogo = GET_SURF(get_nation_flag_sprite(tileset, pPlayer->nation));
pLogo = make_flag_surface_smaler(pLogo);
pBuf = create_iconlabel(pLogo, pWindow->dst, pStr,
@@ -687,17 +691,17 @@
case DS_WAR:
if(can_meet_with_player(pPlayer) || can_intel_with_player(pPlayer)) {
set_wstate(pBuf, FC_WS_NORMAL);
- pBuf->string16->fgcol = *(get_game_colorRGB(COLOR_STD_RED));
+ pBuf->string16->fgcol = (SDL_Color){255, 0, 0, 255};
} else {
pBuf->string16->fgcol =
*(get_game_colorRGB(COLOR_STD_RED_DISABLED));
}
break;
case DS_CEASEFIRE:
- pBuf->string16->fgcol = *(get_game_colorRGB(COLOR_STD_YELLOW));
+ pBuf->string16->fgcol = (SDL_Color){255, 255, 0, 255};
set_wstate(pBuf, FC_WS_NORMAL);
break;
case DS_PEACE:
- pBuf->string16->fgcol = *(get_game_colorRGB(COLOR_STD_GROUND));
+ pBuf->string16->fgcol = (SDL_Color){0, 200, 0, 255};
set_wstate(pBuf, FC_WS_NORMAL);
break;
case DS_ALLIANCE:
@@ -749,7 +753,7 @@
n = units_h;
w += n;
- units_h = 20 * pBuf->size.h + WINDOW_TILE_HIGH + 3 + FRAME_WH;
+ units_h = 20 * pBuf->size.h + WINDOW_TILE_HIGH + adj_size(3) + FRAME_WH;
} else {
units_h = h;
@@ -762,11 +766,11 @@
h = units_h;
pWindow->size.x = ((Main.event.motion.x + w < pWindow->dst->w) ?
- (Main.event.motion.x + 10) : (pWindow->dst->w - w - 10));
+ (Main.event.motion.x + adj_size(10)) : (pWindow->dst->w -
w - adj_size(10)));
pWindow->size.y =
- ((Main.event.motion.y - (WINDOW_TILE_HIGH + 2) + h < pWindow->dst->h) ?
- (Main.event.motion.y - (WINDOW_TILE_HIGH + 2)) :
- (pWindow->dst->h - h - 10));
+ ((Main.event.motion.y - (WINDOW_TILE_HIGH + adj_size(2)) + h <
pWindow->dst->h) ?
+ (Main.event.motion.y - (WINDOW_TILE_HIGH + adj_size(2))) :
+ (pWindow->dst->h - h - adj_size(10)));
resize_window(pWindow, NULL, NULL, w, h);
@@ -785,7 +789,7 @@
/* cities */
pBuf = pBuf->prev;
setup_vertical_widgets_position(1,
- pWindow->size.x + FRAME_WH, pWindow->size.y + WINDOW_TILE_HIGH + 2,
+ pWindow->size.x + FRAME_WH, pWindow->size.y + WINDOW_TILE_HIGH +
adj_size(2),
w, 0, pShort_Players_Dlg->pBeginActiveWidgetList, pBuf);
if (pShort_Players_Dlg->pScroll)
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/repodlgs.c
devel/client/gui-sdl/repodlgs.c
--- devel_distclean/client/gui-sdl/repodlgs.c 2005-10-18 21:02:43.000000000
+0200
+++ devel/client/gui-sdl/repodlgs.c 2005-11-15 06:52:45.000000000 +0100
@@ -71,6 +71,7 @@
/* ===================================================================== */
static struct ADVANCED_DLG *pUnitsDlg = NULL;
static struct SMALL_DLG *pUnits_Upg_Dlg = NULL;
+
struct units_entry {
int active_count;
int upkeep_shield;
@@ -91,14 +92,14 @@
entries[time_to_build].soonest_completions = FC_INFINITY;
}
unit_list_iterate(game.player_ptr->units, pUnit) {
- (entries[pUnit->type].active_count)++;
+ (entries[pUnit->type->index].active_count)++;
(total->active_count)++;
if (pUnit->homecity) {
- entries[pUnit->type].upkeep_shield += pUnit->upkeep[O_SHIELD];
+ entries[pUnit->type->index].upkeep_shield += pUnit->upkeep[O_SHIELD];
total->upkeep_shield += pUnit->upkeep[O_SHIELD];
- entries[pUnit->type].upkeep_food += pUnit->upkeep[O_FOOD];
+ entries[pUnit->type->index].upkeep_food += pUnit->upkeep[O_FOOD];
total->upkeep_food += pUnit->upkeep[O_FOOD];
- entries[pUnit->type].upkeep_gold += pUnit->upkeep[O_GOLD];
+ entries[pUnit->type->index].upkeep_gold += pUnit->upkeep[O_GOLD];
total->upkeep_gold += pUnit->upkeep[O_GOLD];
}
} unit_list_iterate_end;
@@ -110,7 +111,7 @@
entries[pCity->production.value].soonest_completions =
MIN(entries[pCity->production.value].soonest_completions,
city_turns_to_build(pCity,
- pCity->production.value, TRUE, TRUE));
+ pCity->production, TRUE));
}
} city_list_iterate_end;
}
@@ -162,7 +163,8 @@
static int popup_upgrade_unit_callback(struct GUI *pWidget)
{
- int ut1, ut2;
+ struct unit_type ut1;
+ struct unit_type *ut2;
int value, hh, ww = 0;
char cBuf[128];
struct GUI *pBuf = NULL, *pWindow;
@@ -170,12 +172,12 @@
SDL_Surface *pText, *pDest = pWidget->dst;
SDL_Rect dst;
- ut1 = MAX_ID - pWidget->ID;
+ ut1.index = MAX_ID - pWidget->ID;
if (pUnits_Upg_Dlg) {
return 1;
}
- CHECK_UNIT_TYPE(ut1);
+ CHECK_UNIT_TYPE(&ut1);
set_wstate(pWidget, FC_WS_NORMAL);
pSellected_Widget = NULL;
@@ -184,21 +186,21 @@
pUnits_Upg_Dlg = MALLOC(sizeof(struct SMALL_DLG));
- ut2 = can_upgrade_unittype(game.player_ptr, ut1);
- value = unit_upgrade_price(game.player_ptr, ut1, ut2);
+ ut2 = can_upgrade_unittype(game.player_ptr, &ut1);
+ value = unit_upgrade_price(game.player_ptr, &ut1, ut2);
my_snprintf(cBuf, sizeof(cBuf),
_("Upgrade as many %s to %s as possible for %d gold each?\n"
"Treasury contains %d gold."),
- unit_types[ut1].name, unit_types[ut2].name,
+ ut1.name, ut2->name,
value, game.player_ptr->economic.gold);
hh = WINDOW_TILE_HIGH + 1;
- pStr = create_str16_from_char(_("Upgrade Obsolete Units"), 12);
+ pStr = create_str16_from_char(_("Upgrade Obsolete Units"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(pDest, pStr, 100, 100, 0);
+ pWindow = create_window(pDest, pStr, adj_size(100), adj_size(100), 0);
pWindow->action = upgrade_unit_window_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -210,7 +212,7 @@
/* ============================================================= */
/* create text label */
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pStr->fgcol.r = 255;
pStr->fgcol.g = 255;
@@ -219,24 +221,24 @@
pText = create_text_surf_from_str16(pStr);
FREESTRING16(pStr);
- hh += (pText->h + 10);
- ww = MAX(ww , pText->w + 20);
+ hh += (pText->h + adj_size(10));
+ ww = MAX(ww , pText->w + adj_size(20));
/* cancel button */
pBuf = create_themeicon_button_from_chars(pTheme->CANCEL_Icon,
- pWindow->dst, _("No"), 12, 0);
+ pWindow->dst, _("No"), adj_font(12), 0);
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
pBuf->action = cancel_upgrade_unit_callback;
set_wstate(pBuf, FC_WS_NORMAL);
- hh += (pBuf->size.h + 20);
+ hh += (pBuf->size.h + adj_size(20));
add_to_gui_list(ID_BUTTON, pBuf);
if (game.player_ptr->economic.gold >= value) {
pBuf = create_themeicon_button_from_chars(pTheme->OK_Icon, pWindow->dst,
- _("Yes"), 12, 0);
+ _("Yes"), adj_font(12), 0);
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
pBuf->action = ok_upgrade_unit_window_callback;
@@ -245,9 +247,9 @@
add_to_gui_list(pWidget->ID, pBuf);
pBuf->size.w = MAX(pBuf->size.w, pBuf->next->size.w);
pBuf->next->size.w = pBuf->size.w;
- ww = MAX(ww, 30 + pBuf->size.w * 2);
+ ww = MAX(ww, adj_size(30) + pBuf->size.w * 2);
} else {
- ww = MAX(ww, pBuf->size.w + 20);
+ ww = MAX(ww, pBuf->size.w + adj_size(20));
}
/* ============================================ */
@@ -265,26 +267,26 @@
/* setup rest of widgets */
/* label */
dst.x = FRAME_WH + (ww - DOUBLE_FRAME_WH - pText->w) / 2;
- dst.y = WINDOW_TILE_HIGH + 11;
+ dst.y = WINDOW_TILE_HIGH + adj_size(11);
SDL_BlitSurface(pText, NULL, pWindow->theme, &dst);
FREESURFACE(pText);
/* cancel button */
pBuf = pWindow->prev;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - 10;
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h -
adj_size(10);
if (game.player_ptr->economic.gold >= value) {
/* sell button */
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + (ww - (2 * pBuf->size.w + 10)) / 2;
+ pBuf->size.x = pWindow->size.x + (ww - (2 * pBuf->size.w + adj_size(10)))
/ 2;
pBuf->size.y = pBuf->next->size.y;
/* cancel button */
- pBuf->next->size.x = pBuf->size.x + pBuf->size.w + 10;
+ pBuf->next->size.x = pBuf->size.x + pBuf->size.w + adj_size(10);
} else {
/* x position of cancel button */
pBuf->size.x = pWindow->size.x +
- pWindow->size.w - FRAME_WH - pBuf->size.w - 10;
+ pWindow->size.w - FRAME_WH - pBuf->size.w -
adj_size(10);
}
@@ -341,7 +343,7 @@
}
my_snprintf(cBuf, sizeof(cBuf), _("active"));
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pText1 = create_text_surf_from_str16(pStr);
@@ -364,10 +366,10 @@
FREESTRING16(pStr);
/* --------------- */
- pStr = create_str16_from_char(_("Units Report"), 12);
+ pStr = create_str16_from_char(_("Units Report"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 40, 30, 0);
+ pWindow = create_window(NULL, pStr, adj_size(40), adj_size(30), 0);
pUnitsDlg->pEndWidgetList = pWindow;
w = MAX(w, pWindow->size.w);
set_wstate(pWindow, FC_WS_NORMAL);
@@ -388,19 +390,19 @@
/* totals */
my_snprintf(cBuf, sizeof(cBuf), "%d", total->active_count);
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
WF_DRAW_THEME_TRANSPARENT);
h += pBuf->size.h;
- pBuf->size.w = pText1->w + 6;
+ pBuf->size.w = pText1->w + adj_size(6);
add_to_gui_list(ID_LABEL, pBuf);
/* ---------------------------------------------- */
my_snprintf(cBuf, sizeof(cBuf), "%d", total->upkeep_shield);
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr, WF_DRAW_THEME_TRANSPARENT);
@@ -410,7 +412,7 @@
/* ---------------------------------------------- */
my_snprintf(cBuf, sizeof(cBuf), "%d", total->upkeep_food);
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr, WF_DRAW_THEME_TRANSPARENT);
@@ -420,7 +422,7 @@
/* ---------------------------------------------- */
my_snprintf(cBuf, sizeof(cBuf), "%d", total->upkeep_gold);
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr, WF_DRAW_THEME_TRANSPARENT);
@@ -430,34 +432,34 @@
/* ---------------------------------------------- */
my_snprintf(cBuf, sizeof(cBuf), "%d", total->building_count);
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
WF_DRAW_THEME_TRANSPARENT);
- pBuf->size.w = pText2->w + 6;
+ pBuf->size.w = pText2->w + adj_size(6);
add_to_gui_list(ID_LABEL, pBuf);
/* ------------------------- */
pLast = pBuf;
count = 0;
unit_type_iterate(i) {
- if ((units[i].active_count > 0) || (units[i].building_count > 0)) {
- upgrade = (can_upgrade_unittype(game.player_ptr, i) != -1);
- pUnit = get_unit_type(i);
+ if ((units[i->index].active_count > 0) || (units[i->index].building_count
> 0)) {
+ upgrade = (can_upgrade_unittype(game.player_ptr, i) != NULL);
+ pUnit = i;
/* ----------- */
- pBuf = create_iconlabel(GET_SURF(pUnit->sprite), pWindow->dst, NULL,
+ pBuf = create_iconlabel(adj_surf(GET_SURF(get_unittype_sprite(tileset,
i))), pWindow->dst, NULL,
WF_DRAW_THEME_TRANSPARENT);
- if(count > 72) {
+ if(count > adj_size(72)) {
set_wflag(pBuf, WF_HIDDEN);
}
hh = pBuf->size.h;
- add_to_gui_list(MAX_ID - i, pBuf);
+ add_to_gui_list(MAX_ID - i->index, pBuf);
/* ----------- */
- pStr = create_str16_from_char(pUnit->name, 12);
+ pStr = create_str16_from_char(pUnit->name, adj_font(12));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
(WF_DRAW_THEME_TRANSPARENT|WF_SELLECT_WITHOUT_BAR));
@@ -469,132 +471,133 @@
pBuf->string16->fgcol = color;
}
pBuf->string16->style &= ~SF_CENTER;
- if(count > 72) {
+ if(count > adj_size(72)) {
set_wflag(pBuf , WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
name_w = MAX(pBuf->size.w, name_w);
- add_to_gui_list(MAX_ID - i, pBuf);
+ add_to_gui_list(MAX_ID - i->index, pBuf);
/* ----------- */
- my_snprintf(cBuf, sizeof(cBuf), "%d", units[i].active_count);
- pStr = create_str16_from_char(cBuf, 10);
+ my_snprintf(cBuf, sizeof(cBuf), "%d", units[i->index].active_count);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
WF_DRAW_THEME_TRANSPARENT);
- if(count > 72) {
+ if(count > adj_size(72)) {
set_wflag(pBuf, WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
- pBuf->size.w = pText1->w + 6;
- add_to_gui_list(MAX_ID - i, pBuf);
+ pBuf->size.w = pText1->w + adj_size(6);
+ add_to_gui_list(MAX_ID - i->index, pBuf);
/* ----------- */
- my_snprintf(cBuf, sizeof(cBuf), "%d", units[i].upkeep_shield);
- pStr = create_str16_from_char(cBuf, 10);
+ my_snprintf(cBuf, sizeof(cBuf), "%d", units[i->index].upkeep_shield);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
WF_DRAW_THEME_TRANSPARENT);
- if(count > 72) {
+ if(count > adj_size(72)) {
set_wflag(pBuf, WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
pBuf->size.w = pText1->w;
- add_to_gui_list(MAX_ID - i, pBuf);
+ add_to_gui_list(MAX_ID - i->index, pBuf);
/* ----------- */
- my_snprintf(cBuf, sizeof(cBuf), "%d", units[i].upkeep_food);
- pStr = create_str16_from_char(cBuf, 10);
+ my_snprintf(cBuf, sizeof(cBuf), "%d", units[i->index].upkeep_food);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
WF_DRAW_THEME_TRANSPARENT);
- if(count > 72) {
+ if(count > adj_size(72)) {
set_wflag(pBuf, WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
pBuf->size.w = pText1->w;
- add_to_gui_list(MAX_ID - i, pBuf);
+ add_to_gui_list(MAX_ID - i->index, pBuf);
/* ----------- */
- my_snprintf(cBuf, sizeof(cBuf), "%d", units[i].upkeep_gold);
- pStr = create_str16_from_char(cBuf, 10);
+ my_snprintf(cBuf, sizeof(cBuf), "%d", units[i->index].upkeep_gold);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
WF_DRAW_THEME_TRANSPARENT);
- if(count > 72) {
+ if(count > adj_size(72)) {
set_wflag(pBuf, WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
pBuf->size.w = pText1->w;
- add_to_gui_list(MAX_ID - i, pBuf);
+ add_to_gui_list(MAX_ID - i->index, pBuf);
/* ----------- */
- if(units[i].building_count > 0) {
- my_snprintf(cBuf, sizeof(cBuf), "%d", units[i].building_count);
+ if(units[i->index].building_count > 0) {
+ my_snprintf(cBuf, sizeof(cBuf), "%d", units[i->index].building_count);
} else {
my_snprintf(cBuf, sizeof(cBuf), "--");
}
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
WF_DRAW_THEME_TRANSPARENT);
- if(count > 72) {
+ if(count > adj_size(72)) {
set_wflag(pBuf, WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
- pBuf->size.w = pText2->w + 6;
- add_to_gui_list(MAX_ID - i, pBuf);
+ pBuf->size.w = pText2->w + adj_size(6);
+ add_to_gui_list(MAX_ID - i->index, pBuf);
/* ----------- */
- if(units[i].building_count > 0) {
- my_snprintf(cBuf, sizeof(cBuf), "%d %s", units[i].soonest_completions,
- PL_("turn", "turns", units[i].soonest_completions));
+ if(units[i->index].building_count > 0) {
+ my_snprintf(cBuf, sizeof(cBuf), "%d %s",
units[i->index].soonest_completions,
+ PL_("turn", "turns",
units[i->index].soonest_completions));
} else {
my_snprintf(cBuf, sizeof(cBuf), "--");
}
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
WF_DRAW_THEME_TRANSPARENT);
- if(count > 72) {
+ if(count > adj_size(72)) {
set_wflag(pBuf, WF_HIDDEN);
}
hh = MAX(hh, pBuf->size.h);
- pBuf->size.w = pText5->w + 6;
- add_to_gui_list(MAX_ID - i, pBuf);
+ pBuf->size.w = pText5->w + adj_size(6);
+ add_to_gui_list(MAX_ID - i->index, pBuf);
- count += 8;
+ count += adj_size(8);
h += (hh/2);
}
} unit_type_iterate_end;
pUnitsDlg->pBeginWidgetList = pBuf;
- w = (tileset_full_tile_width(tileset) * 2 + name_w + 15) +
- (4 * pText1->w + 46) + (pText2->w + 16) + (pText5->w + 6) + 2;
+ w = (tileset_full_tile_width(tileset) * 2 + name_w + adj_size(15)) +
+ (adj_size(4) * pText1->w + adj_size(46)) + (pText2->w +
adj_size(16))
+ + (pText5->w + adj_size(6)) + adj_size(2);
if(count) {
pUnitsDlg->pBeginActiveWidgetList = pBuf;
pUnitsDlg->pEndActiveWidgetList = pLast->prev;
- if(count > 80) {
+ if(count > adj_size(80)) {
pUnitsDlg->pActiveWidgetList = pUnitsDlg->pEndActiveWidgetList;
if(pUnitsDlg->pScroll) {
pUnitsDlg->pScroll->count = count;
}
ww = create_vertical_scrollbar(pUnitsDlg, 8, 10, TRUE, TRUE);
w += ww;
- h = (hh + 9 * (hh/2) + 10) + WINDOW_TILE_HIGH + 1 + FRAME_WH;
+ h = (hh + 9 * (hh/2) + adj_size(10)) + WINDOW_TILE_HIGH + 1 + FRAME_WH;
} else {
h += WINDOW_TILE_HIGH + 1 + FRAME_WH + hh/2;
}
} else {
- h = WINDOW_TILE_HIGH + 1 + FRAME_WH + 50;
+ h = WINDOW_TILE_HIGH + 1 + FRAME_WH + adj_size(50);
}
- h += pText1->h + 10;
- w += DOUBLE_FRAME_WH + 2;
+ h += pText1->h + adj_size(10);
+ w += DOUBLE_FRAME_WH + adj_size(2);
pWindow->size.x = (Main.screen->w - w) / 2;
pWindow->size.y = (Main.screen->h - h) / 2;
@@ -616,154 +619,154 @@
pBuf->size.y = pWindow->size.y + 1;
/* totals background and label */
- dst.x = FRAME_WH + 2;
- dst.y = h - ( pText3->h + 2 ) - 2 - FRAME_WH;
- dst.w = name_w + tileset_full_tile_width(tileset) * 2 + 5;
- dst.h = pText3->h + 2;
+ dst.x = FRAME_WH + adj_size(2);
+ dst.y = h - ( pText3->h + adj_size(2) ) - adj_size(2) - FRAME_WH;
+ dst.w = name_w + tileset_full_tile_width(tileset) * 2 + adj_size(5);
+ dst.h = pText3->h + adj_size(2);
SDL_FillRectAlpha(pWindow->theme, &dst, &color);
putframe(pWindow->theme, dst.x , dst.y,
dst.x + dst.w, dst.y + dst.h - 1, 0xFF000000);
dst.y += 1;
- dst.x += ((name_w + tileset_full_tile_width(tileset) * 2 + 5) - pText3->w) /
2;
+ dst.x += ((name_w + tileset_full_tile_width(tileset) * 2 + adj_size(5)) -
pText3->w) / 2;
SDL_BlitSurface(pText3, NULL, pWindow->theme, &dst);
FREESURFACE(pText3);
/* total active widget */
pBuf = pBuf->prev;
pBuf->size.x = pWindow->size.x + FRAME_WH + name_w +
- tileset_full_tile_width(tileset) * 2 + 17;
+ tileset_full_tile_width(tileset) * 2 + adj_size(17);
pBuf->size.y = pWindow->size.y + dst.y;
/* total shields cost widget */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = pWindow->size.y + dst.y;
/* total food cost widget */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = pWindow->size.y + dst.y;
/* total gold cost widget */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = pWindow->size.y + dst.y;
/* total building count widget */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = pWindow->size.y + dst.y;
/* units background and labels */
- dst.x = FRAME_WH + 2;
- dst.y = WINDOW_TILE_HIGH + 2;
- dst.w = name_w + tileset_full_tile_width(tileset) * 2 + 5;
- dst.h = pText4->h + 2;
+ dst.x = FRAME_WH + adj_size(2);
+ dst.y = WINDOW_TILE_HIGH + adj_size(2);
+ dst.w = name_w + tileset_full_tile_width(tileset) * 2 + adj_size(5);
+ dst.h = pText4->h + adj_size(2);
SDL_FillRectAlpha(pWindow->theme, &dst, &color);
putframe(pWindow->theme, dst.x , dst.y,
dst.x + dst.w, dst.y + dst.h - 1, 0xFF000000);
dst.y += 1;
- dst.x += ((name_w + tileset_full_tile_width(tileset) * 2 + 5)- pText4->w) /
2;
+ dst.x += ((name_w + tileset_full_tile_width(tileset) * 2 + adj_size(5))-
pText4->w) / 2;
SDL_BlitSurface(pText4, NULL, pWindow->theme, &dst);
FREESURFACE(pText4);
/* active count background and label */
- dst.x = FRAME_WH + 2 + name_w + tileset_full_tile_width(tileset) * 2 + 15;
- dst.y = WINDOW_TILE_HIGH + 2;
- dst.w = pText1->w + 6;
- dst.h = h - WINDOW_TILE_HIGH - 2 - FRAME_WH - 2;
+ dst.x = FRAME_WH + 2 + name_w + tileset_full_tile_width(tileset) * 2 +
adj_size(15);
+ dst.y = WINDOW_TILE_HIGH + adj_size(2);
+ dst.w = pText1->w + adj_size(6);
+ dst.h = h - WINDOW_TILE_HIGH - adj_size(2) - FRAME_WH - adj_size(2);
SDL_FillRectAlpha(pWindow->theme, &dst, &color);
putframe(pWindow->theme, dst.x , dst.y,
dst.x + dst.w, dst.y + dst.h - 1, 0xFF000000);
- dst.x += 3;
+ dst.x += adj_size(3);
SDL_BlitSurface(pText1, NULL, pWindow->theme, &dst);
ww = pText1->w;
hh = pText1->h;
FREESURFACE(pText1);
/* shields cost background and label */
- dst.x += (ww + 13);
+ dst.x += (ww + adj_size(13));
w = dst.x;
dst.w = ww;
- dst.h = h - WINDOW_TILE_HIGH - 2 - FRAME_WH - 2;
+ dst.h = h - WINDOW_TILE_HIGH - adj_size(2) - FRAME_WH - adj_size(2);
SDL_FillRectAlpha(pWindow->theme, &dst, &color);
putframe(pWindow->theme, dst.x , dst.y,
dst.x + dst.w, dst.y + dst.h - 1, 0xFF000000);
- dst.y = WINDOW_TILE_HIGH + 4;
+ dst.y = WINDOW_TILE_HIGH + adj_size(4);
dst.x += ((ww - pIcons->pBIG_Shield->w) / 2);
SDL_BlitSurface(pIcons->pBIG_Shield, NULL, pWindow->theme, &dst);
/* food cost background and label */
- dst.x = w + ww + 10;
+ dst.x = w + ww + adj_size(10);
w = dst.x;
- dst.y = WINDOW_TILE_HIGH + 2;
+ dst.y = WINDOW_TILE_HIGH + adj_size(2);
dst.w = ww;
- dst.h = h - WINDOW_TILE_HIGH - 2 - FRAME_WH - 2;
+ dst.h = h - WINDOW_TILE_HIGH - adj_size(2) - FRAME_WH - adj_size(2);
SDL_FillRectAlpha(pWindow->theme, &dst, &color);
putframe(pWindow->theme, dst.x , dst.y,
dst.x + dst.w, dst.y + dst.h - 1, 0xFF000000);
- dst.y = WINDOW_TILE_HIGH + 4;
+ dst.y = WINDOW_TILE_HIGH + adj_size(4);
dst.x += ((ww - pIcons->pBIG_Food->w) / 2);
SDL_BlitSurface(pIcons->pBIG_Food, NULL, pWindow->theme, &dst);
/* gold cost background and label */
- dst.x = w + ww + 10;
+ dst.x = w + ww + adj_size(10);
w = dst.x;
- dst.y = WINDOW_TILE_HIGH + 2;
+ dst.y = WINDOW_TILE_HIGH + adj_size(2);
dst.w = ww;
- dst.h = h - WINDOW_TILE_HIGH - 2 - FRAME_WH - 2;
+ dst.h = h - WINDOW_TILE_HIGH - adj_size(2) - FRAME_WH - adj_size(2);
SDL_FillRectAlpha(pWindow->theme, &dst, &color);
putframe(pWindow->theme, dst.x , dst.y,
dst.x + dst.w, dst.y + dst.h - 1, 0xFF000000);
- dst.y = WINDOW_TILE_HIGH + 4;
+ dst.y = WINDOW_TILE_HIGH + adj_size(4);
dst.x += ((ww - pIcons->pBIG_Coin->w) / 2);
SDL_BlitSurface(pIcons->pBIG_Coin, NULL, pWindow->theme, &dst);
/* building count background and label */
- dst.x = w + ww + 10;
- dst.y = WINDOW_TILE_HIGH + 2;
- dst.w = pText2->w + 6;
- ww = pText2->w + 6;
+ dst.x = w + ww + adj_size(10);
+ dst.y = WINDOW_TILE_HIGH + adj_size(2);
+ dst.w = pText2->w + adj_size(6);
+ ww = pText2->w + adj_size(6);
w = dst.x;
- dst.h = h - WINDOW_TILE_HIGH - 2 - FRAME_WH - 2;
+ dst.h = h - WINDOW_TILE_HIGH - adj_size(2) - FRAME_WH - adj_size(2);
SDL_FillRectAlpha(pWindow->theme, &dst, &color);
putframe(pWindow->theme, dst.x , dst.y,
dst.x + dst.w, dst.y + dst.h - 1, 0xFF000000);
- dst.x += 3;
+ dst.x += adj_size(3);
SDL_BlitSurface(pText2, NULL, pWindow->theme, &dst);
FREESURFACE(pText2);
/* building count background and label */
- dst.x = w + ww + 10;
- dst.y = WINDOW_TILE_HIGH + 2;
- dst.w = pText5->w + 6;
- dst.h = h - WINDOW_TILE_HIGH - 2 - FRAME_WH - 2;
+ dst.x = w + ww + adj_size(10);
+ dst.y = WINDOW_TILE_HIGH + adj_size(2);
+ dst.w = pText5->w + adj_size(6);
+ dst.h = h - WINDOW_TILE_HIGH - adj_size(2) - FRAME_WH - adj_size(2);
SDL_FillRectAlpha(pWindow->theme, &dst, &color);
putframe(pWindow->theme, dst.x , dst.y,
dst.x + dst.w, dst.y + dst.h - 1, 0xFF000000);
- dst.x += 3;
+ dst.x += adj_size(3);
SDL_BlitSurface(pText5, NULL, pWindow->theme, &dst);
FREESURFACE(pText5);
if(count) {
- int start_x = pWindow->size.x + FRAME_WH + 2;
- int start_y = pWindow->size.y + WINDOW_TILE_HIGH + 2 + hh + 2;
+ int start_x = pWindow->size.x + FRAME_WH + adj_size(2);
+ int start_y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(2) + hh +
adj_size(2);
int mod = 0;
pBuf = pBuf->prev;
@@ -776,31 +779,31 @@
pBuf = pBuf->prev;
pBuf->size.w = name_w;
- pBuf->size.x = start_x + tileset_full_tile_width(tileset) * 2 + 5;
+ pBuf->size.x = start_x + tileset_full_tile_width(tileset) * 2 +
adj_size(5);
pBuf->size.y = start_y + (hh - pBuf->size.h) / 2;
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = start_y + (hh - pBuf->size.h) / 2;
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = start_y + (hh - pBuf->size.h) / 2;
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = start_y + (hh - pBuf->size.h) / 2;
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = start_y + (hh - pBuf->size.h) / 2;
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = start_y + (hh - pBuf->size.h) / 2;
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
pBuf->size.y = start_y + (hh - pBuf->size.h) / 2;
start_y += (hh>>1);
@@ -845,11 +848,11 @@
/* find if there are new units entry (if not then rebuild all) */
pWidget = pUnitsDlg->pEndActiveWidgetList;/* icon of first unit */
unit_type_iterate(i) {
- if ((units[i].active_count > 0) || (units[i].building_count > 0)) {
+ if ((units[i->index].active_count > 0) ||
(units[i->index].building_count > 0)) {
is_in_list = FALSE;
pBuf = pWidget;
while(pBuf) {
- if(i == MAX_ID - pBuf->ID) {
+ if(i->index == MAX_ID - pBuf->ID) {
is_in_list = TRUE;
pWidget = pBuf;
break;
@@ -872,9 +875,9 @@
pWidget = pUnitsDlg->pEndActiveWidgetList;
unit_type_iterate(i) {
pBuf = pWidget;
- if ((units[i].active_count > 0) || (units[i].building_count > 0)) {
- if (i == MAX_ID - pBuf->ID) {
-UPD: upgrade = (can_upgrade_unittype(game.player_ptr, i) != -1);
+ if ((units[i->index].active_count > 0) ||
(units[i->index].building_count > 0)) {
+ if (i->index == MAX_ID - pBuf->ID) {
+UPD: upgrade = can_upgrade_unittype(game.player_ptr, i)->index;
pBuf = pBuf->prev;
if(upgrade) {
pBuf->string16->fgcol = sellect;
@@ -882,29 +885,29 @@
set_wstate(pBuf, FC_WS_NORMAL);
}
- my_snprintf(cBuf, sizeof(cBuf), "%d", units[i].active_count);
+ my_snprintf(cBuf, sizeof(cBuf), "%d", units[i->index].active_count);
pBuf = pBuf->prev;
copy_chars_to_string16(pBuf->string16, cBuf);
- my_snprintf(cBuf, sizeof(cBuf), "%d", units[i].upkeep_shield);
+ my_snprintf(cBuf, sizeof(cBuf), "%d", units[i->index].upkeep_shield);
pBuf = pBuf->prev;
copy_chars_to_string16(pBuf->string16, cBuf);
- my_snprintf(cBuf, sizeof(cBuf), "%d", units[i].upkeep_food);
+ my_snprintf(cBuf, sizeof(cBuf), "%d", units[i->index].upkeep_food);
pBuf = pBuf->prev;
copy_chars_to_string16(pBuf->string16, cBuf);
- if(units[i].building_count > 0) {
- my_snprintf(cBuf, sizeof(cBuf), "%d", units[i].building_count);
+ if(units[i->index].building_count > 0) {
+ my_snprintf(cBuf, sizeof(cBuf), "%d",
units[i->index].building_count);
} else {
my_snprintf(cBuf, sizeof(cBuf), "--");
}
pBuf = pBuf->prev;
copy_chars_to_string16(pBuf->string16, cBuf);
- if(units[i].building_count > 0) {
- my_snprintf(cBuf, sizeof(cBuf), "%d %s",
units[i].soonest_completions,
- PL_("turn", "turns", units[i].soonest_completions));
+ if(units[i->index].building_count > 0) {
+ my_snprintf(cBuf, sizeof(cBuf), "%d %s",
units[i->index].soonest_completions,
+ PL_("turn", "turns",
units[i->index].soonest_completions));
} else {
my_snprintf(cBuf, sizeof(cBuf), "--");
}
@@ -916,7 +919,7 @@
pBuf = pWidget->next;
do {
del_widget_from_vertical_scroll_widget_list(pUnitsDlg,
pBuf->prev);
- } while(i != MAX_ID - pBuf->prev->ID &&
+ } while(i->index != MAX_ID - pBuf->prev->ID &&
pBuf->prev != pUnitsDlg->pBeginActiveWidgetList);
if(pBuf->prev == pUnitsDlg->pBeginActiveWidgetList) {
del_widget_from_vertical_scroll_widget_list(pUnitsDlg,
pBuf->prev);
@@ -928,14 +931,14 @@
}
} else {
if(pBuf && pBuf->next != pUnitsDlg->pBeginActiveWidgetList) {
- if (i < MAX_ID - pBuf->ID) {
+ if (i->index < MAX_ID - pBuf->ID) {
continue;
} else {
pBuf = pBuf->next;
do {
del_widget_from_vertical_scroll_widget_list(pUnitsDlg,
pBuf->prev);
- } while(i == MAX_ID - pBuf->prev->ID &&
+ } while(i->index == MAX_ID - pBuf->prev->ID &&
pBuf->prev != pUnitsDlg->pBeginActiveWidgetList);
if(pBuf->prev == pUnitsDlg->pBeginActiveWidgetList) {
del_widget_from_vertical_scroll_widget_list(pUnitsDlg,
@@ -1208,7 +1211,7 @@
pMotion.dst_rate = (int *)pMotion.pHoriz_Dst->data.ptr;
pMotion.tax = 100 - *pMotion.src_rate - *pMotion.dst_rate;
if ((SDL_Client_Flags & CF_CHANGE_TAXRATE_SCI_BLOCK)) {
- if (pMotion.tax <= get_gov_pplayer(game.player_ptr)->max_rate) {
+ if (pMotion.tax <= get_player_bonus(game.player_ptr, EFT_MAX_RATES)) {
pMotion.pHoriz_Dst = NULL; /* tax */
pMotion.dst_rate = &pMotion.tax;
} else {
@@ -1227,7 +1230,7 @@
pMotion.dst_rate = (int *)pMotion.pHoriz_Dst->data.ptr;
pMotion.tax = 100 - *pMotion.src_rate - *pMotion.dst_rate;
if (SDL_Client_Flags & CF_CHANGE_TAXRATE_LUX_BLOCK) {
- if (pMotion.tax <= get_gov_pplayer(game.player_ptr)->max_rate) {
+ if (pMotion.tax <= get_player_bonus(game.player_ptr, EFT_MAX_RATES)) {
/* tax */
pMotion.pHoriz_Dst = NULL;
pMotion.dst_rate = &pMotion.tax;
@@ -1250,7 +1253,7 @@
}
pMotion.min = pHoriz_Src->next->size.x + pHoriz_Src->next->size.w + 2;
- pMotion.gov_max = get_gov_pplayer(game.player_ptr)->max_rate;
+ pMotion.gov_max = get_player_bonus(game.player_ptr, EFT_MAX_RATES);
pMotion.max = pMotion.min + pMotion.gov_max * 1.5;
pMotion.x = pHoriz_Src->size.x;
@@ -1479,10 +1482,10 @@
hh = WINDOW_TILE_HIGH + 1;
- pStr = create_str16_from_char(_("Sell It?"), 12);
+ pStr = create_str16_from_char(_("Sell It?"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(pDest, pStr, 100, 100, 0);
+ pWindow = create_window(pDest, pStr, adj_size(100), adj_size(100), 0);
pWindow->action = sell_impv_window_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -1494,7 +1497,7 @@
/* ============================================================= */
/* create text label */
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pStr->fgcol.r = 255;
pStr->fgcol.g = 255;
@@ -1503,24 +1506,24 @@
pText = create_text_surf_from_str16(pStr);
FREESTRING16(pStr);
- hh += (pText->h + 10);
- ww = MAX(ww , pText->w + 20);
+ hh += (pText->h + adj_size(10));
+ ww = MAX(ww , pText->w + adj_size(20));
/* cancel button */
pBuf = create_themeicon_button_from_chars(pTheme->CANCEL_Icon,
- pWindow->dst, _("No"), 12, 0);
+ pWindow->dst, _("No"), adj_font(12), 0);
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
pBuf->action = cancel_sell_impv_callback;
set_wstate(pBuf, FC_WS_NORMAL);
- hh += (pBuf->size.h + 20);
+ hh += (pBuf->size.h + adj_size(20));
add_to_gui_list(ID_BUTTON, pBuf);
if (count > 0) {
pBuf = create_themeicon_button_from_chars(pTheme->OK_Icon, pWindow->dst,
- "Sell", 12, 0);
+ "Sell", adj_font(12), 0);
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
pBuf->action = ok_sell_impv_callback;
@@ -1530,9 +1533,9 @@
add_to_gui_list(ID_BUTTON, pBuf);
pBuf->size.w = MAX(pBuf->size.w, pBuf->next->size.w);
pBuf->next->size.w = pBuf->size.w;
- ww = MAX(ww, 30 + pBuf->size.w * 2);
+ ww = MAX(ww, adj_size(30) + pBuf->size.w * 2);
} else {
- ww = MAX(ww, pBuf->size.w + 20);
+ ww = MAX(ww, pBuf->size.w + adj_size(20));
}
/* ============================================ */
@@ -1550,26 +1553,26 @@
/* setup rest of widgets */
/* label */
dst.x = FRAME_WH + (ww - DOUBLE_FRAME_WH - pText->w) / 2;
- dst.y = WINDOW_TILE_HIGH + 11;
+ dst.y = WINDOW_TILE_HIGH + adj_size(11);
SDL_BlitSurface(pText, NULL, pWindow->theme, &dst);
FREESURFACE(pText);
/* cancel button */
pBuf = pWindow->prev;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - 10;
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h -
adj_size(10);
if (count > 0) {
/* sell button */
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + (ww - (2 * pBuf->size.w + 10)) / 2;
+ pBuf->size.x = pWindow->size.x + (ww - (2 * pBuf->size.w + adj_size(10)))
/ 2;
pBuf->size.y = pBuf->next->size.y;
/* cancel button */
- pBuf->next->size.x = pBuf->size.x + pBuf->size.w + 10;
+ pBuf->next->size.x = pBuf->size.x + pBuf->size.w + adj_size(10);
} else {
/* x position of cancel button */
pBuf->size.x = pWindow->size.x +
- pWindow->size.w - FRAME_WH - pBuf->size.w - 10;
+ pWindow->size.w - FRAME_WH - pBuf->size.w -
adj_size(10);
}
@@ -1688,10 +1691,10 @@
get_economy_report_data(entries, &entries_used, &total, &tax);
/* --------------- */
- pStr = create_str16_from_char(_("Economy Report"), 12);
+ pStr = create_str16_from_char(_("Economy Report"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 40, 30, 0);
+ pWindow = create_window(NULL, pStr, adj_size(40), adj_size(30), 0);
pEconomyDlg->pEndWidgetList = pWindow;
h = WINDOW_TILE_HIGH + 1 + FRAME_WH;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -1703,7 +1706,7 @@
/* Total Treasury */
my_snprintf(cBuf, sizeof(cBuf), "%d", game.player_ptr->economic.gold);
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pBuf = create_iconlabel(pIcons->pBIG_Coin, pWindow->dst, pStr,
@@ -1716,7 +1719,7 @@
/* Tax Rate */
/* it is important to leave 1 space at ending of this string */
my_snprintf(cBuf, sizeof(cBuf), "%d%% " , game.player_ptr->economic.tax);
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pBuf = create_iconlabel(NULL, pWindow->dst, pStr, WF_DRAW_THEME_TRANSPARENT);
@@ -1727,7 +1730,7 @@
/* Total Icome Label */
my_snprintf(cBuf, sizeof(cBuf), "%d", tax);
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
pBuf = create_iconlabel(NULL, pWindow->dst, pStr, WF_DRAW_THEME_TRANSPARENT);
@@ -1738,7 +1741,7 @@
/* Total Cost Label */
my_snprintf(cBuf, sizeof(cBuf), "%d", total);
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
pBuf = create_iconlabel(NULL, pWindow->dst, pStr, WF_DRAW_THEME_TRANSPARENT);
@@ -1749,7 +1752,7 @@
/* Net Icome */
my_snprintf(cBuf, sizeof(cBuf), "%d", tax - total);
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
if(tax - total < 0) {
@@ -1766,7 +1769,7 @@
/* lux rate */
my_snprintf(cBuf, sizeof(cBuf), _("Lock"));
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pBuf = create_checkbox(pWindow->dst,
@@ -1774,7 +1777,7 @@
(WF_DRAW_THEME_TRANSPARENT|WF_WIDGET_HAS_INFO_LABEL));
set_new_checkbox_theme(pBuf, pTheme->LOCK_Icon, pTheme->UNLOCK_Icon);
- w2 = 10 + pBuf->size.w;
+ w2 = adj_size(10) + pBuf->size.w;
pBuf->string16 = pStr;
pBuf->action = toggle_block_callback;
set_wstate(pBuf, FC_WS_NORMAL);
@@ -1782,13 +1785,13 @@
add_to_gui_list(ID_CHANGE_TAXRATE_DLG_LUX_BLOCK_CHECKBOX, pBuf);
/* ---- */
- pBuf = create_horizontal(pTheme->Horiz, pWindow->dst, 30,
+ pBuf = create_horizontal(pTheme->Horiz, pWindow->dst, adj_size(30),
(WF_FREE_DATA | WF_DRAW_THEME_TRANSPARENT));
pBuf->action = horiz_taxrate_callback;
pBuf->data.ptr = MALLOC(sizeof(int));
*(int *)pBuf->data.ptr = game.player_ptr->economic.luxury;
- w2 += 184;
+ w2 += adj_size(184);
set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(ID_CHANGE_TAXRATE_DLG_LUX_SCROLLBAR, pBuf);
@@ -1796,18 +1799,18 @@
/* it is important to leave 1 space at ending of this string */
my_snprintf(cBuf, sizeof(cBuf), "%d%% ", game.player_ptr->economic.luxury);
- pStr = create_str16_from_char(cBuf, 11);
+ pStr = create_str16_from_char(cBuf, adj_font(11));
pStr->style |= TTF_STYLE_BOLD;
pBuf = create_iconlabel(pIcons->pBIG_Luxury, pWindow->dst, pStr,
WF_DRAW_THEME_TRANSPARENT);
- w2 += (5 + pBuf->size.w + 10);
+ w2 += (adj_size(5) + pBuf->size.w + adj_size(10));
add_to_gui_list(ID_CHANGE_TAXRATE_DLG_LUX_LABEL, pBuf);
/* ------------------------- */
/* science rate */
my_snprintf(cBuf, sizeof(cBuf), _("Lock"));
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= TTF_STYLE_BOLD;
pBuf = create_checkbox(pWindow->dst,
@@ -1823,7 +1826,7 @@
add_to_gui_list(ID_CHANGE_TAXRATE_DLG_SCI_BLOCK_CHECKBOX, pBuf);
/* ---- */
- pBuf = create_horizontal(pTheme->Horiz, pWindow->dst, 30,
+ pBuf = create_horizontal(pTheme->Horiz, pWindow->dst, adj_size(30),
(WF_FREE_DATA | WF_DRAW_THEME_TRANSPARENT));
pBuf->action = horiz_taxrate_callback;
@@ -1837,7 +1840,7 @@
/* it is important to leave 1 space at ending of this string */
my_snprintf(cBuf, sizeof(cBuf), "%d%% ", game.player_ptr->economic.science);
- pStr = create_str16_from_char(cBuf, 11);
+ pStr = create_str16_from_char(cBuf, adj_font(11));
pStr->style |= TTF_STYLE_BOLD;
pBuf = create_iconlabel(pIcons->pBIG_Colb, pWindow->dst, pStr,
@@ -1847,7 +1850,7 @@
/* ---- */
my_snprintf(cBuf, sizeof(cBuf), _("Update"));
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pBuf = create_themeicon_button(pTheme->Small_OK_Icon, pWindow->dst, pStr,
WF_DRAW_THEME_TRANSPARENT);
pBuf->action = apply_taxrates_callback;
@@ -1859,7 +1862,7 @@
/* ---- */
my_snprintf(cBuf, sizeof(cBuf), _("Cancel"));
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pBuf = create_themeicon_button(pTheme->Small_CANCEL_Icon, pWindow->dst, pStr,
WF_DRAW_THEME_TRANSPARENT);
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
@@ -1871,14 +1874,14 @@
pBuf->size.w = MAX(pBuf->size.w , pBuf->next->size.w);
pBuf->next->size.w = pBuf->size.w;
- w2 = MAX(w2 , 10 + 2 * pBuf->size.w + 10 + 10);
- h += 5;
+ w2 = MAX(w2 , adj_size(10) + 2 * pBuf->size.w + adj_size(10) + adj_size(10));
+ h += adj_size(5);
/* ------------------------- */
pLast = pBuf;
if(entries_used) {
/* Create Imprv Background Icon */
- pMain = create_surf(116, 116, SDL_SWSURFACE);
+ pMain = create_surf(adj_size(116), adj_size(116), SDL_SWSURFACE);
pSurf = SDL_DisplayFormatAlpha(pMain);
SDL_FillRect(pSurf, NULL, SDL_MapRGBA(pSurf->format, color.r,
color.g, color.b, color.unused));
@@ -1887,7 +1890,7 @@
pMain = pSurf;
pSurf = NULL;
- pStr = create_string16(NULL, 0, 10);
+ pStr = create_string16(NULL, 0, adj_font(10));
pStr->style |= (SF_CENTER|TTF_STYLE_BOLD);
pStr->render = 3;
pStr->bgcol = color;
@@ -1901,7 +1904,7 @@
copy_chars_to_string16(pStr, cBuf);
pStr->style |= TTF_STYLE_BOLD;
- pText_Name = create_text_surf_smaller_that_w(pStr, pSurf->w - 4);
+ pText_Name = create_text_surf_smaller_that_w(pStr, pSurf->w -
adj_size(4));
SDL_SetAlpha(pText_Name, 0x0, 0x0);
my_snprintf(cBuf, sizeof(cBuf), "%s %d\n%s %d",
@@ -1915,8 +1918,8 @@
/*-----------------*/
- pZoom = ZoomSurface(
- GET_SURF(get_improvement_type(p->type)->sprite), 1.5, 1.5, 1);
+ pZoom = adj_surf(ZoomSurface(
+ GET_SURF(get_building_sprite(tileset, p->type)), 1.5, 1.5, 1));
dst.x = (pSurf->w - pZoom->w)/2;
dst.y = (pSurf->h/2 - pZoom->h)/2;
SDL_BlitSurface(pZoom, NULL, pSurf, &dst);
@@ -1936,7 +1939,8 @@
dst.x += pIcons->pBIG_Coin->w + 1;
}
} else {
- if(p->type == B_PALACE) {
+
+ if(!is_wonder(p->type)) {
copy_chars_to_string16(pStr, _("Nation"));
} else {
copy_chars_to_string16(pStr, _("Wonder"));
@@ -1951,7 +1955,7 @@
FREESURFACE(pZoom);
}
- dst.y += (pIcons->pBIG_Coin->h + 2);
+ dst.y += (pIcons->pBIG_Coin->h + adj_size(2));
dst.x = (pSurf->w - pText->w)/2;
SDL_BlitSurface(pText, NULL, pSurf, &dst);
@@ -1987,24 +1991,24 @@
pEconomyDlg->pActiveWidgetList = pEconomyDlg->pEndActiveWidgetList;
count = create_vertical_scrollbar(pEconomyDlg,
TARGETS_COL, TARGETS_ROW, TRUE, TRUE);
- h += (TARGETS_ROW * pBuf->size.h + 10);
+ h += (TARGETS_ROW * pBuf->size.h + adj_size(10));
} else {
count = 0;
if(entries_used > TARGETS_COL) {
h += pBuf->size.h;
}
- h += (10 + pBuf->size.h);
+ h += (adj_size(10) + pBuf->size.h);
}
count = TARGETS_COL * pBuf->size.w + count + DOUBLE_FRAME_WH;
} else {
pEconomyDlg->pBeginWidgetList = pBuf;
- h += 10;
+ h += adj_size(10);
count = 0;
}
/* tresure */
my_snprintf(cBuf, sizeof(cBuf), _("Treasury: "));
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
pText = create_text_surf_from_str16(pStr);
w3 = pText->w;
@@ -2030,7 +2034,7 @@
pText2 = create_text_surf_from_str16(pStr);
w3 = MAX(w3, pText2->w);
- w = MAX(FRAME_WH + 10 + w3 + w + w2 + FRAME_WH, count);
+ w = MAX(FRAME_WH + adj_size(10) + w3 + w + w2 + FRAME_WH, count);
pWindow->size.x = (Main.screen->w - w) / 2;
pWindow->size.y = (Main.screen->h - h) / 2;
@@ -2046,31 +2050,31 @@
pMain = NULL;
pBuf = pWindow->prev;
- pBuf->size.x = pWindow->size.x + FRAME_WH + 10 + pText->w;
- pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 1 + 5;
+ pBuf->size.x = pWindow->size.x + FRAME_WH + adj_size(10) + pText->w;
+ pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 1 + adj_size(5);
h = pBuf->size.h;
w = pBuf->size.w + pText->w;
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + FRAME_WH + 10 + pText_Name->w;
+ pBuf->size.x = pWindow->size.x + FRAME_WH + adj_size(10) + pText_Name->w;
pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h;
h += pBuf->size.h;
w = MAX(w, pBuf->size.w + pText_Name->w);
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + FRAME_WH + 10 + pSurf->w;
+ pBuf->size.x = pWindow->size.x + FRAME_WH + adj_size(10) + pSurf->w;
pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h;
h += pBuf->size.h;
w = MAX(w, pBuf->size.w + pSurf->w);
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + FRAME_WH + 10 + pZoom->w;
+ pBuf->size.x = pWindow->size.x + FRAME_WH + adj_size(10) + pZoom->w;
pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h;
h += pBuf->size.h;
w = MAX(w, pBuf->size.w + pZoom->w);
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + FRAME_WH + 10 + pText2->w;
+ pBuf->size.x = pWindow->size.x + FRAME_WH + adj_size(10) + pText2->w;
pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h;
h += pBuf->size.h;
w = MAX(w, pBuf->size.w + pText2->w);
@@ -2079,7 +2083,7 @@
dst.x = FRAME_WH;
dst.y = WINDOW_TILE_HIGH + 1;
dst.w = pWindow->size.w - DOUBLE_FRAME_WH;
- dst.h = h + 15;
+ dst.h = h + adj_size(15);
h = dst.y + dst.h;
color.unused = 136;
@@ -2089,8 +2093,8 @@
dst.x + dst.w - 1, dst.y + dst.h - 1, 0xFF000000);
/* draw statical strings */
- dst.x = FRAME_WH + 10;
- dst.y = WINDOW_TILE_HIGH + 1 + 5;
+ dst.x = FRAME_WH + adj_size(10);
+ dst.y = WINDOW_TILE_HIGH + adj_size(1 + 5);
SDL_BlitSurface(pText, NULL, pWindow->theme, &dst);
dst.y += pText->h;
FREESURFACE(pText);
@@ -2113,22 +2117,22 @@
/* gov and taxrate */
my_snprintf(cBuf, sizeof(cBuf), _("%s max rate : %d%%"),
- pGov->name, pGov->max_rate);
+ pGov->name,
get_player_bonus(game.player_ptr, EFT_MAX_RATES));
copy_chars_to_string16(pStr, cBuf);
pMain = create_text_surf_from_str16(pStr);
FREESTRING16(pStr);
- dst.y = WINDOW_TILE_HIGH + 1 + 5;
- dst.x = FRAME_WH + 10 + w +
- (pWindow->size.w - (w + DOUBLE_FRAME_WH + 10) - pMain->w) / 2;
+ dst.y = WINDOW_TILE_HIGH + adj_size(1 + 5);
+ dst.x = FRAME_WH + adj_size(10) + w +
+ (pWindow->size.w - (w + DOUBLE_FRAME_WH + adj_size(10)) - pMain->w) / 2;
SDL_BlitSurface(pMain, NULL, pWindow->theme, &dst);
dst.y += (pMain->h + 1);
FREESURFACE(pMain);
/* Luxuries Horizontal Scrollbar Background */
- dst.x = FRAME_WH + 10 + w +
- (pWindow->size.w - (w + DOUBLE_FRAME_WH + 10) - 184) / 2;
- dst.w = 184;
+ dst.x = FRAME_WH + adj_size(10) + w +
+ (pWindow->size.w - (w + DOUBLE_FRAME_WH + adj_size(10)) -
adj_size(184)) / 2;
+ dst.w = adj_size(184);
dst.h = pTheme->Horiz->h - 2;
color.unused = 64;
@@ -2140,17 +2144,17 @@
/* lock icon */
pBuf = pBuf->prev;
pBuf->size.x = pWindow->size.x + dst.x - pBuf->size.w;
- pBuf->size.y = pWindow->size.y + dst.y - 2;
+ pBuf->size.y = pWindow->size.y + dst.y - adj_size(2);
/* lux scrollbar */
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + dst.x + 2
+ pBuf->size.x = pWindow->size.x + dst.x + adj_size(2)
+ (game.player_ptr->economic.luxury * 3) / 2;
pBuf->size.y = pWindow->size.y + dst.y -1;
/* lux rate */
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + dst.x + dst.w + 5;
+ pBuf->size.x = pWindow->size.x + dst.x + dst.w + adj_size(5);
pBuf->size.y = pWindow->size.y + dst.y + 1;
@@ -2164,30 +2168,30 @@
/* science lock icon */
pBuf = pBuf->prev;
pBuf->size.x = pWindow->size.x + dst.x - pBuf->size.w;
- pBuf->size.y = pWindow->size.y + dst.y - 2;
+ pBuf->size.y = pWindow->size.y + dst.y - adj_size(2);
/* science scrollbar */
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + dst.x + 2
+ pBuf->size.x = pWindow->size.x + dst.x + adj_size(2)
+ (game.player_ptr->economic.science * 3) / 2;
pBuf->size.y = pWindow->size.y + dst.y -1;
/* science rate */
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + dst.x + dst.w + 5;
+ pBuf->size.x = pWindow->size.x + dst.x + dst.w + adj_size(5);
pBuf->size.y = pWindow->size.y + dst.y + 1;
/* update */
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + FRAME_WH + 10 + w +
- (pWindow->size.w - (w + DOUBLE_FRAME_WH + 10)
- - (2 * pBuf->size.w + 10)) / 2;
- pBuf->size.y = pWindow->size.y + dst.y + dst.h + 3;
+ pBuf->size.x = pWindow->size.x + FRAME_WH + adj_size(10) + w +
+ (pWindow->size.w - (w + DOUBLE_FRAME_WH + adj_size(10))
+ - (2 * pBuf->size.w + adj_size(10))) /
2;
+ pBuf->size.y = pWindow->size.y + dst.y + dst.h + adj_size(3);
/* cancel */
pBuf = pBuf->prev;
- pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + 10;
- pBuf->size.y = pWindow->size.y + dst.y + dst.h + 3;
+ pBuf->size.x = pBuf->next->size.x + pBuf->next->size.w + adj_size(10);
+ pBuf->size.y = pWindow->size.y + dst.y + dst.h + adj_size(3);
/* ------------------------------- */
if(entries_used) {
@@ -2208,7 +2212,6 @@
redraw_group(pEconomyDlg->pBeginWidgetList, pWindow, 0);
sdl_dirty_rect(pWindow->size);
flush_dirty();
-
}
/* ===================================================================== */
@@ -2221,31 +2224,35 @@
void setup_auxiliary_tech_icons(void)
{
SDL_Surface *pSurf;
- SDL_String16 *pStr = create_str16_from_char(_("None"), 10);
+ SDL_String16 *pStr = create_str16_from_char(_("None"), adj_font(10));
- /* create "None" icon */
- pNone_Tech_Icon = create_surf(50, 50, SDL_SWSURFACE);
+ pStr->style |= (TTF_STYLE_BOLD | SF_CENTER);
+
+ /* create icons */
+ pNone_Tech_Icon = create_surf(adj_size(50), adj_size(50), SDL_SWSURFACE);
SDL_FillRect(pNone_Tech_Icon, NULL,
SDL_MapRGB(pNone_Tech_Icon->format, 255 , 255 , 255));
putframe(pNone_Tech_Icon, 0 , 0,
pNone_Tech_Icon->w - 1, pNone_Tech_Icon->h - 1 , 0x0);
- pFuture_Tech_Icon = SDL_DisplayFormat(pNone_Tech_Icon);
- pStr->style |= (TTF_STYLE_BOLD | SF_CENTER);
+ pFuture_Tech_Icon = SDL_DisplayFormat(pNone_Tech_Icon);
+ /* None */
pSurf = create_text_surf_from_str16(pStr);
blit_entire_src(pSurf, pNone_Tech_Icon ,
- (50 - pSurf->w) / 2 , (50 - pSurf->h) / 2);
+ (adj_size(50) - pSurf->w) / 2 , (adj_size(50) - pSurf->h) / 2);
FREESURFACE(pSurf);
+
+ /* FT */
copy_chars_to_string16(pStr, _("FT"));
pSurf = create_text_surf_from_str16(pStr);
blit_entire_src(pSurf, pFuture_Tech_Icon,
- (50 - pSurf->w) / 2 , (50 - pSurf->h) / 2);
-
+ (adj_size(50) - pSurf->w) / 2 , (adj_size(50) - pSurf->h) / 2);
FREESURFACE(pSurf);
+
FREESTRING16(pStr);
}
@@ -2268,7 +2275,7 @@
case A_FUTURE:
return pFuture_Tech_Icon;
default:
- return GET_SURF(advances[tech].sprite);
+ return adj_surf(GET_SURF(get_tech_sprite(tileset, tech)));
}
return NULL;
}
@@ -2280,16 +2287,16 @@
switch (get_invention(game.player_ptr, tech_id))
{
case TECH_UNKNOWN:
- return get_game_colorRGB(COLOR_STD_WHITE);
+ return get_game_colorRGB(COLOR_REQTREE_UNREACHABLE);
case TECH_KNOWN:
- return get_game_colorRGB(COLOR_STD_GROUND);
+ return get_game_colorRGB(COLOR_REQTREE_KNOWN);
case TECH_REACHABLE:
- return get_game_colorRGB(COLOR_STD_YELLOW);
+ return get_game_colorRGB(COLOR_REQTREE_REACHABLE);
default:
- return get_game_colorRGB(COLOR_STD_RED);
+ return get_game_colorRGB(COLOR_REQTREE_BACKGROUND);
}
}
- return get_game_colorRGB(COLOR_STD_RED);
+ return get_game_colorRGB(COLOR_REQTREE_UNREACHABLE);
}
SDL_Surface * create_sellect_tech_icon(SDL_String16 *pStr, Tech_type_id
tech_id, enum tech_info_mode mode)
@@ -2310,7 +2317,7 @@
w = 135;
break;
case MED_MODE:
- color = *get_game_colorRGB(COLOR_STD_WHITE);
+ color = (SDL_Color){255, 255, 255, 255};
default:
h = 200;
w = 100;
@@ -2323,7 +2330,7 @@
pSurf = SDL_DisplayFormatAlpha(pTmp);
FREESURFACE(pTmp);
- if (game.player_ptr->research.researching == tech_id)
+ if (get_player_research(game.player_ptr)->researching == tech_id)
{
color.unused = 180;
} else {
@@ -2369,9 +2376,12 @@
w = 0;
impr_type_iterate(imp) {
pImpr = get_improvement_type(imp);
- if (pImpr->tech_req == tech_id) {
- Surf_Array[w++] = GET_SURF(pImpr->sprite);
+
+ requirement_vector_iterate(&pImpr->reqs, preq) {
+ if (preq->source.value.tech == tech_id) {
+ Surf_Array[w++] = GET_SURF(get_building_sprite(tileset, imp));
}
+ } requirement_vector_iterate_end;
} impr_type_iterate_end;
if (w) {
@@ -2405,9 +2415,9 @@
/* -------------------------------------------------------- */
w = 0;
unit_type_iterate(un) {
- pUnit = get_unit_type(un);
+ pUnit = un;
if (pUnit->tech_requirement == tech_id) {
- Surf_Array[w++] = GET_SURF(pUnit->sprite);
+ Surf_Array[w++] = GET_SURF(get_unittype_sprite(tileset, un));
}
} unit_type_iterate_end;
@@ -2490,7 +2500,7 @@
char cBuf[128];
SDL_String16 *pStr;
SDL_Surface *pSurf, *pColb_Surface = pIcons->pBIG_Colb;
- int step, i, cost = total_bulbs_required(game.player_ptr);
+ int step, i, cost;
SDL_Rect dest, src;
SDL_Color color;
struct impr_type *pImpr;
@@ -2499,10 +2509,16 @@
int curent_output = 0;
struct GUI *pWindow = pScienceDlg->pEndWidgetList;
- color = *get_game_colorRGB(COLOR_STD_WHITE);
+ color = (SDL_Color){255, 255, 255, 255};
+
+ if (get_player_research(game.player_ptr)->researching != A_UNSET) {
+ cost = total_bulbs_required(game.player_ptr);
+ } else {
+ cost = 0;
+ }
- pWindow->prev->theme =
get_tech_icon(game.player_ptr->research.researching);
- pWindow->prev->prev->theme =
get_tech_icon(game.player_ptr->research->tech_goal);
+ pWindow->prev->theme =
get_tech_icon(get_player_research(game.player_ptr)->researching);
+ pWindow->prev->prev->theme =
get_tech_icon(get_player_research(game.player_ptr)->tech_goal);
/* redraw Window */
redraw_group(pWindow, pWindow, 0);
@@ -2526,7 +2542,7 @@
char cBiernikujemy[64];
turns_to_advance = (cost + curent_output - 1) / curent_output;
turns_to_next_tech =
- (cost - game.player_ptr->research.bulbs_researched +
+ (cost - get_player_research(game.player_ptr)->bulbs_researched +
curent_output - 1) / curent_output;
my_snprintf(cBiernikujemy, sizeof(cBiernikujemy),
@@ -2540,37 +2556,37 @@
PL_("turn", "turns", turns_to_advance), cBiernikujemy);
}
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pStr->style |= SF_CENTER;
pStr->fgcol = color;
pSurf = create_text_surf_from_str16(pStr);
dest.x = pWindow->size.x + (pWindow->size.w - pSurf->w) / 2;
- dest.y = pWindow->size.y + WINDOW_TILE_HIGH + 2;
+ dest.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(2);
SDL_BlitSurface(pSurf, NULL, pWindow->dst, &dest);
- dest.y += pSurf->h + 2;
+ dest.y += pSurf->h + adj_size(2);
FREESURFACE(pSurf);
/* ------------------------------------- */
dest.x = pWindow->prev->size.x;
/* separator */
- putline(pWindow->dst, dest.x, dest.y, dest.x + 365, dest.y, 0xff000000);
+ putline(pWindow->dst, dest.x, dest.y, dest.x + adj_size(365), dest.y,
0xff000000);
dest.y += 6;
/* ------------------------------------- */
my_snprintf(cBuf, sizeof(cBuf), "%s (%d/%d)",
get_tech_name(game.player_ptr,
- game.player_ptr->research.researching),
- game.player_ptr->research.bulbs_researched, cost);
+ get_player_research(game.player_ptr)->researching),
+ get_player_research(game.player_ptr)->bulbs_researched, cost);
copy_chars_to_string16(pStr, cBuf);
pSurf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->prev->size.x + pWindow->prev->size.w + 10;
+ dest.x = pWindow->prev->size.x + pWindow->prev->size.w + adj_size(10);
SDL_BlitSurface(pSurf, NULL, pWindow->dst, &dest);
dest.y += pSurf->h;
@@ -2578,9 +2594,9 @@
dest.w = cost * pColb_Surface->w;
step = pColb_Surface->w;
- if (dest.w > 300) {
- dest.w = 300;
- step = (300 - pColb_Surface->w) / (cost - 1);
+ if (dest.w > adj_size(300)) {
+ dest.w = adj_size(300);
+ step = (adj_size(300) - pColb_Surface->w) / (cost - 1);
if (step == 0) {
step = 1;
@@ -2588,25 +2604,25 @@
}
- dest.h = pColb_Surface->h + 4;
+ dest.h = pColb_Surface->h + adj_size(4);
color.unused = 136;
SDL_FillRectAlpha(pWindow->dst, &dest, &color);
putframe(pWindow->dst, dest.x - 1, dest.y - 1, dest.x + dest.w,
dest.y + dest.h, 0xff000000);
- if (cost > 286)
+ if (cost > adj_size(286))
{
cost =
- 286.0 * ((float) game.player_ptr->research.bulbs_researched / cost);
+ adj_size(286) * ((float)
get_player_research(game.player_ptr)->bulbs_researched / cost);
}
else
{
cost =
- (float)cost * ((float)game.player_ptr->research.bulbs_researched/cost);
+ (float)cost *
((float)get_player_research(game.player_ptr)->bulbs_researched/cost);
}
- dest.y += 2;
+ dest.y += adj_size(2);
for (i = 0; i < cost; i++) {
SDL_BlitSurface(pColb_Surface, NULL, pWindow->dst, &dest);
dest.x += step;
@@ -2614,34 +2630,37 @@
/* ----------------------- */
- dest.y += dest.h + 4;
- dest.x = pWindow->prev->size.x + pWindow->prev->size.w + 10;
+ dest.y += dest.h + adj_size(4);
+ dest.x = pWindow->prev->size.x + pWindow->prev->size.w + adj_size(10);
impr_type_iterate(imp) {
pImpr = get_improvement_type(imp);
- if (pImpr->tech_req == game.player_ptr->research.researching) {
- SDL_BlitSurface(GET_SURF(pImpr->sprite), NULL, pWindow->dst, &dest);
- dest.x += GET_SURF(pImpr->sprite)->w + 1;
+
+ requirement_vector_iterate(&pImpr->reqs, preq) {
+ if (preq->source.value.tech ==
get_player_research(game.player_ptr)->researching) {
+ SDL_BlitSurface(adj_surf(GET_SURF(get_building_sprite(tileset,
imp))), NULL, pWindow->dst, &dest);
+ dest.x += GET_SURF(get_building_sprite(tileset, imp))->w + 1;
}
+ } requirement_vector_iterate_end;
} impr_type_iterate_end;
- dest.x += 5;
+ dest.x += adj_size(5);
unit_type_iterate(un) {
- pUnit = get_unit_type(un);
- if (pUnit->tech_requirement == game.player_ptr->research.researching) {
- if (GET_SURF(pUnit->sprite)->w > 64) {
- float zoom = 64.0 / GET_SURF(pUnit->sprite)->w;
+ pUnit = un;
+ if (pUnit->tech_requirement ==
get_player_research(game.player_ptr)->researching) {
+ if (GET_SURF(get_unittype_sprite(tileset, un))->w > 64) {
+ float zoom = 64.0 / GET_SURF(get_unittype_sprite(tileset, un))->w;
SDL_Surface *pZoomed =
- ZoomSurface(GET_SURF(pUnit->sprite), zoom, zoom, 1);
+ ZoomSurface(GET_SURF(get_unittype_sprite(tileset, un)), zoom,
zoom, 1);
src = get_smaller_surface_rect(pZoomed);
SDL_BlitSurface(pZoomed, &src, pWindow->dst, &dest);
FREESURFACE(pZoomed);
- dest.x += src.w + 2;
+ dest.x += src.w + adj_size(2);
} else {
- src = get_smaller_surface_rect(GET_SURF(pUnit->sprite));
- SDL_BlitSurface(GET_SURF(pUnit->sprite), &src, pWindow->dst, &dest);
- dest.x += src.w + 2;
+ src = get_smaller_surface_rect(GET_SURF(get_unittype_sprite(tileset,
un)));
+ SDL_BlitSurface(GET_SURF(get_unittype_sprite(tileset, un)), &src,
pWindow->dst, &dest);
+ dest.x += src.w + adj_size(2);
}
}
} unit_type_iterate_end;
@@ -2649,57 +2668,59 @@
/* -------------------------------- */
/* draw separator line */
dest.x = pWindow->prev->size.x;
- dest.y = pWindow->prev->size.y + pWindow->prev->size.h + 35;
+ dest.y = pWindow->prev->size.y + pWindow->prev->size.h + adj_size(35);
- putline(pWindow->dst, dest.x, dest.y, dest.x + 365, dest.y, 0xff000000);
- dest.y += 10;
+ putline(pWindow->dst, dest.x, dest.y, dest.x + adj_size(365), dest.y,
0xff000000);
+ dest.y += adj_size(10);
/* -------------------------------- */
/* Goals */
- if (game.player_ptr->research->tech_goal != A_UNSET)
+ if (get_player_research(game.player_ptr)->tech_goal != A_UNSET)
{
steps =
num_unknown_techs_for_goal(game.player_ptr,
- game.player_ptr->research->tech_goal);
+
get_player_research(game.player_ptr)->tech_goal);
my_snprintf(cBuf, sizeof(cBuf), "%s ( %d %s )",
get_tech_name(game.player_ptr,
- game.player_ptr->research->tech_goal), steps,
+ get_player_research(game.player_ptr)->tech_goal),
steps,
PL_("step", "steps", steps));
copy_chars_to_string16(pStr, cBuf);
pSurf = create_text_surf_from_str16(pStr);
- dest.x = pWindow->prev->size.x + pWindow->prev->size.w + 10;
+ dest.x = pWindow->prev->size.x + pWindow->prev->size.w + adj_size(10);
SDL_BlitSurface(pSurf, NULL, pWindow->dst, &dest);
- dest.y += pSurf->h + 4;
+ dest.y += pSurf->h + adj_size(4);
FREESURFACE(pSurf);
impr_type_iterate(imp) {
pImpr = get_improvement_type(imp);
- if (pImpr->tech_req == game.player_ptr->research->tech_goal) {
- SDL_BlitSurface(GET_SURF(pImpr->sprite), NULL, pWindow->dst, &dest);
- dest.x += GET_SURF(pImpr->sprite)->w + 1;
+ requirement_vector_iterate(&pImpr->reqs, preq) {
+ if (preq->source.value.tech ==
get_player_research(game.player_ptr)->tech_goal) {
+ SDL_BlitSurface(GET_SURF(get_building_sprite(tileset, imp)), NULL,
pWindow->dst, &dest);
+ dest.x += GET_SURF(get_building_sprite(tileset, imp))->w + 1;
}
+ } requirement_vector_iterate_end;
} impr_type_iterate_end;
dest.x += 5;
unit_type_iterate(un) {
- pUnit = get_unit_type(un);
- if (pUnit->tech_requirement == game.player_ptr->research->tech_goal) {
- if (GET_SURF(pUnit->sprite)->w > 64) {
- float zoom = 64.0 / GET_SURF(pUnit->sprite)->w;
+ pUnit = un;
+ if (pUnit->tech_requirement ==
get_player_research(game.player_ptr)->tech_goal) {
+ if (GET_SURF(get_unittype_sprite(tileset, un))->w > 64) {
+ float zoom = 64.0 / GET_SURF(get_unittype_sprite(tileset, un))->w;
SDL_Surface *pZoomed =
- ZoomSurface(GET_SURF(pUnit->sprite), zoom, zoom, 1);
+ ZoomSurface(GET_SURF(get_unittype_sprite(tileset, un)), zoom,
zoom, 1);
src = get_smaller_surface_rect(pZoomed);
SDL_BlitSurface(pZoomed, &src, pWindow->dst, &dest);
FREESURFACE(pZoomed);
- dest.x += src.w + 2;
+ dest.x += src.w + adj_size(2);
} else {
- src = get_smaller_surface_rect(GET_SURF(pUnit->sprite));
- SDL_BlitSurface(GET_SURF(pUnit->sprite), &src, pWindow->dst,
&dest);
- dest.x += src.w + 2;
+ src =
get_smaller_surface_rect(GET_SURF(get_unittype_sprite(tileset, un)));
+ SDL_BlitSurface(GET_SURF(get_unittype_sprite(tileset, un)), &src,
pWindow->dst, &dest);
+ dest.x += src.w + adj_size(2);
}
}
} unit_type_iterate_end;
@@ -2790,7 +2811,7 @@
redraw_icon2(pWidget);
flush_rect(pWidget->size);
- if (is_future_tech(game.player_ptr->research.researching)) {
+ if (is_future_tech(get_player_research(game.player_ptr)->researching)) {
return -1;
}
@@ -2808,10 +2829,10 @@
pChangeTechDlg = MALLOC(sizeof(struct ADVANCED_DLG));
- pStr = create_str16_from_char(_("What should we focus on now?"), 12);
+ pStr = create_str16_from_char(_("What should we focus on now?"),
adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 40, 30, 0);
+ pWindow = create_window(NULL, pStr, adj_size(40), adj_size(30), 0);
pChangeTechDlg->pEndWidgetList = pWindow;
w = MAX(w, pWindow->size.w);
set_wstate(pWindow, FC_WS_NORMAL);
@@ -2822,7 +2843,7 @@
/* exit button */
pBuf = create_themeicon(pTheme->Small_CANCEL_Icon, pWindow->dst,
WF_DRAW_THEME_TRANSPARENT);
- w += pBuf->size.w + 10;
+ w += pBuf->size.w + adj_size(10);
pBuf->action = exit_change_tech_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
@@ -2854,7 +2875,7 @@
}
}
- pStr = create_string16(NULL, 0, 10);
+ pStr = create_string16(NULL, 0, adj_font(10));
pStr->style |= (TTF_STYLE_BOLD | SF_CENTER);
count = 0;
@@ -2901,8 +2922,8 @@
count = 1;
}
- w = MAX(w, (col * pBuf->size.w + 2 + DOUBLE_FRAME_WH + i));
- h = WINDOW_TILE_HIGH + 1 + count * pBuf->size.h + 2 + FRAME_WH;
+ w = MAX(w, (col * pBuf->size.w + adj_size(2) + DOUBLE_FRAME_WH + i));
+ h = WINDOW_TILE_HIGH + 1 + count * pBuf->size.h + adj_size(2) + FRAME_WH;
pWindow->size.x = (Main.screen->w - w) / 2;
pWindow->size.y = (Main.screen->h - h) / 2;
disable_science_dialog();
@@ -2981,7 +3002,7 @@
&& get_invention(game.player_ptr, i) != TECH_KNOWN
&& advances[i].req[0] != A_LAST && advances[i].req[1] != A_LAST
&& (num_unknown_techs_for_goal(game.player_ptr, i) < 11
- || i == game.player_ptr->research->tech_goal)) {
+ || i == get_player_research(game.player_ptr)->tech_goal)) {
count++;
}
}
@@ -2992,10 +3013,10 @@
pChangeTechDlg = MALLOC(sizeof(struct ADVANCED_DLG));
- pStr = create_str16_from_char(_("Sellect target :"), 12);
+ pStr = create_str16_from_char(_("Sellect target :"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 40, 30, 0);
+ pWindow = create_window(NULL, pStr, adj_size(40), adj_size(30), 0);
pChangeTechDlg->pEndWidgetList = pWindow;
w = MAX(w, pWindow->size.w);
set_wstate(pWindow, FC_WS_NORMAL);
@@ -3006,7 +3027,7 @@
/* exit button */
pBuf = create_themeicon(pTheme->Small_CANCEL_Icon, pWindow->dst,
WF_DRAW_THEME_TRANSPARENT);
- w += pBuf->size.w + 10;
+ w += pBuf->size.w + adj_size(10);
pBuf->action = exit_change_tech_dlg_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
@@ -3038,7 +3059,7 @@
}
}
- pStr = create_string16(NULL, 0, 10);
+ pStr = create_string16(NULL, 0, adj_font(10));
pStr->style |= (TTF_STYLE_BOLD | SF_CENTER);
/* collect all techs which are reachable in under 11 steps
@@ -3051,7 +3072,7 @@
&& get_invention(game.player_ptr, i) != TECH_KNOWN
&& advances[i].req[0] != A_LAST && advances[i].req[1] != A_LAST
&& ((num = num_unknown_techs_for_goal(game.player_ptr, i)) < 11
- || i == game.player_ptr->research->tech_goal)) {
+ || i == get_player_research(game.player_ptr)->tech_goal)) {
count++;
my_snprintf(cBuf, sizeof(cBuf), "%s\n%d %s", advances[i].name, num,
@@ -3091,8 +3112,8 @@
count = 1;
}
- w = MAX(w, (col * pBuf->size.w + 2 + DOUBLE_FRAME_WH + i));
- h = WINDOW_TILE_HIGH + 1 + count * pBuf->size.h + 2 + FRAME_WH;
+ w = MAX(w, (col * pBuf->size.w + adj_size(2) + DOUBLE_FRAME_WH + i));
+ h = WINDOW_TILE_HIGH + 1 + count * pBuf->size.h + adj_size(2) + FRAME_WH;
pWindow->size.x = (Main.screen->w - w) / 2;
pWindow->size.y = (Main.screen->h - h) / 2;
disable_science_dialog();
@@ -3144,7 +3165,7 @@
/**************************************************************************
Popup (or raise) the science report(F6). It may or may not be modal.
**************************************************************************/
-void popup_science_dialog(bool make_modal)
+void popup_science_dialog(bool raise)
{
struct GUI *pBuf = get_research_widget(), *pWindow = NULL;
SDL_String16 *pStr;
@@ -3161,18 +3182,18 @@
pScienceDlg = MALLOC(sizeof(struct SMALL_DLG));
- pStr = create_str16_from_char(_("Science"), 12);
+ pStr = create_str16_from_char(_("Science"), adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 400, 260, 0);
+ pWindow = create_window(NULL, pStr, adj_size(400), adj_size(260), 0);
pScienceDlg->pEndWidgetList = pWindow;
clear_wflag(pWindow, WF_DRAW_FRAME_AROUND_WIDGET);
pWindow->action = science_dialog_callback;
- pWindow->size.x = (Main.screen->w - 400) / 2;
- pWindow->size.y = (Main.screen->h - 260) / 2;
- pWindow->size.w = 400;
- pWindow->size.h = 260;
+ pWindow->size.x = (Main.screen->w - adj_size(400)) / 2;
+ pWindow->size.y = (Main.screen->h - adj_size(260)) / 2;
+ pWindow->size.w = adj_size(400);
+ pWindow->size.h = adj_size(260);
set_wstate(pWindow, FC_WS_NORMAL);
pLogo = get_logo_gfx();
@@ -3193,12 +3214,18 @@
}
}
- if(game.player_ptr->research.researching != A_FUTURE) {
- pLogo = GET_SURF(advances[game.player_ptr->research.researching].sprite);
+ if (get_player_research(game.player_ptr)->researching != A_UNSET)
+ {
+ if(get_player_research(game.player_ptr)->researching != A_FUTURE) {
+ pLogo = adj_surf(GET_SURF(get_tech_sprite(tileset,
get_player_research(game.player_ptr)->researching)));
} else {
/* "Future Tech" icon */
pLogo = pFuture_Tech_Icon;
}
+ } else {
+ /* "None" icon */
+ pLogo = pNone_Tech_Icon;
+ }
pBuf = create_icon2(pLogo, pWindow->dst, WF_DRAW_THEME_TRANSPARENT);
@@ -3207,15 +3234,15 @@
set_wstate(pBuf, FC_WS_NORMAL);
}
- pBuf->size.x = pWindow->size.x + 16;
- pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 60;
+ pBuf->size.x = pWindow->size.x + adj_size(16);
+ pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + adj_size(60);
add_to_gui_list(ID_SCIENCE_DLG_CHANGE_REASARCH_BUTTON, pBuf);
/* ------ */
- if (game.player_ptr->research->tech_goal != A_UNSET)
+ if (get_player_research(game.player_ptr)->tech_goal != A_UNSET)
{
- pLogo = GET_SURF(advances[game.player_ptr->research->tech_goal].sprite);
+ pLogo = adj_surf(GET_SURF(get_tech_sprite(tileset,
get_player_research(game.player_ptr)->tech_goal)));
} else {
/* "None" icon */
pLogo = pNone_Tech_Icon;
@@ -3227,9 +3254,9 @@
set_wstate(pBuf, FC_WS_NORMAL);
}
- pBuf->size.x = pWindow->size.x + 16;
+ pBuf->size.x = pWindow->size.x + adj_size(16);
pBuf->size.y =
- pWindow->size.y + WINDOW_TILE_HIGH + 60 + pBuf->size.h + 45;
+ pWindow->size.y + WINDOW_TILE_HIGH + adj_size(60) + pBuf->size.h +
adj_size(45);
add_to_gui_list(ID_SCIENCE_DLG_CHANGE_GOAL_BUTTON, pBuf);
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/SDL_ttf.c
devel/client/gui-sdl/SDL_ttf.c
--- devel_distclean/client/gui-sdl/SDL_ttf.c 2005-10-14 20:23:41.000000000
+0200
+++ devel/client/gui-sdl/SDL_ttf.c 2005-11-15 06:52:45.000000000 +0100
@@ -22,6 +22,10 @@
/* $Id: SDL_ttf.c 7167 2004-01-05 17:55:18Z jdorje $ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
diff -u -r -b -B -X devel/diff_ignore
devel_distclean/client/gui-sdl/spaceshipdlg.c
devel/client/gui-sdl/spaceshipdlg.c
--- devel_distclean/client/gui-sdl/spaceshipdlg.c 2005-10-16
21:49:00.000000000 +0200
+++ devel/client/gui-sdl/spaceshipdlg.c 2005-11-15 06:52:45.000000000 +0100
@@ -64,7 +64,7 @@
TYPED_LIST_ITERATE(struct SMALL_DLG, dialoglist, pdialog)
#define dialog_list_iterate_end LIST_ITERATE_END
-static struct dialog_list dialog_list;
+static struct dialog_list *dialog_list = NULL;
static bool dialog_list_has_been_initialised = FALSE;
/****************************************************************
@@ -73,7 +73,7 @@
static struct SMALL_DLG *get_spaceship_dialog(struct player *pplayer)
{
if (!dialog_list_has_been_initialised) {
- dialog_list_init(&dialog_list);
+ dialog_list = dialog_list_new();
dialog_list_has_been_initialised = TRUE;
}
@@ -118,8 +118,8 @@
/* launch button */
pBuf = pSpaceShp->pEndWidgetList->prev->prev;
- if(game.spacerace
- && pPlayer->player_no == game.player_idx
+ if(game.info.spacerace
+ && pPlayer->player_no == game.info.player_idx
&& pPlayer->spaceship.state == SSHIP_STARTED
&& pPlayer->spaceship.success_rate > 0.0) {
set_wstate(pBuf, FC_WS_NORMAL);
@@ -129,7 +129,6 @@
pBuf = pBuf->prev;
copy_chars_to_string16(pBuf->string16,
get_spaceship_descr(&pPlayer->spaceship));
-
/* ------------------------------------------ */
/* redraw */
@@ -156,10 +155,10 @@
my_snprintf(cBuf, sizeof(cBuf), _("%s's SpaceShip"),
get_nation_name(pPlayer->nation));
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pStr->style |= TTF_STYLE_BOLD;
- pWindow = create_window(NULL, pStr, 10, 10, WF_DRAW_THEME_TRANSPARENT);
+ pWindow = create_window(NULL, pStr, adj_size(10), adj_size(10),
WF_DRAW_THEME_TRANSPARENT);
pWindow->action = space_dialog_window_callback;
set_wstate(pWindow, FC_WS_NORMAL);
@@ -178,31 +177,31 @@
pBuf->action = exit_space_dialog_callback;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->key = SDLK_ESCAPE;
- w += (pBuf->size.w + 10);
+ w += (pBuf->size.w + adj_size(10));
add_to_gui_list(ID_BUTTON, pBuf);
pBuf = create_themeicon_button_from_chars(pTheme->OK_Icon, pWindow->dst,
- _("Launch"), 12, 0);
+ _("Launch"), adj_font(12), 0);
clear_wflag(pBuf, WF_DRAW_FRAME_AROUND_WIDGET);
pBuf->action = launch_spaceship_callback;
w = MAX(w, pBuf->size.w);
- h += pBuf->size.h + 20;
+ h += pBuf->size.h + adj_size(20);
add_to_gui_list(ID_BUTTON, pBuf);
- pStr = create_str16_from_char(get_spaceship_descr(NULL), 12);
+ pStr = create_str16_from_char(get_spaceship_descr(NULL), adj_font(12));
pStr->render = 3;
pStr->bgcol.unused = 128;
pBuf = create_iconlabel(NULL, pWindow->dst, pStr,
WF_DRAW_THEME_TRANSPARENT);
w = MAX(w, pBuf->size.w);
- h += pBuf->size.h + 20;
+ h += pBuf->size.h + adj_size(20);
add_to_gui_list(ID_LABEL, pBuf);
pSpaceShp->pBeginWidgetList = pBuf;
/* -------------------------------------------------------- */
- w = MAX(w, 300);
+ w = MAX(w, adj_size(300));
pWindow->size.x = (Main.screen->w - w) / 2;
pWindow->size.y = (Main.screen->h - h) / 2;
@@ -217,14 +216,14 @@
/* launch button */
pBuf = pBuf->prev;
pBuf->size.x = pWindow->size.x + (pWindow->size.w - pBuf->size.w) / 2;
- pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h - 10;
+ pBuf->size.y = pWindow->size.y + pWindow->size.h - pBuf->size.h -
adj_size(10);
/* info label */
pBuf = pBuf->prev;
pBuf->size.x = pWindow->size.x + (pWindow->size.w - pBuf->size.w) / 2;
- pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 1 + 10;
+ pBuf->size.y = pWindow->size.y + WINDOW_TILE_HIGH + 1 + adj_size(10);
- dialog_list_prepend(&dialog_list, pSpaceShp);
+ dialog_list_prepend(dialog_list, pSpaceShp);
refresh_spaceship_dialog(pPlayer);
} else {
@@ -246,7 +245,7 @@
if((pSpaceShp = get_spaceship_dialog(pPlayer))) {
popdown_window_group_dialog(pSpaceShp->pBeginWidgetList,
pSpaceShp->pEndWidgetList);
- dialog_list_unlink(&dialog_list, pSpaceShp);
+ dialog_list_unlink(dialog_list, pSpaceShp);
FREE(pSpaceShp);
}
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/gui-sdl/wldlg.c
devel/client/gui-sdl/wldlg.c
--- devel_distclean/client/gui-sdl/wldlg.c 2005-10-18 21:02:43.000000000
+0200
+++ devel/client/gui-sdl/wldlg.c 2005-11-15 06:52:45.000000000 +0100
@@ -54,6 +54,7 @@
#include "support.h"
#include "climisc.h"
#include "clinet.h"
+#include "log.h"
#include "wldlg.h"
#include "citydlg.h"
@@ -81,8 +82,7 @@
struct GUI *pProduction_Progres;
int stock;
- int production.value;
- bool production.is_unit;
+ struct city_production currently_building;
} *pEditor = NULL;
@@ -90,7 +90,7 @@
static int worklist_editor_item_callback(struct GUI *pWidget);
static SDL_Surface * get_progress_icon(int stock, int cost, int *progress);
static const char * get_production_name(struct city *pCity,
- int id, bool is_unit, int *cost);
+ struct city_production prod, int
*cost);
static void refresh_worklist_count_label(void);
static void refresh_production_label(int stock);
@@ -139,18 +139,13 @@
bool same_prod = TRUE;
/* remove duplicate entry of impv./wonder target from worklist */
- for(i = 0; i < MAX_LEN_WORKLIST; i++) {
- if(pEditor->pCopy_WorkList->wlefs[i] == WEF_END) {
- break;
- }
- if(pEditor->pCopy_WorkList->wlefs[i] == WEF_IMPR) {
- for(j = i + 1; j < MAX_LEN_WORKLIST; j++) {
- if(pEditor->pCopy_WorkList->wlefs[j] == WEF_END) {
- break;
- }
- if(pEditor->pCopy_WorkList->wlefs[j] == WEF_IMPR &&
- pEditor->pCopy_WorkList->wlids[i] ==
- pEditor->pCopy_WorkList->wlids[j]) {
+ for(i = 0; i < worklist_length(pEditor->pCopy_WorkList); i++) {
+
+ if(!pEditor->pCopy_WorkList->entries[i].is_unit) {
+ for(j = i + 1; j < worklist_length(pEditor->pCopy_WorkList); j++) {
+ if(!pEditor->pCopy_WorkList->entries[j].is_unit &&
+ (pEditor->pCopy_WorkList->entries[i].value ==
+ pEditor->pCopy_WorkList->entries[j].value)) {
worklist_remove(pEditor->pCopy_WorkList, j);
}
}
@@ -159,23 +154,19 @@
if(pCity) {
/* remove duplicate entry of currently building impv./wonder from worklist
*/
- if(!pEditor->production.is_unit) {
- for(i = 0; i < MAX_LEN_WORKLIST; i++) {
- if(pEditor->pCopy_WorkList->wlefs[i] == WEF_END) {
- break;
- }
- if(pEditor->pCopy_WorkList->wlefs[i] == WEF_IMPR &&
- pEditor->pCopy_WorkList->wlids[i] == pEditor->production.value) {
+ if(!pEditor->currently_building.is_unit) {
+ for(i = 0; i < worklist_length(pEditor->pCopy_WorkList); i++) {
+ if(!pEditor->pCopy_WorkList->entries[i].is_unit &&
+ pEditor->pCopy_WorkList->entries[i].value ==
pEditor->currently_building.value) {
worklist_remove(pEditor->pCopy_WorkList, i);
}
}
}
/* change production */
- if(pEditor->production.is_unit != pCity->production.is_unit ||
- pEditor->production.value != pCity->production.value) {
- city_change_production(pCity, pEditor->production.is_unit,
- pEditor->production.value);
+ if(pEditor->currently_building.is_unit != pCity->production.is_unit ||
+ pEditor->currently_building.value != pCity->production.value) {
+ city_change_production(pCity, pEditor->currently_building);
same_prod = FALSE;
}
@@ -232,53 +223,43 @@
*/
static void add_target_to_worklist(struct GUI *pTarget)
{
- bool is_unit = FALSE;
- int i, target = MAX_ID - pTarget->ID;
struct GUI *pBuf = NULL, *pDock = NULL;
SDL_String16 *pStr = NULL;
SDL_Surface *pDest = pTarget->dst;
+ int i;
+ struct city_production prod = cid_decode(MAX_ID - pTarget->ID);
set_wstate(pTarget, FC_WS_SELLECTED);
redraw_widget(pTarget);
flush_rect(pTarget->size);
- if(target < 1000) {
- is_unit = TRUE;
- } else {
- target -= 1000;
- }
-
- /* Denny adding currently building Impr/Wonder Target */
- if(pEditor->pCity && !is_unit && !pEditor->production.is_unit &&
- (target == pEditor->production.value)) {
+ /* Deny adding currently building Impr/Wonder Target */
+ if(pEditor->pCity && !prod.is_unit && !pEditor->currently_building.is_unit &&
+ (prod.value == pEditor->currently_building.value)) {
return;
}
- /* find first free place or imprvm. already in list */
- for(i = 0; i < MAX_LEN_WORKLIST; i++)
- if(pEditor->pCopy_WorkList->wlefs[i] == WEF_END ||
- (!is_unit && pEditor->pCopy_WorkList->wlefs[i] == WEF_IMPR &&
- pEditor->pCopy_WorkList->wlids[i] == target)) {
- break;
+ if (worklist_length(pEditor->pCopy_WorkList) >= MAX_LEN_WORKLIST - 1) {
+ return;
}
- /* there is no room or imprvm. is already on list */
- if(i >= MAX_LEN_WORKLIST - 1 || pEditor->pCopy_WorkList->wlefs[i] !=
WEF_END) {
+ for(i = 0; i < worklist_length(pEditor->pCopy_WorkList); i++) {
+ if((!prod.is_unit && !pEditor->pCopy_WorkList->entries[i].is_unit) &&
+ (pEditor->pCopy_WorkList->entries[i].value == prod.value)) {
return;
}
+ }
- pEditor->pCopy_WorkList->wlefs[i] = is_unit ? WEF_UNIT : WEF_IMPR;
- pEditor->pCopy_WorkList->wlids[i] = target;
-
- pEditor->pCopy_WorkList->wlefs[i + 1] = WEF_END;
- pEditor->pCopy_WorkList->wlids[i + 1] = 0;
+ worklist_append(pEditor->pCopy_WorkList, prod);
/* create widget entry */
- if(is_unit) {
- pStr = create_str16_from_char(get_unit_type(target)->name, 10);
+ if(prod.is_unit) {
+ pStr = create_str16_from_char(get_unit_type(prod.value)->name,
adj_font(10));
} else {
- pStr = create_str16_from_char(get_impr_name_ex(pEditor->pCity, target),
10);
+ pStr = create_str16_from_char(get_impr_name_ex(pEditor->pCity, prod.value),
+ adj_font(10));
}
+
pStr->style |= SF_CENTER;
pBuf = create_iconlabel(NULL, pDest, pStr,
(WF_DRAW_THEME_TRANSPARENT|WF_FREE_DATA));
@@ -287,13 +268,9 @@
pBuf->action = worklist_editor_item_callback;
pBuf->data.ptr = MALLOC(sizeof(int));
- *((int *)pBuf->data.ptr) = i;
+ *((int *)pBuf->data.ptr) = worklist_length(pEditor->pCopy_WorkList) - 1;
- if(is_unit) {
- pBuf->ID = MAX_ID - target;
- } else {
- pBuf->ID = MAX_ID - 1000 - target;
- }
+ pBuf->ID = MAX_ID - cid_encode(prod);
if(pEditor->pWork->pBeginActiveWidgetList) {
pDock = pEditor->pWork->pBeginActiveWidgetList;
@@ -301,12 +278,32 @@
pDock = pEditor->pDock;
}
+/* FIXME */
+#if 0
+ if (worklist_length(pEditor->pCopy_WorkList) >
pEditor->pWork->pScroll->active + 1) {
+
+ setup_vertical_widgets_position(1,
+ pEditor->pEndWidgetList->size.x + FRAME_WH + adj_size(2),
+ get_widget_pointer_form_main_list(ID_WINDOW)->size.y + FRAME_WH +
adj_size(152) +
+ pEditor->pWork->pScroll->pUp_Left_Button->size.h + 1,
+ adj_size(126), 0, pEditor->pWork->pBeginWidgetList,
+ pEditor->pWork->pEndWidgetList);
+
+ setup_vertical_scrollbar_area(pEditor->pWork->pScroll,
+ pEditor->pEndWidgetList->size.x + FRAME_WH + adj_size(2),
+ get_widget_pointer_form_main_list(ID_WINDOW)->size.y + FRAME_WH +
adj_size(152),
+ adj_size(225), FALSE);
+
+ show_scrollbar(pEditor->pWork->pScroll);
+ }
+#endif
+
add_widget_to_vertical_scroll_widget_list(pEditor->pWork, pBuf,
pDock, FALSE,
- pEditor->pEndWidgetList->size.x + FRAME_WH + 2,
- pEditor->pEndWidgetList->size.y + FRAME_WH + 152);
+ pEditor->pEndWidgetList->size.x + FRAME_WH +
adj_size(2),
+ pEditor->pEndWidgetList->size.y + FRAME_WH +
adj_size(152));
- pBuf->size.w = 126;
+ pBuf->size.w = adj_size(126);
refresh_worklist_count_label();
redraw_group(pEditor->pWork->pBeginWidgetList,
@@ -330,24 +327,23 @@
* Change production in editor shell, callculate production shields penalty and
* refresh production progress label
*/
-static void change_production(int target, bool is_unit)
+static void change_production(struct city_production prod)
{
- if(!are_the_same_class(pEditor->production.value,
- pEditor->production.is_unit, target, is_unit)) {
+ if(!are_the_same_class(pEditor->currently_building.value,
+ pEditor->currently_building.is_unit, prod.value, prod.is_unit))
{
if(pEditor->stock != pEditor->pCity->shield_stock) {
if(are_the_same_class(pEditor->pCity->production.value,
- pEditor->pCity->production.is_unit, target, is_unit)) {
+ pEditor->pCity->production.is_unit, prod.value, prod.is_unit)) {
pEditor->stock = pEditor->pCity->shield_stock;
}
} else {
pEditor->stock =
- city_change_production_penalty(pEditor->pCity, target, is_unit);
+ city_change_production_penalty(pEditor->pCity, prod);
}
}
- pEditor->production.value = target;
- pEditor->production.is_unit = is_unit;
+ pEditor->currently_building = prod;
refresh_production_label(pEditor->stock);
return;
@@ -363,8 +359,8 @@
*/
static void add_target_to_production(struct GUI *pTarget)
{
- bool is_unit = FALSE;
- int target, dummy;
+ int dummy;
+ struct city_production prod;
assert(pTarget != NULL);
/* redraw Target Icon */
@@ -372,34 +368,23 @@
redraw_widget(pTarget);
flush_rect(pTarget->size);
- /* decode target */
- target = MAX_ID - pTarget->ID;
- if(target < 1000) {
- is_unit = TRUE;
- } else {
- target -= 1000;
- }
+ prod = cid_decode(MAX_ID - pTarget->ID);
/* check if we change to the same target */
- if(((pEditor->production.value == target) &&
- (pEditor->production.is_unit == is_unit)) || pEditor->pCity->did_buy) {
+ if(((pEditor->currently_building.value == prod.value) &&
+ (pEditor->currently_building.is_unit == prod.is_unit))) {
/* comit changes and exit - double click detection */
ok_worklist_editor_callback(NULL);
return;
}
- change_production(target, is_unit);
+ change_production(prod);
/* change Production Text Label in Worklist Widget list */
copy_chars_to_string16(pEditor->pWork->pEndActiveWidgetList->string16,
- get_production_name(pEditor->pCity, target, is_unit, &dummy));
+ get_production_name(pEditor->pCity, prod, &dummy));
- /* code Target ID */
- if(is_unit) {
- pEditor->pWork->pEndActiveWidgetList->ID = MAX_ID - target;
- } else {
- pEditor->pWork->pEndActiveWidgetList->ID = MAX_ID - 1000 - target;
- }
+ pEditor->pWork->pEndActiveWidgetList->ID = MAX_ID - cid_encode(prod);
redraw_widget(pEditor->pWork->pEndActiveWidgetList);
sdl_dirty_rect(pEditor->pWork->pEndActiveWidgetList->size);
@@ -411,28 +396,21 @@
/* Get Help Info about target */
static void get_target_help_data(struct GUI *pTarget)
{
- bool is_unit = FALSE;
- int target;
assert(pTarget != NULL);
+ struct city_production prod;
/* redraw Target Icon */
set_wstate(pTarget, FC_WS_SELLECTED);
redraw_widget(pTarget);
/*flush_rect(pTarget->size);*/
- /* decode target */
- target = MAX_ID - pTarget->ID;
- if(target < 1000) {
- is_unit = TRUE;
- } else {
- target -= 1000;
- }
+ prod = cid_decode(MAX_ID - pTarget->ID);
- if (is_unit)
+ if (prod.is_unit)
{
- popup_unit_info(target);
+ popup_unit_info(prod.value);
} else {
- popup_impr_info(target);
+ popup_impr_info(prod.value);
}
}
@@ -486,30 +464,30 @@
*((int *)pBuf->data.ptr) = *((int *)pBuf->data.ptr) - 1;
} while(pBuf != pEditor->pWork->pBeginActiveWidgetList);
}
+
/* remove element from worklist */
worklist_remove(pEditor->pCopy_WorkList, *((int *)pItem->data.ptr));
+
/* remove widget from widget list */
del_widget_from_vertical_scroll_widget_list(pEditor->pWork, pItem);
} else {
/* change production ... */
- if(!pEditor->pCity->did_buy) {
if(worklist_is_empty(pEditor->pCopy_WorkList)) {
/* there is no worklist */
- if(!(!pEditor->production.is_unit &&
- (pEditor->production.value == B_CAPITAL))) {
+ if(!(!pEditor->currently_building.is_unit &&
+ building_has_effect(pEditor->currently_building.value,
EFT_PROD_TO_GOLD))) {
/* change to capitalization */
int dummy;
- change_production(B_CAPITAL, FALSE);
+
change_production(cid_production(get_building_for_effect(EFT_PROD_TO_GOLD)));
copy_chars_to_string16(pItem->string16,
- get_production_name(pEditor->pCity, B_CAPITAL, FALSE, &dummy));
+ get_production_name(pEditor->pCity,
cid_decode(cid_encode_building(get_building_for_effect(EFT_PROD_TO_GOLD))),
&dummy));
- pItem->ID = MAX_ID - 1000 - B_CAPITAL;
+ pItem->ID = MAX_ID -
cid_encode_building(get_building_for_effect(EFT_PROD_TO_GOLD));
}
} else {
/* change productions to first worklist element */
struct GUI *pBuf = pItem->prev;
- change_production(pEditor->pCopy_WorkList->wlids[0],
- (pEditor->pCopy_WorkList->wlefs[0] == WEF_UNIT));
+ change_production(pEditor->pCopy_WorkList->entries[0]);
worklist_advance(pEditor->pCopy_WorkList);
del_widget_from_vertical_scroll_widget_list(pEditor->pWork, pItem);
FREE(pBuf->data.ptr);
@@ -521,7 +499,26 @@
}
}
}
+
+/* FIXME */
+#if 0
+ /* worklist_length(pEditor->pCopy_WorkList): without production */
+ if (worklist_length(pEditor->pCopy_WorkList) <=
pEditor->pWork->pScroll->active + 1) {
+
+ setup_vertical_widgets_position(1,
+ pEditor->pEndWidgetList->size.x + FRAME_WH + adj_size(2),
+ get_widget_pointer_form_main_list(ID_WINDOW)->size.y + FRAME_WH +
adj_size(152),
+ adj_size(126), 0, pEditor->pWork->pBeginWidgetList,
+ pEditor->pWork->pEndWidgetList);
+#if 0
+ setup_vertical_scrollbar_area(pEditor->pWork->pScroll,
+ pEditor->pEndWidgetList->size.x + FRAME_WH + adj_size(2),
+ get_widget_pointer_form_main_list(ID_WINDOW)->size.y + FRAME_WH +
adj_size(152),
+ adj_size(225), FALSE);*/
+#endif
+ hide_scrollbar(pEditor->pWork->pScroll);
}
+#endif
refresh_worklist_count_label();
redraw_group(pEditor->pWork->pBeginWidgetList,
@@ -530,7 +527,7 @@
}
/*
- * Swap worklist elements DOWN.
+ * Swap worklist entries DOWN.
* Fuction swap current element with next element of worklist.
*
* If pItem is last widget or there is only one widget on widgets list
@@ -542,10 +539,9 @@
*/
static void swap_item_down_from_worklist(struct GUI *pItem)
{
- int id;
Uint16 *pText, ID;
- enum worklist_elem_flag flag;
bool changed = FALSE;
+ struct city_production tmp;
if(pItem == pEditor->pWork->pBeginActiveWidgetList) {
remove_item_from_worklist(pItem);
@@ -559,33 +555,17 @@
/* worklist operations -> swap down */
int row = *((int *)pItem->data.ptr);
- flag = pEditor->pCopy_WorkList->wlefs[row];
- id = pEditor->pCopy_WorkList->wlids[row];
+ tmp = pEditor->pCopy_WorkList->entries[row];
+ pEditor->pCopy_WorkList->entries[row] =
pEditor->pCopy_WorkList->entries[row + 1];
+ pEditor->pCopy_WorkList->entries[row + 1] = tmp;
- pEditor->pCopy_WorkList->wlids[row] = pEditor->pCopy_WorkList->wlids[row +
1];
- pEditor->pCopy_WorkList->wlefs[row] = pEditor->pCopy_WorkList->wlefs[row +
1];
- pEditor->pCopy_WorkList->wlids[row + 1] = id;
- pEditor->pCopy_WorkList->wlefs[row + 1] = flag;
changed = TRUE;
} else {
/* change production ... */
- if(!pEditor->pCity->did_buy) {
- id = MAX_ID - ID;
-
- if(id < 1000) {
- flag = WEF_UNIT;
- } else {
- id -= 1000;
- flag = WEF_IMPR;
- }
-
- change_production(pEditor->pCopy_WorkList->wlids[0],
- (pEditor->pCopy_WorkList->wlefs[0] == WEF_UNIT));
- pEditor->pCopy_WorkList->wlids[0] = id;
- pEditor->pCopy_WorkList->wlefs[0] = flag;
+ change_production(pEditor->pCopy_WorkList->entries[0]);
+ pEditor->pCopy_WorkList->entries[0] = cid_decode(MAX_ID - ID);
changed = TRUE;
}
- }
if(changed) {
pItem->string16->text = pItem->prev->string16->text;
@@ -602,7 +582,7 @@
}
/*
- * Swap worklist elements UP.
+ * Swap worklist entries UP.
* Fuction swap current element with prev. element of worklist.
*
* If pItem is first widget on widgets list fuction remove this widget
@@ -615,11 +595,10 @@
*/
static void swap_item_up_from_worklist(struct GUI *pItem)
{
- int id;
Uint16 *pText = pItem->string16->text;
Uint16 ID = pItem->ID;
- enum worklist_elem_flag flag;
bool changed = FALSE;
+ struct city_production tmp;
if(pItem == pEditor->pWork->pEndActiveWidgetList) {
remove_item_from_worklist(pItem);
@@ -630,32 +609,18 @@
/* worklist operations -> swap up*/
int row = *((int *)pItem->data.ptr);
- flag = pEditor->pCopy_WorkList->wlefs[row];
- id = pEditor->pCopy_WorkList->wlids[row];
+ tmp = pEditor->pCopy_WorkList->entries[row];
+ pEditor->pCopy_WorkList->entries[row] =
pEditor->pCopy_WorkList->entries[row - 1];
+ pEditor->pCopy_WorkList->entries[row - 1] = tmp;
- pEditor->pCopy_WorkList->wlids[row] = pEditor->pCopy_WorkList->wlids[row -
1];
- pEditor->pCopy_WorkList->wlefs[row] = pEditor->pCopy_WorkList->wlefs[row -
1];
- pEditor->pCopy_WorkList->wlids[row - 1] = id;
- pEditor->pCopy_WorkList->wlefs[row - 1] = flag;
changed = TRUE;
} else {
- if(!pEditor->pCity->did_buy) {
/* change production ... */
- id = pEditor->production.value;
-
- if(pEditor->production.is_unit) {
- flag = WEF_UNIT;
- } else {
- flag = WEF_IMPR;
- }
+ change_production(pEditor->pCopy_WorkList->entries[0]);
+ pEditor->pCopy_WorkList->entries[0] = pEditor->currently_building;
- change_production(pEditor->pCopy_WorkList->wlids[0],
- (pEditor->pCopy_WorkList->wlefs[0] == WEF_UNIT));
- pEditor->pCopy_WorkList->wlids[0] = id;
- pEditor->pCopy_WorkList->wlefs[0] = flag;
changed = FALSE;
}
- }
if(changed) {
pItem->string16->text = pItem->next->string16->text;
@@ -672,9 +637,9 @@
/*
* worklist callback
- * left mouse button -> swap elements up.
+ * left mouse button -> swap entries up.
* middle mouse button -> remove element from list
- * right mouse button -> swap elements down.
+ * right mouse button -> swap entries down.
*/
static int worklist_editor_item_callback(struct GUI *pWidget)
{
@@ -700,7 +665,7 @@
* Add global worklist to city worklist starting from last free entry.
* Add only avilable targets in current game state.
* If global worklist have more targets that city worklist have free
- * elements then we adding only first part of global worklist.
+ * entries then we adding only first part of global worklist.
*/
static void add_global_worklist(struct GUI *pWidget)
{
@@ -710,66 +675,53 @@
struct GUI *pBuf = pEditor->pWork->pEndActiveWidgetList;
struct worklist *pWorkList = &game.player_ptr->worklists[MAX_ID -
pWidget->ID];
- /* find first free element in worklist */
- for(count = 0; count < MAX_LEN_WORKLIST; count++) {
- if(pEditor->pCopy_WorkList->wlefs[count] == WEF_END) {
- break;
- }
- }
-
- if(count >= MAX_LEN_WORKLIST - 1) {
+ if(worklist_length(pEditor->pCopy_WorkList) >= MAX_LEN_WORKLIST - 1) {
/* worklist is full */
return;
}
- firstfree = count;
+ firstfree = worklist_length(pEditor->pCopy_WorkList);
/* copy global worklist to city worklist */
- for(count = 0 ; count < MAX_LEN_WORKLIST; count++) {
-
- /* last element */
- if(pWorkList->wlefs[count] == WEF_END) {
- break;
- }
+ for(count = 0 ; count < worklist_length(pWorkList); count++) {
/* global worklist can have targets unavilable in current state of game
then we must remove those targets from new city worklist */
- if(((pWorkList->wlefs[count] == WEF_UNIT) &&
- !can_eventually_build_unit(pEditor->pCity, pWorkList->wlids[count]))
||
- ((pWorkList->wlefs[count] == WEF_IMPR) &&
- !can_eventually_build_improvement(pEditor->pCity,
pWorkList->wlids[count]))) {
+ if(((pWorkList->entries[count].is_unit) &&
+ !can_eventually_build_unit(pEditor->pCity,
get_unit_type(pWorkList->entries[count].value))) ||
+ ((!pWorkList->entries[count].is_unit) &&
+ !can_eventually_build_improvement(pEditor->pCity,
pWorkList->entries[count].value))) {
continue;
}
- pEditor->pCopy_WorkList->wlids[firstfree] = pWorkList->wlids[count];
- pEditor->pCopy_WorkList->wlefs[firstfree] = pWorkList->wlefs[count];
+ worklist_append(pEditor->pCopy_WorkList, pWorkList->entries[count]);
/* create widget */
- if(pWorkList->wlefs[count] == WEF_UNIT) {
+ if(pWorkList->entries[count].is_unit) {
pBuf = create_iconlabel(NULL, pDest,
create_str16_from_char(
- get_unit_type(pWorkList->wlids[count])->name, 10),
+ get_unit_type(pWorkList->entries[count].value)->name,
adj_font(10)),
(WF_DRAW_THEME_TRANSPARENT|WF_FREE_DATA));
- pBuf->ID = MAX_ID - pWorkList->wlids[count];
+ pBuf->ID = MAX_ID -
cid_encode_unit(get_unit_type(pWorkList->entries[count].value));
} else {
pBuf = create_iconlabel(NULL, pDest,
create_str16_from_char(
get_impr_name_ex(pEditor->pCity,
- pWorkList->wlids[count]), 10),
+ pWorkList->entries[count].value), adj_font(10)),
(WF_DRAW_THEME_TRANSPARENT|WF_FREE_DATA));
- pBuf->ID = MAX_ID - 1000 - pWorkList->wlids[count];
+ pBuf->ID = MAX_ID -
cid_encode_building(pWorkList->entries[count].value);
}
pBuf->string16->style |= SF_CENTER;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = worklist_editor_item_callback;
- pBuf->size.w = 126;
+ pBuf->size.w = adj_size(126);
pBuf->data.ptr = MALLOC(sizeof(int));
*((int *)pBuf->data.ptr) = firstfree;
add_widget_to_vertical_scroll_widget_list(pEditor->pWork,
pBuf, pEditor->pWork->pBeginActiveWidgetList, FALSE,
- pEditor->pEndWidgetList->size.x + FRAME_WH + 2,
- pEditor->pEndWidgetList->size.y + FRAME_WH + 152);
+ pEditor->pEndWidgetList->size.x + FRAME_WH +
adj_size(2),
+ pEditor->pEndWidgetList->size.y + FRAME_WH +
adj_size(152));
firstfree++;
if(firstfree == MAX_LEN_WORKLIST - 1) {
@@ -777,11 +729,6 @@
}
}
- if(firstfree < MAX_LEN_WORKLIST) {
- pEditor->pCopy_WorkList->wlids[firstfree] = 0;
- pEditor->pCopy_WorkList->wlefs[firstfree] = WEF_END;
- }
-
refresh_worklist_count_label();
redraw_group(pEditor->pWork->pBeginWidgetList,
pEditor->pWork->pEndWidgetList, TRUE);
@@ -799,8 +746,8 @@
{
if(!worklist_is_empty(&game.player_ptr->worklists[MAX_ID - pWidget->ID])) {
SDL_Surface *pDest = pWidget->dst;
- int count, target , wl_count;
- bool is_unit;
+ int count, wl_count;
+ struct city_production target;
struct GUI *pBuf = pEditor->pWork->pEndActiveWidgetList;
struct worklist wl ,
*pWorkList = &game.player_ptr->worklists[MAX_ID - pWidget->ID];
@@ -810,24 +757,19 @@
wl_count = 0;
/* copy global worklist to city worklist */
- for(count = 0; count < MAX_LEN_WORKLIST; count++) {
-
- /* last element */
- if(pWorkList->wlefs[count] == WEF_END) {
- break;
- }
+ for(count = 0; count < worklist_length(pWorkList); count++) {
/* global worklist can have targets unavilable in current state of game
then we must remove those targets from new city worklist */
- if(((pWorkList->wlefs[count] == WEF_UNIT) &&
- !can_eventually_build_unit(pEditor->pCity, pWorkList->wlids[count]))
||
- ((pWorkList->wlefs[count] == WEF_IMPR) &&
- !can_eventually_build_improvement(pEditor->pCity,
pWorkList->wlids[count]))) {
+ if(((pWorkList->entries[count].is_unit) &&
+ !can_eventually_build_unit(pEditor->pCity,
get_unit_type(pWorkList->entries[count].value))) ||
+ ((!pWorkList->entries[count].is_unit) &&
+ !can_eventually_build_improvement(pEditor->pCity,
pWorkList->entries[count].value))) {
continue;
}
- wl.wlids[wl_count] = pWorkList->wlids[count];
- wl.wlefs[wl_count] = pWorkList->wlefs[count];
+ wl.entries[wl_count].value = pWorkList->entries[count].value;
+ wl.entries[wl_count].is_unit = pWorkList->entries[count].is_unit;
wl_count++;
}
/* --------------------------------- */
@@ -852,32 +794,32 @@
/* create new widget list */
for(count = 0; count < MAX_LEN_WORKLIST; count++) {
/* end of list */
- if(!worklist_peek_ith(pEditor->pCopy_WorkList, &target, &is_unit,
count)) {
+ if(!worklist_peek_ith(pEditor->pCopy_WorkList, &target, count)) {
break;
}
- if(is_unit) {
+ if(target.is_unit) {
pBuf = create_iconlabel(NULL, pDest,
- create_str16_from_char(get_unit_type(target)->name, 10),
+ create_str16_from_char(get_unit_type(target.value)->name,
adj_font(10)),
(WF_DRAW_THEME_TRANSPARENT|WF_FREE_DATA));
- pBuf->ID = MAX_ID - target;
+ pBuf->ID = MAX_ID - B_LAST - target.value;
} else {
pBuf = create_iconlabel(NULL, pDest,
- create_str16_from_char(get_impr_name_ex(pEditor->pCity, target), 10),
+ create_str16_from_char(get_impr_name_ex(pEditor->pCity,
target.value), adj_font(10)),
(WF_DRAW_THEME_TRANSPARENT|WF_FREE_DATA));
- pBuf->ID = MAX_ID -1000 - target;
+ pBuf->ID = MAX_ID - target.value;
}
pBuf->string16->style |= SF_CENTER;
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = worklist_editor_item_callback;
- pBuf->size.w = 126;
+ pBuf->size.w = adj_size(126);
pBuf->data.ptr = MALLOC(sizeof(int));
*((int *)pBuf->data.ptr) = count;
add_widget_to_vertical_scroll_widget_list(pEditor->pWork,
pBuf, pEditor->pWork->pBeginActiveWidgetList, FALSE,
- pEditor->pEndWidgetList->size.x + FRAME_WH + 2,
- pEditor->pEndWidgetList->size.y + FRAME_WH + 152);
+ pEditor->pEndWidgetList->size.x + FRAME_WH +
adj_size(2),
+ pEditor->pEndWidgetList->size.y + FRAME_WH +
adj_size(152));
}
refresh_worklist_count_label();
@@ -923,17 +865,17 @@
/* return full unit/imprv. name and build cost in "cost" pointer */
static const char * get_production_name(struct city *pCity,
- int id, bool is_unit, int *cost)
+ struct city_production prod, int
*cost)
{
assert(cost != NULL);
- if(is_unit) {
- struct unit_type *pType = get_unit_type(id);
- *cost = unit_build_shield_cost(id);
+ if(prod.is_unit) {
+ struct unit_type *pType = get_unit_type(prod.value);
+ *cost = unit_build_shield_cost(get_unit_type(prod.value));
return pType->name;
} else {
- *cost = impr_build_shield_cost(id);
- return get_impr_name_ex(pCity, id);
+ *cost = impr_build_shield_cost(prod.value);
+ return get_impr_name_ex(pCity, prod.value);
}
}
@@ -950,22 +892,22 @@
assert(progress != NULL);
if(stock < cost) {
- width = ((float)stock / cost) * 116.0;
+ width = ((float)stock / cost) * adj_size(116.0);
*progress = ((float)stock / cost) * 100.0;
if(!width && stock) {
*progress = 1;
width = 1;
}
} else {
- width = 116;
+ width = adj_size(116);
*progress = 100;
}
- pIcon = create_bcgnd_surf(pTheme->Edit, 1, 0, 120, 30);
+ pIcon = create_bcgnd_surf(pTheme->Edit, 1, 0, adj_size(120), adj_size(30));
if(width) {
SDL_Rect dst = {2,1,0,0};
- SDL_Surface *pBuf = create_bcgnd_surf(pTheme->Button, 1, 3, width, 28);
+ SDL_Surface *pBuf = create_bcgnd_surf(pTheme->Button, 1, 3, width,
adj_size(28));
SDL_BlitSurface(pBuf, NULL, pIcon, &dst);
FREESURFACE(pBuf);
}
@@ -983,18 +925,17 @@
char cBuf[64];
SDL_Rect area;
const char *name = get_production_name(pEditor->pCity,
- pEditor->production.value,
- pEditor->production.is_unit, &cost);
+ pEditor->currently_building, &cost);
- if (!pEditor->production.is_unit
- && pEditor->production.value == B_CAPITAL)
+ if (!pEditor->currently_building.is_unit
+ && (pEditor->currently_building.value ==
get_building_for_effect(EFT_PROD_TO_GOLD)))
{
my_snprintf(cBuf, sizeof(cBuf),
- _("%s\n%d gold per turn"), name, MAX(0,
pEditor->pCity->shield_surplus));
+ _("%s\n%d gold per turn"), name, MAX(0,
pEditor->pCity->surplus[O_SHIELD]));
} else {
if(stock < cost) {
turns = city_turns_to_build(pEditor->pCity,
- pEditor->production.value, pEditor->production.is_unit, TRUE);
+ pEditor->currently_building, TRUE);
if(turns == 999)
{
my_snprintf(cBuf, sizeof(cBuf), _("%s\nblocked!"), name);
@@ -1016,11 +957,11 @@
remake_label_size(pEditor->pProduction_Name);
pEditor->pProduction_Name->size.x = pEditor->pEndWidgetList->size.x +
- (130 - pEditor->pProduction_Name->size.w)/2 + FRAME_WH;
+ (adj_size(130) - pEditor->pProduction_Name->size.w)/2 +
FRAME_WH;
area.x = pEditor->pEndWidgetList->size.x + FRAME_WH;
area.y = pEditor->pProduction_Name->size.y;
- area.w = 130;
+ area.w = adj_size(130);
area.h = pEditor->pProduction_Name->size.h;
refresh_widget_background(pEditor->pProduction_Name);
@@ -1045,7 +986,7 @@
char cBuf[64];
SDL_Rect area;
- my_snprintf(cBuf, sizeof(cBuf), _("( %d elements )"),
+ my_snprintf(cBuf, sizeof(cBuf), _("( %d entries )"),
worklist_length(pEditor->pCopy_WorkList));
copy_chars_to_string16(pEditor->pWorkList_Counter->string16, cBuf);
@@ -1057,7 +998,7 @@
remake_label_size(pEditor->pWorkList_Counter);
pEditor->pWorkList_Counter->size.x = pEditor->pEndWidgetList->size.x +
- (130 - pEditor->pWorkList_Counter->size.w)/2 + FRAME_WH;
+ (adj_size(130) - pEditor->pWorkList_Counter->size.w)/2 +
FRAME_WH;
refresh_widget_background(pEditor->pWorkList_Counter);
@@ -1065,7 +1006,7 @@
area.x = pEditor->pEndWidgetList->size.x + FRAME_WH;
area.y = pEditor->pWorkList_Counter->size.y;
- area.w = 130;
+ area.w = adj_size(130);
area.h = pEditor->pWorkList_Counter->size.h;
sdl_dirty_rect(area);
@@ -1087,9 +1028,10 @@
SDL_String16 *pStr = NULL;
struct GUI *pBuf = NULL, *pWindow, *pLast;
SDL_Surface *pText = NULL, *pText_Name = NULL, *pZoom = NULL;
- SDL_Surface *pMain = create_surf(116, 116, SDL_SWSURFACE);
+ SDL_Surface *pMain = create_surf(adj_size(116), adj_size(116),
SDL_SWSURFACE);
SDL_Surface *pIcon, *pDest;
SDL_Color color = {255,255,255,128};
+ SDL_Color c;
SDL_Rect dst;
char cBuf[128];
struct unit_type *pUnit = NULL;
@@ -1112,8 +1054,7 @@
copy_worklist(pEditor->pCopy_WorkList, pWorkList);
if(pCity) {
- pEditor->production.is_unit = pCity->production.is_unit;
- pEditor->production.value = pCity->production.value;
+ pEditor->currently_building = pCity->production;
pEditor->stock = pCity->shield_stock;
}
@@ -1146,7 +1087,7 @@
my_snprintf(cBuf, sizeof(cBuf), "%s", pWorkList->name);
}
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pBuf = create_iconlabel(NULL, pDest, pStr, 0);
@@ -1154,30 +1095,26 @@
add_to_gui_list(ID_LABEL, pBuf);
/* --------------------------- */
- count = worklist_length(pWorkList);
- my_snprintf(cBuf, sizeof(cBuf), _("( %d elements )"), count);
- count = 0;
- pStr = create_str16_from_char(cBuf, 10);
+ my_snprintf(cBuf, sizeof(cBuf), _("( %d entries )"),
worklist_length(pWorkList));
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pBuf = create_iconlabel(NULL, pDest, pStr, WF_DRAW_THEME_TRANSPARENT);
pEditor->pWorkList_Counter = pBuf;
add_to_gui_list(ID_LABEL, pBuf);
/* --------------------------- */
+
/* create production proggres label or rename worklist edit */
if(pCity) {
/* count == cost */
/* turns == progress */
- const char *name = get_production_name(pCity,
- pCity->production.value,
- pCity->production.is_unit, &count);
+ const char *name = get_production_name(pCity, pCity->production, &count);
- if (!pCity->production.is_unit && pCity->production.value == B_CAPITAL)
+ if (!pCity->production.is_unit && (pCity->production.value ==
get_building_for_effect(EFT_PROD_TO_GOLD)))
{
my_snprintf(cBuf, sizeof(cBuf),
- _("%s\n%d gold per turn"), name, MAX(0, pCity->shield_surplus));
+ _("%s\n%d gold per turn"), name, MAX(0, pCity->surplus[O_SHIELD]));
} else {
if(pCity->shield_stock < count) {
- turns = city_turns_to_build(pCity,
- pCity->production.value, pCity->production.is_unit, TRUE);
+ turns = city_turns_to_build(pCity, pCity->production, TRUE);
if(turns == 999)
{
my_snprintf(cBuf, sizeof(cBuf), _("%s\nblocked!"), name);
@@ -1189,7 +1126,7 @@
my_snprintf(cBuf, sizeof(cBuf), _("%s\nfinished!"), name);
}
}
- pStr = create_str16_from_char(cBuf, 10);
+ pStr = create_str16_from_char(cBuf, adj_font(10));
pStr->style |= SF_CENTER;
pBuf = create_iconlabel(NULL, pDest, pStr, WF_DRAW_THEME_TRANSPARENT);
@@ -1199,7 +1136,7 @@
pIcon = get_progress_icon(pCity->shield_stock, count, &turns);
my_snprintf(cBuf, sizeof(cBuf), "%d%%" , turns);
- pStr = create_str16_from_char(cBuf, 12);
+ pStr = create_str16_from_char(cBuf, adj_font(12));
pStr->style |= (TTF_STYLE_BOLD|SF_CENTER);
pBuf = create_iconlabel(pIcon, pDest, pStr,
@@ -1210,8 +1147,8 @@
pEditor->pProduction_Progres = pBuf;
add_to_gui_list(ID_LABEL, pBuf);
} else {
- pBuf = create_edit_from_chars(NULL, pDest, pWorkList->name, 10, 120,
- WF_DRAW_THEME_TRANSPARENT);
+ pBuf = create_edit_from_chars(NULL, pDest, pWorkList->name, adj_font(10),
+ adj_size(120), WF_DRAW_THEME_TRANSPARENT);
pBuf->action = rename_worklist_editor_callback;
set_wstate(pBuf, FC_WS_NORMAL);
@@ -1246,9 +1183,6 @@
Production Widget Label in worklist Widget list
will have this field NULL
-
- turns == unit/impv. id
- can_build == is_unit
*/
pEditor->pWork = MALLOC(sizeof(struct ADVANCED_DLG));
@@ -1260,19 +1194,14 @@
if(pCity) {
/* Production Widget Label */
pStr = create_str16_from_char(get_production_name(pCity,
- pCity->production.value,
- pCity->production.is_unit, &turns), 10);
+ pCity->production, &turns), adj_font(10));
pStr->style |= SF_CENTER;
pBuf = create_iconlabel(NULL, pDest, pStr, WF_DRAW_THEME_TRANSPARENT);
set_wstate(pBuf, FC_WS_NORMAL);
pBuf->action = worklist_editor_item_callback;
- if(pCity->production.is_unit) {
- add_to_gui_list(MAX_ID - pCity->production.value, pBuf);
- } else {
- add_to_gui_list(MAX_ID - 1000 - pCity->production.value, pBuf);
- }
+ add_to_gui_list(MAX_ID - cid_encode(pCity->production), pBuf);
pEditor->pWork->pEndWidgetList = pBuf;
pEditor->pWork->pBeginWidgetList = pBuf;
@@ -1283,17 +1212,19 @@
pLast = pBuf;
pEditor->pDock = pBuf;
- /* create Widget Labels of worklist elements */
- for(count = 0; count < MAX_LEN_WORKLIST; count++) {
- /* end of list */
- if(!worklist_peek_ith(pWorkList, &turns, &can_build, count)) {
- break;
- }
- if(can_build) {
- pStr = create_str16_from_char(get_unit_type(turns)->name, 10);
+ /* create Widget Labels of worklist entries */
+
+ count = 0;
+
+ struct worklist *worklist = pWorkList;
+
+ worklist_iterate(worklist, prod) {
+
+ if(prod.is_unit) {
+ pStr = create_str16_from_char(get_unit_type(prod.value)->name,
adj_font(10));
} else {
- pStr = create_str16_from_char(get_impr_name_ex(pCity, turns), 10);
+ pStr = create_str16_from_char(get_impr_name_ex(pCity, prod.value),
adj_font(10));
}
pStr->style |= SF_CENTER;
pBuf = create_iconlabel(NULL, pDest, pStr,
@@ -1305,14 +1236,16 @@
pBuf->data.ptr = MALLOC(sizeof(int));
*((int *)pBuf->data.ptr) = count;
- if(can_build) {
- add_to_gui_list(MAX_ID - turns, pBuf);
- } else {
- add_to_gui_list(MAX_ID - 1000 - turns, pBuf);
- }
+ add_to_gui_list(MAX_ID - cid_encode(prod), pBuf);
+
+ count++;
+ if(count > pEditor->pWork->pScroll->active - 1) {
+ set_wflag(pBuf, WF_HIDDEN);
}
+ } worklist_iterate_end;
+
if(count) {
if(!pCity) {
pEditor->pWork->pEndWidgetList = pLast->prev;
@@ -1327,6 +1260,27 @@
pEditor->pWork->pBeginWidgetList = pLast;
}
+/* FIXME */
+#if 0
+ pEditor->pWork->pActiveWidgetList = pLast;
+ create_vertical_scrollbar(pEditor->pWork, 1,
+ pEditor->pWork->pScroll->active, FALSE, TRUE);
+ pEditor->pWork->pScroll->pUp_Left_Button->size.w = adj_size(122);
+ pEditor->pWork->pScroll->pDown_Right_Button->size.w = adj_size(122);
+
+ /* count: without production */
+ if(count <= pEditor->pWork->pScroll->active + 1) {
+ if(count > 0) {
+ struct GUI *pTmp = pLast;
+ do {
+ pTmp = pTmp->prev;
+ clear_wflag(pTmp, WF_HIDDEN);
+ } while (pTmp != pBuf);
+ }
+ hide_scrollbar(pEditor->pWork->pScroll);
+ }
+#endif
+
pEditor->pWork->pScroll->count += count;
pLast = pEditor->pWork->pBeginWidgetList;
@@ -1337,7 +1291,7 @@
for (i = 0; i < MAX_NUM_WORKLISTS; i++) {
if (game.player_ptr->worklists[i].is_valid) {
pBuf = create_iconlabel_from_chars(NULL, pDest,
- game.player_ptr->worklists[i].name, 10,
+ game.player_ptr->worklists[i].name, adj_font(10),
WF_DRAW_THEME_TRANSPARENT);
set_wstate(pBuf, FC_WS_NORMAL);
add_to_gui_list(MAX_ID - i, pBuf);
@@ -1352,7 +1306,6 @@
}
}
}
-
if(count) {
pEditor->pGlobal = MALLOC(sizeof(struct ADVANCED_DLG));
pEditor->pGlobal->pEndWidgetList = pLast->prev;
@@ -1367,9 +1320,10 @@
pEditor->pGlobal->pScroll->active = 4;
pEditor->pGlobal->pScroll->step = 1;
- create_vertical_scrollbar(pEditor->pGlobal, 1, 4, FALSE, TRUE);
- pEditor->pGlobal->pScroll->pUp_Left_Button->size.w = 122;
- pEditor->pGlobal->pScroll->pDown_Right_Button->size.w = 122;
+ create_vertical_scrollbar(pEditor->pGlobal, 1,
+ pEditor->pGlobal->pScroll->active, FALSE, TRUE);
+ pEditor->pGlobal->pScroll->pUp_Left_Button->size.w = adj_size(122);
+ pEditor->pGlobal->pScroll->pDown_Right_Button->size.w = adj_size(122);
} else {
struct GUI *pTmp = pLast;
do {
@@ -1384,7 +1338,7 @@
/* ----------------------------- */
count = 0;
/* Targets units and imprv. to build */
- pStr = create_string16(NULL, 0, 10);
+ pStr = create_string16(NULL, 0, adj_font(10));
pStr->style |= (SF_CENTER|TTF_STYLE_BOLD);
pStr->render = 3;
pStr->bgcol = color;
@@ -1392,7 +1346,7 @@
impr_type_iterate(imp) {
can_build = can_player_build_improvement(game.player_ptr, imp);
can_eventually_build =
- could_player_eventually_build_improvement(game.player_ptr, imp);
+ can_player_eventually_build_improvement(game.player_ptr, imp);
/* If there's a city, can the city build the improvement? */
if (pCity) {
@@ -1415,10 +1369,11 @@
SDL_SetAlpha(pText_Name, 0x0, 0x0);
if (is_wonder(imp)) {
- if (wonder_obsolete(imp)) {
+ if (improvement_obsolete(game.player_ptr, imp)) {
state = _("Obsolete");
} else {
- if (game.global_wonders[imp] != 0) {
+ if ((is_great_wonder(imp) && game.info.great_wonders[imp] != 0) ||
+ (is_small_wonder(imp) && game.player_ptr->small_wonders[imp] !=
0)) {
state = _("Built");
} else {
state = _("Wonder");
@@ -1429,8 +1384,8 @@
}
if(pCity) {
- if(imp != B_CAPITAL) {
- turns = city_turns_to_build(pCity, imp, FALSE, TRUE);
+ if(imp != get_building_for_effect(EFT_PROD_TO_GOLD)) {
+ turns = city_turns_to_build(pCity, cid_production(imp), TRUE);
if (turns == FC_INFINITY) {
if(state) {
@@ -1465,11 +1420,11 @@
} else {
/* capitalization */
my_snprintf(cBuf, sizeof(cBuf), _("%d gold per turn"),
- MAX(0, pCity->shield_surplus));
+ MAX(0, pCity->surplus[O_SHIELD]));
}
} else {
/* non city mode */
- if(imp != B_CAPITAL) {
+ if(imp != get_building_for_effect(EFT_PROD_TO_GOLD)) {
if(state) {
my_snprintf(cBuf, sizeof(cBuf), _("(%s)\n%d %s"),
state, impr_build_shield_cost(imp),
@@ -1493,7 +1448,7 @@
SDL_SetAlpha(pText, 0x0, 0x0);
/*-----------------*/
- pZoom = ZoomSurface(GET_SURF(pImpr->sprite), 1.5, 1.5, 1);
+ pZoom = adj_surf(ZoomSurface(GET_SURF(get_building_sprite(tileset,
imp)), 1.5, 1.5, 1));
dst.x = (pIcon->w - pZoom->w)/2;
dst.y = (pIcon->h/2 - pZoom->h)/2;
SDL_BlitSurface(pZoom, NULL, pIcon, &dst);
@@ -1519,7 +1474,7 @@
widget_h = MAX(widget_h, pBuf->size.h);
pBuf->data.city = pCity;
- add_to_gui_list(MAX_ID - 1000 - imp, pBuf);
+ add_to_gui_list(MAX_ID - imp, pBuf);
pBuf->action = worklist_editor_targets_callback;
if(count > (TARGETS_ROW * TARGETS_COL - 1)) {
@@ -1528,7 +1483,9 @@
count++;
}
} impr_type_iterate_end;
+
/* ------------------------------ */
+
unit_type_iterate(un) {
can_build = can_player_build_unit(game.player_ptr, un);
can_eventually_build =
@@ -1544,7 +1501,7 @@
if ((advanced_tech && can_eventually_build) ||
(!advanced_tech && can_build)) {
- pUnit = get_unit_type(un);
+ pUnit = un;
pIcon = crop_rect_from_surface(pMain, NULL);
@@ -1556,7 +1513,7 @@
SDL_SetAlpha(pText_Name, 0x0, 0x0);
if (pCity) {
- turns = city_turns_to_build(pCity, un, TRUE, TRUE);
+ turns = city_turns_to_build(pCity, cid_production(un->index), TRUE);
if (turns == FC_INFINITY) {
my_snprintf(cBuf, sizeof(cBuf),
_("(%d/%d/%d)\n%d/%d %s\nnever"),
@@ -1588,7 +1545,7 @@
pText = create_text_surf_from_str16(pStr);
SDL_SetAlpha(pText, 0x0, 0x0);
- pZoom = make_flag_surface_smaler(GET_SURF(pUnit->sprite));
+ pZoom =
make_flag_surface_smaler(adj_surf(GET_SURF(get_unittype_sprite(tileset, un))));
dst.x = (pIcon->w - pZoom->w)/2;
dst.y = (pIcon->h/2 - pZoom->h)/2;
SDL_BlitSurface(pZoom, NULL, pIcon, &dst);
@@ -1613,7 +1570,7 @@
widget_h = MAX(widget_h, pBuf->size.h);
pBuf->data.city = pCity;
- add_to_gui_list(MAX_ID - un, pBuf);
+ add_to_gui_list(MAX_ID - cid_encode_unit(un), pBuf);
pBuf->action = worklist_editor_targets_callback;
if(count > (TARGETS_ROW * TARGETS_COL - 1)) {
@@ -1644,7 +1601,7 @@
pEditor->pBeginWidgetList = pEditor->pTargets->pBeginWidgetList;
/* Window */
- w = MAX(w, widget_w * TARGETS_COL + count + 130) + DOUBLE_FRAME_WH;
+ w = MAX(w, widget_w * TARGETS_COL + count + adj_size(130)) + DOUBLE_FRAME_WH;
h = MAX(h, widget_h * TARGETS_ROW) + FRAME_WH + FRAME_WH;
@@ -1664,19 +1621,22 @@
/* Backgrounds */
dst.x = FRAME_WH;
dst.y = FRAME_WH + 1;
- dst.w = 130;
- dst.h = 145;
+ dst.w = adj_size(130);
+ dst.h = adj_size(145);
+
+ c = *get_game_colorRGB(COLOR_STD_BACKGROUND_BROWN);
+
SDL_FillRect(pWindow->theme, &dst,
- get_game_color(COLOR_STD_BACKGROUND_BROWN, pWindow->theme));
+ SDL_MapRGBA(pWindow->theme->format, c.r, c.g, c.b, c.unused));
putframe(pWindow->theme, dst.x, dst.y,
dst.x + dst.w - 1, dst.y + dst.h - 1, 0xFF000000);
putframe(pWindow->theme, dst.x + 2, dst.y + 2,
dst.x + dst.w - 3, dst.y + dst.h - 3, 0xFF000000);
dst.x = FRAME_WH;
- dst.y = FRAME_WH + 150;
- dst.w = 130;
- dst.h = 228;
+ dst.y = FRAME_WH + adj_size(150);
+ dst.w = adj_size(130);
+ dst.h = adj_size(228);
color.unused = 136;
SDL_FillRectAlpha(pWindow->theme, &dst, &color);
putframe(pWindow->theme, dst.x, dst.y,
@@ -1684,83 +1644,95 @@
if(pEditor->pGlobal) {
dst.x = FRAME_WH;
- dst.y = FRAME_WH + 380;
- dst.w = 130;
- dst.h = 99;
+ dst.y = FRAME_WH + adj_size(380);
+ dst.w = adj_size(130);
+ dst.h = adj_size(99);
+
+ c = *get_game_colorRGB(COLOR_STD_BACKGROUND_BROWN);
+
SDL_FillRect(pWindow->theme, &dst,
- get_game_color(COLOR_STD_BACKGROUND_BROWN, pWindow->theme));
+ SDL_MapRGBA(pWindow->theme->format, c.r, c.g, c.b, c.unused));
putframe(pWindow->theme, dst.x, dst.y,
dst.x + dst.w - 1, dst.y + dst.h - 1, 0xFF000000);
- putframe(pWindow->theme, dst.x + 2, dst.y + 2,
- dst.x + dst.w - 3, dst.y + dst.h - 3, 0xFF000000);
+ putframe(pWindow->theme, dst.x + adj_size(2), dst.y + adj_size(2),
+ dst.x + dst.w - adj_size(3), dst.y + dst.h - adj_size(3), 0xFF000000);
}
/* name */
pBuf = pWindow->prev;
- pBuf->size.x = pWindow->size.x + (130 - pBuf->size.w)/2 + FRAME_WH;
- pBuf->size.y = pWindow->size.y + FRAME_WH + 4;
+ pBuf->size.x = pWindow->size.x + (adj_size(130) - pBuf->size.w)/2 + FRAME_WH;
+ pBuf->size.y = pWindow->size.y + FRAME_WH + adj_size(4);
/* size of worklist (without production) */
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + (130 - pBuf->size.w)/2 + FRAME_WH;
+ pBuf->size.x = pWindow->size.x + (adj_size(130) - pBuf->size.w)/2 + FRAME_WH;
pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h;
if(pCity) {
/* current build and proggrse bar */
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + (130 - pBuf->size.w)/2 + FRAME_WH;
- pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + 5;
+ pBuf->size.x = pWindow->size.x + (adj_size(130) - pBuf->size.w)/2 +
FRAME_WH;
+ pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h + adj_size(5);
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + (130 - pBuf->size.w)/2 + FRAME_WH;
+ pBuf->size.x = pWindow->size.x + (adj_size(130) - pBuf->size.w)/2 +
FRAME_WH;
pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h;
} else {
/* rename worklist */
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + (130 - pBuf->size.w)/2 + FRAME_WH;
- pBuf->size.y = pWindow->size.y + FRAME_WH + 1 + (145 - pBuf->size.h)/2;
+ pBuf->size.x = pWindow->size.x + (adj_size(130) - pBuf->size.w)/2 +
FRAME_WH;
+ pBuf->size.y = pWindow->size.y + FRAME_WH + 1 + (adj_size(145) -
pBuf->size.h)/2;
}
/* ok button */
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + (65 - pBuf->size.w)/2 + FRAME_WH;
- pBuf->size.y = pWindow->size.y + FRAME_WH + 135 - pBuf->size.h;
+ pBuf->size.x = pWindow->size.x + (adj_size(65) - pBuf->size.w)/2 + FRAME_WH;
+ pBuf->size.y = pWindow->size.y + FRAME_WH + adj_size(135) - pBuf->size.h;
/* exit button */
pBuf = pBuf->prev;
- pBuf->size.x = pWindow->size.x + 65 + (65 - pBuf->size.w)/2 + FRAME_WH;
- pBuf->size.y = pWindow->size.y + FRAME_WH + 135 - pBuf->size.h;
+ pBuf->size.x = pWindow->size.x + adj_size(65) + (adj_size(65) -
pBuf->size.w)/2 + FRAME_WH;
+ pBuf->size.y = pWindow->size.y + FRAME_WH + adj_size(135) - pBuf->size.h;
/* worklist */
- if(pCity || pWorkList->wlefs[0] != WEF_END) {
+ /* pEditor->pWork->pScroll->count: including production */
+ if(pCity || (worklist_length(pWorkList) > 0)) {
+ /* FIXME */
setup_vertical_widgets_position(1,
- pWindow->size.x + FRAME_WH + 2, pWindow->size.y + FRAME_WH + 152,
- 126, 0, pEditor->pWork->pBeginWidgetList,
+ pWindow->size.x + FRAME_WH + adj_size(2), pWindow->size.y + FRAME_WH +
adj_size(152)/* +
+ ((pEditor->pWork->pScroll->count > pEditor->pWork->pScroll->active + 2)
?
+ pEditor->pWork->pScroll->pUp_Left_Button->size.h + 1 : 0)*/,
+ adj_size(126), 0, pEditor->pWork->pBeginWidgetList,
pEditor->pWork->pEndWidgetList);
+
+ setup_vertical_scrollbar_area(pEditor->pWork->pScroll,
+ pWindow->size.x + FRAME_WH + adj_size(2),
+ pWindow->size.y + FRAME_WH + adj_size(152),
+ adj_size(225), FALSE);
}
/* global worklists */
if(pEditor->pGlobal) {
setup_vertical_widgets_position(1,
- pWindow->size.x + FRAME_WH + 4,
- pWindow->size.y + FRAME_WH + 384 +
+ pWindow->size.x + FRAME_WH + adj_size(4),
+ pWindow->size.y + FRAME_WH + adj_size(384) +
(pEditor->pGlobal->pScroll ?
pEditor->pGlobal->pScroll->pUp_Left_Button->size.h + 1 : 0),
- 122, 0, pEditor->pGlobal->pBeginWidgetList,
+ adj_size(122), 0, pEditor->pGlobal->pBeginWidgetList,
pEditor->pGlobal->pEndWidgetList);
if(pEditor->pGlobal->pScroll) {
setup_vertical_scrollbar_area(pEditor->pGlobal->pScroll,
- pWindow->size.x + FRAME_WH + 4,
- pWindow->size.y + FRAME_WH + 384,
- 93, FALSE);
+ pWindow->size.x + FRAME_WH + adj_size(4),
+ pWindow->size.y + FRAME_WH + adj_size(384),
+ adj_size(93), FALSE);
}
}
/* Targets */
setup_vertical_widgets_position(TARGETS_COL,
- pWindow->size.x + FRAME_WH + 130,
+ pWindow->size.x + FRAME_WH + adj_size(130),
pWindow->size.y + FRAME_WH,
0, 0, pEditor->pTargets->pBeginWidgetList,
pEditor->pTargets->pEndWidgetList);
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/tilespec.c
devel/client/tilespec.c
--- devel_distclean/client/tilespec.c 2005-10-21 10:14:01.000000000 +0200
+++ devel/client/tilespec.c 2005-11-15 06:52:46.000000000 +0100
@@ -413,11 +413,6 @@
int focus_unit_state = 0;
-static struct sprite* lookup_sprite_tag_alt(struct tileset *t,
- const char *tag, const char *alt,
- bool required, const char *what,
- const char *name);
-
/****************************************************************************
Return the name of the given tileset.
@@ -2359,7 +2354,7 @@
Lookup sprite to match tag, or else to match alt if don't find,
or else return NULL, and emit log message.
***********************************************************************/
-static struct sprite* lookup_sprite_tag_alt(struct tileset *t,
+struct sprite* lookup_sprite_tag_alt(struct tileset *t,
const char *tag, const char *alt,
bool required, const char *what,
const char *name)
diff -u -r -b -B -X devel/diff_ignore devel_distclean/client/tilespec.h
devel/client/tilespec.h
--- devel_distclean/client/tilespec.h 2005-10-21 10:14:01.000000000 +0200
+++ devel/client/tilespec.h 2005-11-15 06:52:46.000000000 +0100
@@ -225,6 +225,11 @@
const struct unit *punit);
struct sprite *get_basic_fog_sprite(const struct tileset *t);
+struct sprite* lookup_sprite_tag_alt(struct tileset *t,
+ const char *tag, const char *alt,
+ bool required, const char *what,
+ const char *name);
+
struct color_system;
struct color_system *get_color_system(const struct tileset *t);
--- amplio.tilespec_orig 2005-10-19 15:07:47.000000000 +0200
+++ amplio.tilespec 2005-11-15 06:52:46.000000000 +0100
@@ -52,13 +52,25 @@
; These are special because they get freed and reloaded
; as required:
main_intro_file = "misc/intro"
-minimap_intro_file = "misc/radar"
+minimap_intro_file = "deluxe/sdl/logo"
; Below, the graphics spec files; must be somewhere (anywhere) in
; the data path. Order may be important for color allocation on
; low-color systems, and if there are any duplicate tags (lattermost
; tag is used).
files =
+ "deluxe/sdl/city.spec",
+ "deluxe/sdl/city_fist.spec",
+ "deluxe/sdl/cursors_anim.spec",
+ "deluxe/sdl/dip_icons.spec",
+ "deluxe/sdl/small_theme_buttons.spec",
+ "deluxe/sdl/techs.spec",
+ "deluxe/sdl/tech_tree.spec",
+ "deluxe/sdl/theme_scrolls.spec",
+ "deluxe/sdl/theme_buttons.spec",
+ "deluxe/sdl/theme_boxs.spec",
+ "deluxe/sdl/theme_orders_buttons.spec",
+ "deluxe/icons.spec",
"amplio/terrain1.spec",
"amplio/terrain2.spec",
"amplio/tiles.spec",
--- isophex.tilespec_orig 2005-10-19 15:07:47.000000000 +0200
+++ isophex.tilespec 2005-11-15 06:52:46.000000000 +0100
@@ -60,13 +60,25 @@
; These are special because they get freed and reloaded
; as required:
main_intro_file = "misc/intro"
-minimap_intro_file = "misc/radar"
+minimap_intro_file = "deluxe/sdl/logo"
; Below, the graphics spec files; must be somewhere (anywhere) in
; the data path. Order may be important for color allocation on
; low-color systems, and if there are any duplicate tags (lattermost
; tag is used).
files =
+ "deluxe/sdl/city.spec",
+ "deluxe/sdl/dip_icons.spec",
+ "deluxe/sdl/techs.spec",
+ "deluxe/sdl/city_fist.spec",
+ "deluxe/sdl/theme_scrolls.spec",
+ "deluxe/sdl/theme_buttons.spec",
+ "deluxe/sdl/small_theme_buttons.spec",
+ "deluxe/sdl/theme_boxs.spec",
+ "deluxe/sdl/theme_orders_buttons.spec",
+ "deluxe/sdl/cursors_anim.spec",
+ "deluxe/sdl/tech_tree.spec",
+ "deluxe/icons.spec",
"misc/colors.spec",
"misc/overlays.spec",
"misc/citybar.spec",
--- isotrident.tilespec_orig 2005-10-19 15:07:47.000000000 +0200
+++ isotrident.tilespec 2005-11-15 06:52:46.000000000 +0100
@@ -49,13 +49,25 @@
; These are special because they get freed and reloaded
; as required:
main_intro_file = "misc/intro"
-minimap_intro_file = "misc/radar"
+minimap_intro_file = "deluxe/sdl/logo"
; Below, the graphics spec files; must be somewhere (anywhere) in
; the data path. Order may be important for color allocation on
; low-color systems, and if there are any duplicate tags (lattermost
; tag is used).
files =
+ "deluxe/sdl/city.spec",
+ "deluxe/sdl/city_fist.spec",
+ "deluxe/sdl/cursors_anim.spec",
+ "deluxe/sdl/dip_icons.spec",
+ "deluxe/sdl/small_theme_buttons.spec",
+ "deluxe/sdl/techs.spec",
+ "deluxe/sdl/tech_tree.spec",
+ "deluxe/sdl/theme_scrolls.spec",
+ "deluxe/sdl/theme_buttons.spec",
+ "deluxe/sdl/theme_boxs.spec",
+ "deluxe/sdl/theme_orders_buttons.spec",
+ "deluxe/icons.spec",
"misc/colors.spec",
"misc/overlays.spec",
"misc/citybar.spec",
--- trident.tilespec_orig 2005-10-19 15:07:47.000000000 +0200
+++ trident.tilespec 2005-11-15 06:52:46.000000000 +0100
@@ -49,13 +49,25 @@
; These are special because they get freed and reloaded
; as required:
main_intro_file = "misc/intro"
-minimap_intro_file = "misc/radar"
+minimap_intro_file = "deluxe/sdl/logo"
; Below, the graphics spec files; must be somewhere (anywhere) in
; the data path. Order may be important for color allocation on
; low-color systems, and if there are any duplicate tags (lattermost
; tag is used).
files =
+ "deluxe/sdl/city.spec",
+ "deluxe/sdl/city_fist.spec",
+ "deluxe/sdl/cursors_anim.spec",
+ "deluxe/sdl/dip_icons.spec",
+ "deluxe/sdl/small_theme_buttons.spec",
+ "deluxe/sdl/techs.spec",
+ "deluxe/sdl/tech_tree.spec",
+ "deluxe/sdl/theme_scrolls.spec",
+ "deluxe/sdl/theme_buttons.spec",
+ "deluxe/sdl/theme_boxs.spec",
+ "deluxe/sdl/theme_orders_buttons.spec",
+ "deluxe/icons.spec",
"misc/colors.spec",
"misc/overlays.spec",
"misc/citybar.spec",
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#14639) Patch for SDL client,
Christian Prochaska <=
|
|