Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. *Read more...*

Feature #874767 ยป 874767-StickyGamePlayWindow-master(gtk3.22).patch

master gui-gtk-3.22 - John Robertson, 2020-05-23 07:31 AM

View differences:

client/Makefile.am
repodlgs_common.h \
reqtree.c \
reqtree.h \
saved_windows.c \
saved_windows.h \
servers.c \
servers.h \
text.c \
client/client_main.c
#include "options.h"
#include "overview_common.h"
#include "packhand.h"
#include "saved_windows.h"
#include "tilespec.h"
#include "themes_common.h"
#include "update_queue.h"
client/gui-gtk-3.22/Makefile.am
graphics.h \
gui_main.c \
gui_main.h \
gui_saved_windows.c \
gui_saved_windows.h \
gui_stuff.c \
gui_stuff.h \
happiness.c \
client/gui-gtk-3.22/gui_main.c
#endif
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
/* utility */
......
#include "control.h"
#include "editor.h"
#include "options.h"
#include "saved_windows.h"
#include "text.h"
#include "tilespec.h"
#include "zoom.h"
......
#include "editgui.h"
#include "gotodlg.h"
#include "graphics.h"
#include "gui_saved_windows.h"
#include "gui_stuff.h"
#include "happiness.h"
#include "inteldlg.h"
......
int overview_canvas_store_width = OVERVIEW_CANVAS_STORE_WIDTH;
int overview_canvas_store_height = OVERVIEW_CANVAS_STORE_HEIGHT;
GtkWidget *toplevel;
GdkWindow *root_window;
GtkWidget *toplevel = NULL;
GdkWindow *root_window = NULL;
GtkWidget *toplevel_tabs;
GtkWidget *top_vbox;
GtkWidget *top_notebook, *bottom_notebook, *right_notebook;
......
width = (overview_canvas_store_width > GUI_GTK_OVERVIEW_MIN_XSIZE) ? overview_canvas_store_width
: GUI_GTK_OVERVIEW_MIN_XSIZE;
if (GUI_GTK_OPTION(small_display_layout)) {
if (GUI_GTK_OPTION(display_layout) == GUI_GTK_LAYOUT_HORIZONTAL) {
/* We want arrow to appear if there is other units in addition
to active one in tile. Active unit is not counted, so there
can be 0 other units to not to display arrow. */
......
G_CALLBACK(select_unit_image_callback),
GINT_TO_POINTER(-1));
if (!GUI_GTK_OPTION(small_display_layout)) {
if (GUI_GTK_OPTION(display_layout) != GUI_GTK_LAYOUT_HORIZONTAL) {
/* Bottom row: other units in the same tile. */
for (i = 0; i < num_units_below; i++) {
unit_below_image[i] = gtk_image_new();
......
gdk_pixbuf_get_width(pix), -1);
g_object_unref(G_OBJECT(pix));
if (!GUI_GTK_OPTION(small_display_layout)) {
if (GUI_GTK_OPTION(display_layout) != GUI_GTK_LAYOUT_HORIZONTAL) {
/* Display on bottom row. */
gtk_grid_attach(GTK_GRID(table), more_arrow_pixmap_container,
MAX_NUM_UNITS_BELOW, 1, 1, 1);
......
unit_image_button);
g_object_unref(unit_image);
g_object_unref(unit_image_button);
if (!GUI_GTK_OPTION(small_display_layout)) {
if (GUI_GTK_OPTION(display_layout) != GUI_GTK_LAYOUT_HORIZONTAL) {
int i;
for (i = 0; i < num_units_below; i++) {
......
static void setup_widgets(void)
{
GtkWidget *page, *ebox, *hgrid, *hgrid2, *label;
GtkWidget *frame, *table, *table2, *paned, *hpaned, *sw, *text;
GtkWidget *button, *view, *vgrid, *right_vbox = NULL;
GtkWidget* frame, * table, * table2, * paned = NULL, * hpaned = NULL, * sw;
GtkWidget * text, *button, *view, *vgrid, *right_vbox = NULL;
int i;
char buf[256];
GtkWidget *notebook, *statusbar;
......
gtk_grid_set_row_spacing(GTK_GRID(top_vbox), 5);
hgrid = gtk_grid_new();
if (GUI_GTK_OPTION(small_display_layout)) {
switch (GUI_GTK_OPTION(display_layout)) {
case GUI_GTK_LAYOUT_HORIZONTAL:
/* The window is divided into two horizontal panels: overview +
* civinfo + unitinfo, main view + message window. */
right_vbox = gtk_grid_new();
......
/* Overview size designed for small displays (netbooks). */
overview_canvas_store_width = OVERVIEW_CANVAS_STORE_WIDTH_NETBOOK;
overview_canvas_store_height = OVERVIEW_CANVAS_STORE_HEIGHT_NETBOOK;
} else {
break;
case GUI_GTK_LAYOUT_VERTICAL:
/* The window is divided into two vertical panes: overview +
* + civinfo + unitinfo + main view, message window. */
paned = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
......
/* Overview size designed for big displays (desktops). */
overview_canvas_store_width = OVERVIEW_CANVAS_STORE_WIDTH;
overview_canvas_store_height = OVERVIEW_CANVAS_STORE_HEIGHT;
break;
case GUI_GTK_LAYOUT_SEPARATE:
break;
}
/* this holds the overview canvas, production info, etc. */
......
gtk_notebook_set_scrollable(GTK_NOTEBOOK(top_notebook), TRUE);
if (GUI_GTK_OPTION(small_display_layout)) {
if (GUI_GTK_OPTION(display_layout)==GUI_GTK_LAYOUT_HORIZONTAL) {
gtk_paned_pack1(GTK_PANED(paned), top_notebook, TRUE, FALSE);
} else if (GUI_GTK_OPTION(message_chat_location) == GUI_GTK_MSGCHAT_MERGED) {
right_vbox = gtk_grid_new();
......
vgrid = gtk_grid_new();
gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
GTK_ORIENTATION_VERTICAL);
if (!GUI_GTK_OPTION(small_display_layout)) {
if (GUI_GTK_OPTION(display_layout)!=GUI_GTK_LAYOUT_HORIZONTAL) {
gtk_container_add(GTK_CONTAINER(vgrid), ingame_votebar);
}
gtk_container_add(GTK_CONTAINER(avbox), vgrid);
if (GUI_GTK_OPTION(small_display_layout)) {
switch(GUI_GTK_OPTION(display_layout)){
case GUI_GTK_LAYOUT_HORIZONTAL:
hpaned = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
} else {
break;
case GUI_GTK_LAYOUT_VERTICAL:
hpaned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
break;
case GUI_GTK_LAYOUT_SEPARATE:
break;
}
gtk_container_add(GTK_CONTAINER(vgrid), hpaned);
g_object_set(hpaned, "margin", 4, NULL);
......
MIGRATE_OPTION(metaserver_tab_first);
MIGRATE_OPTION(allied_chat_only);
MIGRATE_OPTION(message_chat_location);
MIGRATE_OPTION(small_display_layout);
GUI_GTK_OPTION(display_layout) = gui_options.gui_gtk3_small_display_layout
? GUI_GTK_LAYOUT_HORIZONTAL : GUI_GTK_LAYOUT_VERTICAL;
MIGRATE_OPTION(mouse_over_map_focus);
MIGRATE_OPTION(chatline_autocompletion);
MIGRATE_OPTION(citydlg_xsize);
......
GUI_GTK_OPTION(migrated_from_gtk3) = TRUE;
}
static gboolean ui_main_gtk_signals(GtkWidget *widget, GdkEventWindowState *event, gpointer data)
{
if (data != NULL) {
*(int*)data = (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN);
}
return TRUE;
}
/**********************************************************************//**
Called from client_main(), is what it's named.
**************************************************************************/
......
toplevel = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(toplevel), GTK_WIN_POS_CENTER);
if (vmode.width > 0 && vmode.height > 0) {
gtk_window_resize(GTK_WINDOW(toplevel), vmode.width, vmode.height);
}
//if (vmode.width > 0 && vmode.height > 0) {
// gtk_window_resize(GTK_WINDOW(toplevel), vmode.width, vmode.height);
// log_normal("vmode window size at (%d,%d)", vmode.width, vmode.height);
//}
g_signal_connect(toplevel, "key_press_event",
G_CALLBACK(toplevel_handler), NULL);
......
gtk_window_fullscreen(GTK_WINDOW(toplevel));
}
g_signal_connect(GTK_WINDOW(toplevel), "window-state-event", G_CALLBACK(ui_main_gtk_signals), &GUI_GTK_OPTION(fullscreen));
gtk_window_set_title(GTK_WINDOW (toplevel), _("Freeciv"));
g_signal_connect(toplevel, "delete_event",
......
} options_iterate_end;
toplevel_font_name = pango_context_get_font_description(
gtk_widget_get_pango_context(toplevel));
gtk_widget_get_pango_context(toplevel));
if (NULL == city_names_style) {
city_names_style = pango_font_description_copy(toplevel_font_name);
......
spaceship_dialog_init();
chatline_init();
init_mapcanvas_and_overview();
read_saved_windows();
tileset_use_preferred_theme(tileset);
......
gtk_main();
gui_up = FALSE;
if (!GUI_GTK_OPTION(fullscreen)) {
switch (get_current_client_page()) {
case PAGE_GAME:
gui_capture_saved_window(SAVED_GAMEPLAY_WINDOW);
break;
default:
gui_capture_saved_window(SAVED_STARTUP_WINDOW);
break;
}
}
write_saved_windows();
destroy_server_scans();
free_mapcanvas_and_overview();
spaceship_dialog_done();
......
if (scr_height < 1024) {
/* This is a small display */
log_verbose("Defaulting to small widget layout due to small screen");
GUI_GTK_OPTION(small_display_layout) = TRUE;
GUI_GTK_OPTION(display_layout) = GUI_GTK_LAYOUT_HORIZONTAL;
log_verbose("Defaulting to merged messages/chat due to small screen");
GUI_GTK_OPTION(message_chat_location) = GUI_GTK_MSGCHAT_MERGED;
} else {
GUI_GTK_OPTION(display_layout) = GUI_GTK_LAYOUT_VERTICAL;
}
}
}
client/gui-gtk-3.22/gui_saved_windows.c
/***********************************************************************
Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
***********************************************************************/
#include "fc_prehdrs.h"
#include "fc_types.h"
#include "fc_config.h"
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include "saved_windows.h"
#include "gui_saved_windows.h"
#include "gui_main.h"
/**********************************************************************//**
Apply a saved window's position and size.
**************************************************************************/
void apply_saved_window(GdkWindow* window, int index)
{
if (index < 0 || index >= NUM_SAVED_WINDOWS) {
log_warn("index out of bounds in apply_saved_window");
return;
}
if (!((!gui_options.saved_windows[index].x
|| gui_options.saved_windows[index].x == -1)
&& (!gui_options.saved_windows[index].y
|| gui_options.saved_windows[index].y == -1)
&& (!gui_options.saved_windows[index].width
|| gui_options.saved_windows[index].width == -1)
&& (!gui_options.saved_windows[index].height
|| gui_options.saved_windows[index].height == -1))) {
gdk_window_move_resize(window,
gui_options.saved_windows[index].x,
gui_options.saved_windows[index].y,
gui_options.saved_windows[index].width,
gui_options.saved_windows[index].height);
log_normal("setting window geometry (%3d,%3d,%3d,%3d)",
gui_options.saved_windows[index].x,
gui_options.saved_windows[index].y,
gui_options.saved_windows[index].width,
gui_options.saved_windows[index].height);
} else log_normal("window geometry not set (%3d,%3d,%3d,%3d)",
gui_options.saved_windows[index].x,
gui_options.saved_windows[index].y,
gui_options.saved_windows[index].width,
gui_options.saved_windows[index].height);
}
/**********************************************************************//**
Capture a saved window's position and size.
**************************************************************************/
void capture_saved_window(GdkWindow* window, int index)
{
if (index < 0 || index >= NUM_SAVED_WINDOWS) {
log_warn("index out of bounds in capture_saved_window");
return;
}
GdkRectangle rect;
gdk_window_get_frame_extents(window, &rect);
gdk_window_get_geometry(window,
&gui_options.saved_windows[index].x,
&gui_options.saved_windows[index].y,
&gui_options.saved_windows[index].width,
&gui_options.saved_windows[index].height);
gui_options.saved_windows[index].x = rect.x;
gui_options.saved_windows[index].y = rect.y;
//gui_options.saved_windows[index].width = rect.width;
//gui_options.saved_windows[index].height = rect.height;
log_normal("getting window geometry (%3d,%3d,%3d,%3d)",
gui_options.saved_windows[index].x,
gui_options.saved_windows[index].y,
gui_options.saved_windows[index].width,
gui_options.saved_windows[index].height);
}
/**********************************************************************//**
Apply a saved window's position and size.
**************************************************************************/
void gui_apply_saved_window(int index)
{
log_normal("gui_apply_saved_window(%d)", index);
switch (index) {
case SAVED_STARTUP_WINDOW:
case SAVED_GAMEPLAY_WINDOW:
if (root_window != NULL) {
if (!GUI_GTK_OPTION(fullscreen)) {
apply_saved_window(root_window, index);
}
}
break;
}
}
/**********************************************************************//**
Capture a saved window's position and size.
**************************************************************************/
void gui_capture_saved_window(int index)
{
log_normal("gui_capture_saved_window(%d)", index);
switch (index) {
case SAVED_STARTUP_WINDOW:
case SAVED_GAMEPLAY_WINDOW:
if (root_window != NULL) {
if (!GUI_GTK_OPTION(fullscreen)) {
capture_saved_window(root_window, index);
}
}
break;
}
}
client/gui-gtk-3.22/gui_saved_windows.h
/***********************************************************************
Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
***********************************************************************/
#ifndef FC__GUI_SAVED_WINDOWS_H
#define FC__GUI_SAVED_WINDOWS_H
void apply_saved_window(GdkWindow* window, int index);
void capture_saved_window(GdkWindow* window, int index);
#endif /* FC__GUI_SAVED_WINDOWS_H */
client/gui-gtk-3.22/gui_stuff.c
gtk_grid_set_column_spacing(GTK_GRID(action_area), 4);
if (GUI_GTK_OPTION(enable_tabs)
&& (check_top && notebook != GTK_NOTEBOOK(top_notebook))
&& !GUI_GTK_OPTION(small_display_layout)) {
&& GUI_GTK_OPTION(display_layout) != GUI_GTK_LAYOUT_HORIZONTAL) {
/* We expect this to be short (as opposed to tall); maximise usable
* height by putting buttons down the right hand side */
gtk_orientable_set_orientation(GTK_ORIENTABLE(action_area),
client/gui-gtk-3.22/mapview.c
}
gtk_label_set_text(GTK_LABEL(main_label_info),
get_info_label_text(!GUI_GTK_OPTION(small_display_layout)));
get_info_label_text(
GUI_GTK_OPTION(display_layout) != GUI_GTK_LAYOUT_HORIZONTAL));
set_indicator_icons(client_research_sprite(),
client_warming_sprite(),
client/gui-gtk-3.22/menu.c
#include "control.h"
#include "mapview_common.h"
#include "options.h"
#include "saved_windows.h"
#include "tilespec.h"
/* client/gui-gtk-3.22 */
......
#include "plrdlg.h"
#include "ratesdlg.h"
#include "repodlgs.h"
#include "gui_saved_windows.h"
#include "sprite.h"
#include "spaceshipdlg.h"
#include "unitselect.h"
......
GUI_GTK_OPTION(fullscreen) ^= 1;
if (GUI_GTK_OPTION(fullscreen)) {
gui_capture_saved_window(SAVED_GAMEPLAY_WINDOW);
gtk_window_fullscreen(GTK_WINDOW(toplevel));
} else {
gtk_window_unfullscreen(GTK_WINDOW(toplevel));
gui_apply_saved_window(SAVED_GAMEPLAY_WINDOW);
}
}
}
client/gui-gtk-3.22/messagewin.c
col = gtk_tree_view_column_new_with_attributes(NULL, renderer,
"pixbuf", MESWIN_COL_ICON, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
gtk_tree_view_column_set_visible(col, !GUI_GTK_OPTION(small_display_layout));
gtk_tree_view_column_set_visible(col,
GUI_GTK_OPTION(display_layout) != GUI_GTK_LAYOUT_HORIZONTAL);
renderer = gtk_cell_renderer_text_new();
col = gtk_tree_view_column_new_with_attributes(NULL, renderer,
client/gui-gtk-3.22/pages.c
#include "clinet.h"
#include "connectdlg_common.h"
#include "packhand.h"
#include "saved_windows.h"
#include "servers.h"
#include "update_queue.h"
......
#include "optiondlg.h"
#include "plrdlg.h" /* get_flag() */
#include "repodlgs.h"
#include "gui_saved_windows.h"
#include "voteinfo_bar.h"
#include "pages.h"
......
break;
case PAGE_GAME:
{
struct video_mode *vmode = resolution_request_get();
//struct video_mode *vmode = resolution_request_get();
enable_menus(FALSE);
if (vmode == NULL) {
gtk_window_unmaximize(GTK_WINDOW(toplevel));
}
//if (vmode == NULL) {
// gtk_window_unmaximize(GTK_WINDOW(toplevel));
//}
gui_capture_saved_window(SAVED_GAMEPLAY_WINDOW);
gui_apply_saved_window(SAVED_STARTUP_WINDOW);
}
break;
default:
......
break;
case PAGE_GAME:
{
struct video_mode *vmode = resolution_request_get();
//struct video_mode *vmode = resolution_request_get();
reset_unit_table();
enable_menus(TRUE);
if (vmode == NULL) {
gtk_window_maximize(GTK_WINDOW(toplevel));
}
//if (vmode == NULL) {
// gtk_window_maximize(GTK_WINDOW(toplevel));
//}
gui_capture_saved_window(SAVED_STARTUP_WINDOW);
gui_apply_saved_window(SAVED_GAMEPLAY_WINDOW);
voteinfo_gui_update();
mapview_freeze();
}
client/options.c
.gui_gtk3_22_metaserver_tab_first = FALSE,
.gui_gtk3_22_allied_chat_only = FALSE,
.gui_gtk3_22_message_chat_location = GUI_GTK_MSGCHAT_SEPARATE,
.gui_gtk3_22_small_display_layout = FALSE,
.gui_gtk3_22_display_layout = GUI_GTK_LAYOUT_HORIZONTAL,
.gui_gtk3_22_mouse_over_map_focus = FALSE,
.gui_gtk3_22_chatline_autocompletion = TRUE,
.gui_gtk3_22_citydlg_xsize = GUI_GTK3_22_CITYDLG_DEFAULT_XSIZE,
......
? names + value : NULL);
}
/************************************************************************//**
GTK display layout setting names accessor.
****************************************************************************/
static const struct copt_val_name
* gui_gtk_display_layout_names(int value)
{
/* Order must match enum GUI_GTK_LAYOUT_* */
static const struct copt_val_name names[] = {
{ "HORIZONTAL", N_("Horizontal") },
{ "VERTICAL", N_("Vertical") },
{ "SEPARATE", N_("Separate") }
};
return (0 <= value && value < ARRAY_SIZE(names)
? names + value : NULL);
}
/************************************************************************//**
Popup tech help setting names accessor.
****************************************************************************/
......
"tabs alongside the map and other reports; this "
"allows a larger map view on small screens.\n"
"This option requires a restart in order to take "
"effect."), COC_INTERFACE, GUI_GTK3_22,
GUI_GTK_MSGCHAT_SEPARATE,
"effect."),
COC_INTERFACE, GUI_GTK3_22, GUI_GTK_MSGCHAT_SEPARATE,
gui_gtk_message_chat_location_name, NULL),
GEN_BOOL_OPTION(gui_gtk3_22_small_display_layout,
N_("Arrange widgets for small displays"),
N_("If this option is enabled, widgets in the main "
"window will be arranged so that they take up the "
"least amount of total screen space. Specifically, "
"the left panel containing the overview, player "
"status, and the unit information box will be "
"extended over the entire left side of the window. "
GEN_ENUM_OPTION(gui_gtk3_22_display_layout,
N_("Arrangement of widgets"),
N_("'Horizontal', best for small displays, places map "
"control and overview widgets, horizontally above the "
"map in the main window.\n"
"'Vertical', places map control and overview widgets "
"vertically to the left of the map in the main window.\n"
"'Separate' tears off each widget and remembers their "
"previous placements.\n"
"This option requires a restart in order to take "
"effect."), COC_INTERFACE, GUI_GTK3_22, FALSE, NULL),
"effect."),
COC_INTERFACE, GUI_GTK3_22, GUI_GTK_LAYOUT_VERTICAL,
gui_gtk_display_layout_names, NULL),
GEN_BOOL_OPTION(gui_gtk3_22_mouse_over_map_focus,
N_("Mouse over the map widget selects it automatically"),
N_("If this option is enabled, then the map will be "
......
Set in allow_digital_boolean if we should look for old boolean values
(saved as 0 and 1), so if the rc file version is older than 2.3.0.
****************************************************************************/
static const char *get_last_option_file_name(bool *allow_digital_boolean)
const char *get_last_option_file_name(bool *allow_digital_boolean)
{
static char name_buffer[256];
const char *name;
client/options.h
GUI_GTK_MSGCHAT_MERGED
};
enum {
/* Order must match strings in
* options.c:gui_gtk_display_layout_names() */
GUI_GTK_LAYOUT_HORIZONTAL,
GUI_GTK_LAYOUT_VERTICAL,
GUI_GTK_LAYOUT_SEPARATE
};
enum {
/* Order must match strings in
* options.c:gui_popup_tech_help_name() */
......
OLAYER_COUNT
};
enum {
SAVED_STARTUP_WINDOW,
SAVED_GAMEPLAY_WINDOW,
NUM_SAVED_WINDOWS /* must match number of saved_window_names[]
* in saved_windows.c */
};
struct rectangle {
int x;
int y;
int width;
int height;
};
/* Holds all information about the overview aka minimap. */
struct overview {
/* The following fields are controlled by mapview_common.c. */
......
bool zoom_set;
float zoom_default_level;
char display_settings_file[2048];
struct rectangle saved_windows[NUM_SAVED_WINDOWS];
/* gui-gtk-2.0 client specific options.
* These are still kept just so users can migrate them to gtk3-client */
#define FC_GTK2_DEFAULT_THEME_NAME "Freeciv"
......
bool gui_gtk3_22_metaserver_tab_first;
bool gui_gtk3_22_allied_chat_only;
int gui_gtk3_22_message_chat_location; /* enum GUI_GTK_MSGCHAT_* */
bool gui_gtk3_22_small_display_layout;
int gui_gtk3_22_display_layout; /* enum GUI_GTK_LAYOUT_* */
bool gui_gtk3_22_mouse_over_map_focus;
bool gui_gtk3_22_chatline_autocompletion;
int gui_gtk3_22_citydlg_xsize;
......
/* Common option functions. */
const char* get_last_option_file_name(bool* allow_digital_boolean);
const struct option_set *option_optset(const struct option *poption);
int option_number(const struct option *poption);
#define option_index option_number
client/saved_windows.c
/***********************************************************************
Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
***********************************************************************/
#include "fc_prehdrs.h"
#include "fc_types.h"
#include "fc_config.h"
#include "saved_windows.h"
const char* const DISPLAY = "display";
const char* const saved_window_names[NUM_SAVED_WINDOWS] = {
N_("startup")
,N_("gameplay")
};
/**********************************************************************//**
Read saved window positions and sizes from the previous run and store in
the global gui_options area for use by the saved windows when needed.
See options.h for saved window names and defines.
**************************************************************************/
void read_saved_windows(void)
{
int i;
struct section_file* sf = NULL;
bool allow_digital_boolean;
const char* name = get_last_option_file_name(&allow_digital_boolean);
if (name) {
fc_strlcpy(gui_options.display_settings_file, name,
sizeof(gui_options.display_settings_file));
char* p = strrchr(gui_options.display_settings_file,
DIR_SEPARATOR_CHAR);
if (p) {
*p = '\0';
log_verbose("creating directory for display settings file '%s'",
gui_options.display_settings_file);
make_dir(gui_options.display_settings_file);
*p = DIR_SEPARATOR_CHAR;
}
fc_strlcat(gui_options.display_settings_file, ".",
sizeof(gui_options.display_settings_file));
fc_strlcat(gui_options.display_settings_file, DISPLAY,
sizeof(gui_options.display_settings_file));
if ((sf = secfile_load(gui_options.display_settings_file, TRUE))) {
secfile_allow_digital_boolean(sf, allow_digital_boolean);
for (i = 0; i < NUM_SAVED_WINDOWS; i++) {
gui_options.saved_windows[i].x =
secfile_lookup_int_default(sf, -1, "%s.x",
saved_window_names[i]);
gui_options.saved_windows[i].y =
secfile_lookup_int_default(sf, -1, "%s.y",
saved_window_names[i]);
gui_options.saved_windows[i].width =
secfile_lookup_int_default(sf, -1, "%s.width",
saved_window_names[i]);
gui_options.saved_windows[i].height =
secfile_lookup_int_default(sf, -1, "%s.height",
saved_window_names[i]);
}
} else {
log_error("failed to open display settings file '%s'",
gui_options.display_settings_file);
}
} else {
log_error("no display settings file to open");
gui_options.display_settings_file[0] = '\0';
for (i = 0; i < NUM_SAVED_WINDOWS; i++) {
gui_options.saved_windows[i].x = -1;
gui_options.saved_windows[i].y = -1;
gui_options.saved_windows[i].width = -1;
gui_options.saved_windows[i].height = -1;
}
}
if (sf != NULL) {
secfile_destroy(sf);
}
}
/**********************************************************************//**
Write saved window positions and sizes for this run. Saved windows are
expected to keep their position and sizes up to date in the global
gui_options.saved_windows[] array. Saved windows that are attached and not
floating should have sizes and positions of -1. Saved windows that are
hidden should have sizes and positions of 0.
See options.h for saved window names and defines.
**************************************************************************/
void write_saved_windows(void)
{
if (gui_options.display_settings_file[0]) {
struct section_file* sf = secfile_new(FALSE);
if (sf != NULL) {
secfile_insert_str(sf, VERSION_STRING, "client.version");
for (int i = 0; i < NUM_SAVED_WINDOWS; i++) {
secfile_insert_int(sf, gui_options.saved_windows[i].x, "%s.x",
saved_window_names[i]);
secfile_insert_int(sf, gui_options.saved_windows[i].y, "%s.y",
saved_window_names[i]);
secfile_insert_int(sf, gui_options.saved_windows[i].width,
"%s.width", saved_window_names[i]);
secfile_insert_int(sf, gui_options.saved_windows[i].height,
"%s.height", saved_window_names[i]);
if (!secfile_save(sf, gui_options.display_settings_file, 0, FZ_PLAIN)) {
log_error("failed writing display settings to '%s'",
gui_options.display_settings_file);
} else {
log_verbose("failed writing display settings to '%s'",
gui_options.display_settings_file);
}
}
secfile_destroy(sf);
} else {
log_error("failed initializing display settings file to write");
}
}
}
client/saved_windows.h
/***********************************************************************
Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
***********************************************************************/
#ifndef FC__SAVED_WINDOWS_H
#define FC__SAVED_WINDOWS_H
#include "options.h"
const char* const saved_window_names[NUM_SAVED_WINDOWS];
void read_saved_windows(void);
void write_saved_windows(void);
void gui_apply_saved_window(int index);
void gui_capture_saved_window(int index);
#endif /* FC__SAVED_WINDOWS_H */
common/effects.c
const struct impr_type *building,
enum effect_type effect_type)
{
if (!initialized) {
if (!initialized || NULL == pcity || NULL == building) {
return 0;
}
fc_assert_ret_val(NULL != pcity && NULL != building, 0);
return get_target_bonus_effects(NULL,
city_owner(pcity), NULL, pcity,
building,
NULL, NULL, NULL, NULL,
return get_target_bonus_effects(NULL, city_owner(pcity), NULL, pcity,
building, NULL, NULL, NULL, NULL,
NULL, NULL, effect_type);
}
    (1-1/1)