[Freeciv-Dev] (PR#10786) AI level control
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10786 >
> [vasc - Sat Oct 30 02:00:56 2004]:
>
> On Fri, 29 Oct 2004, Christian Knoke wrote:
>
> > <URL: http://rt.freeciv.org/Ticket/Display.html?id=10786 >
> >
> > CVS 29 OCT 2004 S2_0 GTK2
> >
> > I cannot change AI levels during a game, from server options dialog.
> >
> > This is the most-used option, I'd say.
>
> How about adding this to the players dialog menus?
And here is a patch.
Index: client/gui-gtk-2.0/plrdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/plrdlg.c,v
retrieving revision 1.41
diff -u -r1.41 plrdlg.c
--- client/gui-gtk-2.0/plrdlg.c 1 Nov 2004 19:05:38 -0000 1.41
+++ client/gui-gtk-2.0/plrdlg.c 9 Nov 2004 19:15:38 -0000
@@ -35,6 +35,7 @@
#include "civclient.h"
#include "climisc.h"
#include "clinet.h"
+#include "connectdlg_common.h"
#include "gui_main.h"
#include "gui_stuff.h"
#include "inteldlg.h"
@@ -63,6 +64,8 @@
static void players_vision_callback(GtkMenuItem *item, gpointer data);
static void players_intel_callback(GtkMenuItem *item, gpointer data);
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 update_views(void);
@@ -110,7 +113,7 @@
gint plrno;
gtk_tree_model_get(model, &it, (num_player_dlg_columns+1), &plrno, -1);
- plr = &game.players[plrno];
+ plr = get_player(plrno);
if (plr->spaceship.state != SSHIP_NONE) {
gtk_widget_set_sensitive(players_sship_command, TRUE);
@@ -378,6 +381,30 @@
gtk_widget_set_sensitive(players_sship_command, FALSE);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), players_sship_command);
+
+ item = gtk_menu_item_new_with_mnemonic(_("_AI"));
+ gtk_menu_shell_append(GTK_MENU_SHELL(menubar), item);
+
+ menu = gtk_menu_new();
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
+
+ item = gtk_menu_item_new_with_mnemonic(_("_Toggle AI Mode"));
+ g_signal_connect(item, "activate",
+ G_CALLBACK(players_ai_toggle_callback), NULL);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+
+ sep = gtk_separator_menu_item_new();
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep);
+
+ for (i = 0; i < NUM_SKILL_LEVELS; i++) {
+ item = gtk_menu_item_new_with_label(_(skill_level_names[i]));
+ g_signal_connect(item, "activate",
+ G_CALLBACK(players_ai_skill_callback), GUINT_TO_POINTER(i));
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+ }
+ gtk_widget_show_all(menu);
+
+
item = gtk_menu_item_new_with_mnemonic(_("S_how"));
menu = create_show_menu();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
@@ -657,6 +684,46 @@
}
/**************************************************************************
+ AI toggle callback.
+**************************************************************************/
+static void players_ai_toggle_callback(GtkMenuItem *item, gpointer data)
+{
+ GtkTreeModel *model;
+ GtkTreeIter it;
+
+ if (gtk_tree_selection_get_selected(players_selection, &model, &it)) {
+ gint plrno;
+ char buf[512];
+
+ gtk_tree_model_get(model, &it, (num_player_dlg_columns+1), &plrno, -1);
+
+ my_snprintf(buf, sizeof(buf), "/aitoggle %s", get_player(plrno)->name);
+ send_chat(buf);
+ }
+}
+
+/**************************************************************************
+ AI skill level setting callback.
+**************************************************************************/
+static void players_ai_skill_callback(GtkMenuItem *item, gpointer data)
+{
+ GtkTreeModel *model;
+ GtkTreeIter it;
+
+ if (gtk_tree_selection_get_selected(players_selection, &model, &it)) {
+ gint plrno;
+ char buf[512];
+
+ gtk_tree_model_get(model, &it, (num_player_dlg_columns+1), &plrno, -1);
+
+ my_snprintf(buf, sizeof(buf), "/%s %s",
+ skill_level_names[GPOINTER_TO_UINT(data)],
+ get_player(plrno)->name);
+ send_chat(buf);
+ }
+}
+
+/**************************************************************************
...
**************************************************************************/
static void update_views(void)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#10786) AI level control,
Vasco Alexandre da Silva Costa <=
|
|