Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2000:
[Freeciv-Dev] PATCH: gui-mui shared vision add
Home

[Freeciv-Dev] PATCH: gui-mui shared vision add

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] PATCH: gui-mui shared vision add
From: Dirk Stoecker <stoecker@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 19 Sep 2000 11:33:37 +0200 (MET DST)

Hi,

- Added missing _() to one of the GTK-vision texts (diplodlg.c).
  Wouldn't it be better to disable the buttons like for XAW and MUI
  instead of displaying an "did not add text"?
- Added #include <time.h> to common/connection.h.
- Added shared vision support to gui-mui client.
  Anyone using gui-mui please test this as well and tell me result.
- GUI-MUI: Also without embassy pacts can be cancelled now.

P.S. Still needing some locale aware sprintf function for MUI client.

Ciao
 ____  _ _  ____  _ _    _ _  ____
|    |  |  |    |  | \  / |  |    | the cool Gremlin from Bischofswerda
|  __   |   ____|  |  \/  |  |    | WWW: http://home.pages.de/~stoecker/
|    |  |  |       |      |  |    | PGP key available on www page.
|____| _|_ |____| _|_    _|_ |____| I hope AMIGA never ends to make fun!

************************************************************************
* snail-mail: Dirk Stoecker              * e-mail:                     *
*             Geschwister-Scholl-Str. 10 * stoecker@xxxxxxxxxxxxxx     *
*             01877 Bischofswerda        * phone:                      *
*             GERMANY                    * GERMANY +49 (0)3594/706666  *
************************************************************************
diff -ur ../../freeciv-cvs/freeciv/client/gui-gtk/diplodlg.c 
./client/gui-gtk/diplodlg.c
--- ../../freeciv-cvs/freeciv/client/gui-gtk/diplodlg.c Tue Sep 19 08:43:55 2000
+++ ./client/gui-gtk/diplodlg.c Tue Sep 19 09:14:26 2000
@@ -779,8 +779,8 @@
   struct player *pgiver;
 
   if (!has_capability("shared_vision", aconnection.capability)) {
-    append_output_window("clause not added as the server does not"
-                        "have the capability");
+    append_output_window(_("clause not added as the server does not"
+                        "have the capability"));
     return;
   }
 
diff -ur ../../freeciv-cvs/freeciv/client/gui-mui/diplodlg.c 
./client/gui-mui/diplodlg.c
--- ../../freeciv-cvs/freeciv/client/gui-mui/diplodlg.c Tue Sep 19 08:43:57 2000
+++ ./client/gui-mui/diplodlg.c Tue Sep 19 09:58:32 2000
@@ -73,6 +73,8 @@
   Object *plr1_thumb_sprite;
   Object *plr0_gold_integer;
   Object *plr1_gold_integer;
+  Object *plr0_vision_button;
+  Object *plr1_vision_button;
   Object *plr0_pacts_button;
   Object *plr0_pacts_menu;
 };
@@ -441,6 +443,23 @@
 }
 
 /****************************************************************
+ Callback for the vision button
+*****************************************************************/
+void diplomacy_vision(struct Diplomacy_data *data)
+{
+  struct Diplomacy_dialog *pdialog = data->pdialog;
+  struct packet_diplomacy_info pa;
+
+  pa.plrno0 = pdialog->treaty.plr0->player_no;
+  pa.plrno1 = pdialog->treaty.plr1->player_no;
+  pa.clause_type = CLAUSE_VISION;
+  pa.plrno_from = data->playerno;
+  pa.value = 0;
+  send_packet_diplomacy_info(&aconnection, PACKET_DIPLOMACY_CREATE_CLAUSE,
+                            &pa);
+}
+
+/****************************************************************
  Creates the diplomacy dialog between two players
 *****************************************************************/
 struct Diplomacy_dialog *create_diplomacy_dialog(struct player *plr0, 
@@ -471,6 +490,7 @@
                       Child, plr0_gold_text = TextObject, End,
                       Child, pdialog->plr0_gold_integer = MakeInteger(NULL),
                       End,
+                  Child, pdialog->plr0_vision_button = MakeButton(_("Give 
shared vision")),
                   Child, pdialog->plr0_pacts_button = MakeButton(_("Pacts")),
                   Child, HVSpace,
                   End,
@@ -505,6 +525,7 @@
                       Child, plr1_gold_text = TextObject, End,
                       Child, pdialog->plr1_gold_integer = MakeInteger(NULL),
                       End,
+                  Child, pdialog->plr1_vision_button = MakeButton(_("Give 
shared vision")),
                   Child, HVSpace,
                   End,
               End,
@@ -637,6 +658,14 @@
              get_ruler_title(plr1->government,plr1->is_male,plr1->nation),
              plr1->name);
 
+    if(!has_capability("shared_vision", aconnection.capability))
+    {
+      set(pdialog->plr0_vision_button, MUIA_Disabled, TRUE);
+      set(pdialog->plr1_vision_button, MUIA_Disabled, TRUE);
+    }
+
+    DoMethod(pdialog->plr0_vision_button, MUIM_Notify, MUIA_Pressed,FALSE, 
app,5,MUIM_CallHook, &civstandard_hook, diplomacy_vision, pdialog, 
plr0->player_no);
+    DoMethod(pdialog->plr1_vision_button, MUIM_Notify, MUIA_Pressed,FALSE, 
app,5,MUIM_CallHook, &civstandard_hook, diplomacy_vision, pdialog, 
plr1->player_no);
     DoMethod(pdialog->wnd, MUIM_Notify, 
MUIA_Window_CloseRequest,TRUE,app,4,MUIM_CallHook, &civstandard_hook, 
diplomacy_close,pdialog);
     DoMethod(accept_treaty, MUIM_Notify, MUIA_Pressed,FALSE, 
app,4,MUIM_CallHook, &civstandard_hook, diplomacy_accept_treaty,pdialog);
     DoMethod(cancel_meeting, MUIM_Notify, MUIA_Pressed,FALSE, 
app,4,MUIM_CallHook, &civstandard_hook, diplomacy_close,pdialog);
diff -ur ../../freeciv-cvs/freeciv/client/gui-mui/plrdlg.c 
./client/gui-mui/plrdlg.c
--- ../../freeciv-cvs/freeciv/client/gui-mui/plrdlg.c   Tue Sep 19 08:43:57 2000
+++ ./client/gui-mui/plrdlg.c   Tue Sep 19 10:22:13 2000
@@ -52,6 +52,7 @@
 STATIC Object *player_intelligence_button;
 STATIC Object *player_meet_button;
 STATIC Object *player_war_button;
+STATIC Object *player_vision_button;
 STATIC Object *player_spaceship_button;
 STATIC struct Hook player_players_disphook;
 
@@ -72,7 +73,6 @@
                             &pa);
 }
 
-
 /******************************************************************
  Turn off updating of player dialog
 *******************************************************************/
@@ -103,7 +103,6 @@
   }
 }
 
-
 /****************************************************************
  Display function for the players listview
 *****************************************************************/
@@ -170,6 +169,7 @@
     *array++ = get_nation_name(game.players[i].nation);
     *array++ = get_embassy_status(game.player_ptr, &game.players[i]);
     *array++ = dsbuf;
+    *array++ = get_vision_status(game.player_ptr, &game.players[i]);
     *array++ = repbuf;
     *array++ = statebuf;
     *array++ = (char*)player_addr_hack(&game.players[i]);  /* Fixme */
@@ -181,6 +181,7 @@
     *array++ = _("Nation");
     *array++ = _("Embassy");
     *array++ = _("Dipl.State");
+    *array++ = _("Vision");
     *array++ = _("Reputation");
     *array++ = _("State");
     *array++ = _("Host");
@@ -220,6 +221,11 @@
            break;
     }
 
+    if(game.player_ptr->gives_shared_vision & (1<<pplayer->player_no))
+      set(player_vision_button, MUIA_Disabled, FALSE);
+    else
+      set(player_vision_button, MUIA_Disabled, TRUE);
+
     if (pplayer->is_alive && player_has_embassy(game.player_ptr, pplayer))
     {
       if (pplayer->is_connected)
@@ -283,17 +289,27 @@
   LONG playerno;
   DoMethod(player_players_listview, MUIM_NList_GetEntry, 
MUIV_NList_GetEntry_Active, &playerno);
 
-  if (playerno)
+  if(playerno)
   {
-    playerno -= 100;
+    struct packet_generic_integer pa;
+    pa.value = playerno - 100;
+    send_packet_generic_integer(&aconnection, PACKET_PLAYER_CANCEL_PACT, &pa);
+  }
+}
 
-    if (player_has_embassy(game.player_ptr, &game.players[playerno]))
-    {
-      struct packet_generic_integer pa;
-      pa.value = playerno;
-      send_packet_generic_integer(&aconnection, PACKET_PLAYER_CANCEL_PACT,
-                                 &pa);
-    }
+/**************************************************************************
+ Callback for the vision button
+**************************************************************************/
+void players_vision(void)
+{
+  LONG playerno;
+  DoMethod(player_players_listview, MUIM_NList_GetEntry, 
MUIV_NList_GetEntry_Active, &playerno);
+
+  if(playerno)
+  {
+    struct packet_generic_integer pa;
+    pa.value = playerno - 100;
+    send_packet_generic_integer(&aconnection, PACKET_PLAYER_REMOVE_VISION, 
&pa);
   }
 }
 
@@ -325,7 +341,7 @@
        MUIA_NListview_NList, NListObject,
            MUIA_NList_DisplayHook, &player_players_disphook,
            MUIA_NList_Title, TRUE,
-           MUIA_NList_Format, ",,,,,,,",
+           MUIA_NList_Format, ",,,,,,,,",
            End,
        End,
        Child, HGroup,
@@ -333,6 +349,7 @@
            Child, player_intelligence_button = MakeButton(_("_Intelligence")),
            Child, player_meet_button = MakeButton(_("_Meet")),
            Child, player_war_button = MakeButton(_("_Cancel Treaty")),
+            Child, player_vision_button = MakeButton(_("_Withdraw vision")),
            Child, player_spaceship_button = MakeButton(_("_Spaceship")),
            End,
        End,
@@ -348,6 +365,7 @@
     DoMethod(player_intelligence_button, MUIM_Notify, MUIA_Pressed, FALSE, 
app, 3, MUIM_CallHook, &civstandard_hook, players_intelligence);
     DoMethod(player_meet_button, MUIM_Notify, MUIA_Pressed, FALSE, app, 3, 
MUIM_CallHook, &civstandard_hook, players_meet);
     DoMethod(player_war_button, MUIM_Notify, MUIA_Pressed, FALSE, app, 3, 
MUIM_CallHook, &civstandard_hook, players_war);
+    DoMethod(player_vision_button, MUIM_Notify, MUIA_Pressed, FALSE, app, 3, 
MUIM_CallHook, &civstandard_hook, players_vision);
     DoMethod(player_spaceship_button, MUIM_Notify, MUIA_Pressed, FALSE, app, 
3, MUIM_CallHook, &civstandard_hook, players_spaceship);
     DoMethod(player_players_listview, MUIM_Notify, MUIA_NList_Active, 
MUIV_EveryTime, app, 3, MUIM_CallHook, &civstandard_hook, players_active);
     DoMethod(app, OM_ADDMEMBER, player_wnd);
diff -ur ../../freeciv-cvs/freeciv/common/connection.h ./common/connection.h
--- ../../freeciv-cvs/freeciv/common/connection.h       Tue Sep 19 08:44:10 2000
+++ ./common/connection.h       Tue Sep 19 09:03:06 2000
@@ -13,6 +13,11 @@
 #ifndef FC__CONNECTION_H
 #define FC__CONNECTION_H
 
+#include <time.h>      /* time_t */
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+
 /**************************************************************************
   The connection struct and related stuff.
   Includes cmdlevel stuff, which is connection-based.

Attachment: Vision.diff.gz
Description: Binary data


[Prev in Thread] Current Thread [Next in Thread]