[Freeciv-Dev] Re: (PR#15856) Editor: Edit nation info
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=15856 >
without the active player part to appease jason.
-mike
Index: server/srv_main.c
===================================================================
--- server/srv_main.c (revision 11757)
+++ server/srv_main.c (working copy)
@@ -1276,7 +1276,9 @@
struct nation_type *old_nation, *new_nation;
struct player *pplayer = get_player(player_no);
- if (server_state != PRE_GAME_STATE || !pplayer) {
+ if (!(requestor->current_conn->access_level == ALLOW_HACK
+ && game.info.is_edit_mode)
+ && (server_state != PRE_GAME_STATE || !pplayer)) {
return;
}
Index: common/nation.c
===================================================================
--- common/nation.c (revision 11757)
+++ common/nation.c (working copy)
@@ -396,7 +396,8 @@
bool can_conn_edit_players_nation(const struct connection *pconn,
const struct player *pplayer)
{
- return (game.info.is_new_game
- && ((!pconn->observer && pconn->player == pplayer)
- || pconn->access_level >= ALLOW_CTRL));
+ return ((pconn->access_level == ALLOW_HACK && game.info.is_edit_mode)
+ || (game.info.is_new_game
+ && ((!pconn->observer && pconn->player == pplayer)
+ || pconn->access_level >= ALLOW_CTRL)));
}
Index: client/gui-gtk-2.0/dialogs.c
===================================================================
--- client/gui-gtk-2.0/dialogs.c (revision 11757)
+++ client/gui-gtk-2.0/dialogs.c (working copy)
@@ -760,11 +760,15 @@
int i;
shell =
- gtk_dialog_new_with_buttons(_("What Nation Will You Be?"),
+ gtk_dialog_new_with_buttons(game.info.is_edit_mode
+ ? _("Edit Nation")
+ : _("What Nation Will You Be?"),
NULL,
0,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
_("Random Nation"),
- GTK_RESPONSE_CANCEL,
+ GTK_RESPONSE_NO, /* for lack of a better */
GTK_STOCK_OK,
GTK_RESPONSE_ACCEPT,
NULL);
@@ -925,8 +929,18 @@
selected_nation = -1;
/* Finish up. */
- gtk_dialog_set_default_response(GTK_DIALOG(shell), GTK_RESPONSE_ACCEPT);
+ gtk_dialog_set_default_response(GTK_DIALOG(shell), GTK_RESPONSE_CANCEL);
+ /* Don't allow ok without a selection */
+ gtk_dialog_set_response_sensitive(GTK_DIALOG(shell), GTK_RESPONSE_ACCEPT,
+ FALSE);
+ /* don't allow random nation selection in edit mode, since assigning
+ * NO_NATION while game is running is very bad */
+ if (game.info.is_edit_mode) {
+ gtk_dialog_set_response_sensitive(GTK_DIALOG(shell), GTK_RESPONSE_NO,
+ FALSE);
+ }
+
gtk_widget_show_all(GTK_DIALOG(shell)->vbox);
}
@@ -1144,6 +1158,9 @@
gtk_text_buffer_set_text(races_text, nation->legend , -1);
}
+ /* Once we've made a selection, allow user to ok */
+ gtk_dialog_set_response_sensitive(GTK_DIALOG(races_shell),
+ GTK_RESPONSE_ACCEPT, TRUE);
} else {
selected_nation = -1;
}
@@ -1212,11 +1229,8 @@
if (response == GTK_RESPONSE_ACCEPT) {
const char *s;
+ /* can this even happen? */
if (selected_nation == -1) {
- dsend_packet_nation_select_req(&aconnection,
- races_player->player_no,
- -1, FALSE, "", 0);
- popdown_races_dialog();
return;
}
@@ -1242,11 +1256,12 @@
dsend_packet_nation_select_req(&aconnection,
races_player->player_no, selected_nation,
selected_sex, s, selected_city_style);
- } else if (response == GTK_RESPONSE_CANCEL) {
+ } else if (response == GTK_RESPONSE_NO) {
dsend_packet_nation_select_req(&aconnection,
races_player->player_no,
-1, FALSE, "", 0);
}
+
popdown_races_dialog();
}
Index: client/gui-gtk-2.0/plrdlg.c
===================================================================
--- client/gui-gtk-2.0/plrdlg.c (revision 11757)
+++ client/gui-gtk-2.0/plrdlg.c (working copy)
@@ -36,6 +36,8 @@
#include "climisc.h"
#include "clinet.h"
#include "connectdlg_common.h"
+#include "dialogs.h"
+#include "editor.h"
#include "gui_main.h"
#include "gui_stuff.h"
#include "inteldlg.h"
@@ -56,6 +58,8 @@
static GtkWidget *players_war_command;
static GtkWidget *players_vision_command;
static GtkWidget *players_sship_command;
+static GtkWidget *players_edit_menu;
+static GtkWidget *players_edit_nation_command;
static GtkListStore *store;
static GtkTreeModel *model;
@@ -69,6 +73,7 @@
static void players_sship_callback(GtkMenuItem *item, gpointer data);
static void players_ai_toggle_callback(GtkMenuItem *item, gpointer data);
static void players_ai_skill_callback(GtkMenuItem *item, gpointer data);
+static void players_edit_nation_callback(GtkMenuItem *item, gpointer data);
static void update_views(void);
@@ -205,7 +210,7 @@
plr = get_player(id);
if (ev->button == 1) {
- if (can_intel_with_player(plr)) {
+ if (can_intel_with_player(plr)) {
popup_intel_dialog(plr);
}
} else {
@@ -313,6 +318,7 @@
GtkWidget *menu = gtk_menu_new();
GtkWidget *item;
+ /* index starting at one (1) here to force playername to always be shown */
for (i = 1; i < num_player_dlg_columns; i++) {
struct player_dlg_column *pcol;
@@ -508,8 +514,17 @@
gtk_widget_set_sensitive(players_sship_command, FALSE);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), players_sship_command);
+ players_edit_menu = gtk_menu_item_new_with_mnemonic(_("_Editor"));
+ gtk_menu_shell_append(GTK_MENU_SHELL(menubar), players_edit_menu);
+ gtk_widget_set_sensitive(players_edit_menu, game.info.is_edit_mode);
+ menu = gtk_menu_new();
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(players_edit_menu), menu);
+ players_edit_nation_command =
+ gtk_menu_item_new_with_mnemonic(_("_Edit Nation..."));
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), players_edit_nation_command);
+
gui_dialog_show_all(players_dialog_shell);
g_signal_connect(players_meet_command, "activate",
@@ -522,6 +537,8 @@
G_CALLBACK(players_intel_callback), NULL);
g_signal_connect(players_sship_command, "activate",
G_CALLBACK(players_sship_callback), NULL);
+ g_signal_connect(players_edit_nation_command, "activate",
+ G_CALLBACK(players_edit_nation_callback), NULL);
gtk_list_store_clear(store);
update_players_dialog();
@@ -708,6 +725,9 @@
}
} players_iterate_end;
+ /* menu needs to be updated with edit mode changes */
+ gtk_widget_set_sensitive(players_edit_menu, game.info.is_edit_mode);
+
update_players_menu();
update_views();
}
@@ -842,6 +862,23 @@
}
/**************************************************************************
+ popup the races dialog for the selected player
+**************************************************************************/
+static void players_edit_nation_callback(GtkMenuItem *item, gpointer data)
+{
+ GtkTreeModel *model;
+ GtkTreeIter it;
+
+ if (gtk_tree_selection_get_selected(players_selection, &model, &it)) {
+ gint plrno;
+
+ gtk_tree_model_get(model, &it, ncolumns - 1, &plrno, -1);
+
+ popup_races_dialog(get_player(plrno));
+ }
+}
+
+/**************************************************************************
...
**************************************************************************/
static void update_views(void)
Index: client/packhand.c
===================================================================
--- client/packhand.c (revision 11757)
+++ client/packhand.c (working copy)
@@ -1402,6 +1402,7 @@
}
update_unit_focus();
update_menus();
+ update_players_dialog();
if (update_aifill_button) {
update_start_page();
}
Index: client/plrdlg_common.c
===================================================================
--- client/plrdlg_common.c (revision 11757)
+++ client/plrdlg_common.c (working copy)
@@ -23,6 +23,7 @@
#include "support.h"
#include "climisc.h"
+#include "editor.h"
#include "text.h"
#include "plrdlg_g.h"
@@ -271,7 +272,7 @@
*******************************************************************/
int player_dlg_default_sort_column(void)
{
- return 3;
+ return 4;
}
/****************************************************************************
Index: client/editor.h
===================================================================
--- client/editor.h (revision 11757)
+++ client/editor.h (working copy)
@@ -31,6 +31,8 @@
EPAINT_LAST
};
+extern struct player *editable_player;
+
typedef void (*ToolFunction)(struct tile *ptile);
void editor_init_tools(void);
|
|