Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Warborg is Wargames playing on network
- -- Copyright (C) 2011 Manuel De Girardi
- -- 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 3 of The License, 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.
- -- You Should Have Received A Copy of The GNU General Public License
- -- Along with This Program. if not, See <Http://Www.Gnu.Org/Licenses/>.
- with Text_Io;
- --
- with Gtk.Window; use Gtk.Window;
- with Gtk.Menu_Bar; use Gtk.Menu_Bar;
- with Gtk.Menu; use Gtk.Menu;
- with Gtk.Menu_Item; use Gtk.Menu_Item;
- with Gtk.Label; use Gtk.Label;
- with Gtk.Gentry; use Gtk.Gentry;
- with Gtk.Box; use Gtk.Box;
- with Gtk.Frame; use Gtk.Frame;
- with Gtk.Scrolled_Window; use Gtk.Scrolled_Window;
- with Gtk.Adjustment; use Gtk.Adjustment;
- with Gdk.GC; use Gdk.GC;
- with Gtkada.Canvas; use Gtkada.Canvas;
- with Gdk.Pixbuf; use Gdk.Pixbuf;
- with Gdk.Color; use Gdk.Color;
- with Pango.Layout; use Pango.Layout;
- with Gtk.Paned; use Gtk.Paned;
- with Gtk.Tree_View; use Gtk.Tree_View;
- with Gtk.Tree_Store; use Gtk.Tree_Store;
- with Gtk.Tree_Model; use Gtk.Tree_Model;
- with Gtk.Tree_View_Column; use Gtk.Tree_View_Column;
- with Gtk.Cell_Renderer_Text; use Gtk.Cell_Renderer_Text;
- with Gtk.Tree_Selection; use Gtk.Tree_Selection;
- with Glib.Values; use Glib.Values;
- with Gtk.Button; use Gtk.Button;
- with Gtk.Spin_Button; use Gtk.Spin_Button;
- with Gtk.Status_Bar; use Gtk.Status_Bar;
- with Gtk.Handlers; use Gtk.Handlers;
- pragma Elaborate_All (Gtk.Handlers);
- with Gtk.Dialog; use Gtk.Dialog;
- with Gtk.Stock; use Gtk.Stock;
- with Gtk.Enums; use Gtk.Enums;
- with Gtk.Widget; use Gtk.Widget;
- with Gtk.Main;
- with Gdk.Window; use Gdk.Window;
- with Gdk.Rectangle; use Gdk.Rectangle;
- with Gtk.Style; use Gtk.Style;
- with Gdk.Drawable; use Gdk.Drawable;
- with Glib.Error; use Glib.Error;
- use Glib;
- with Calendar; use Calendar;
- with Dates; use Dates;
- with Gnat.MD5, Gnat.Os_Lib, Gnat.Sockets;
- use Gnat;
- with Ada.Unchecked_Deallocation;
- with Ada.Streams.Stream_Io;
- use Ada.Streams;
- with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
- with Ada.Strings.Fixed;
- use Ada.Strings;
- with Warborg.System; use Warborg.System;
- package body Warborg.Xborg is
- task type Process_Type(Main_Window : access Main_Window_Type) is
- entry Login(Address : in String;
- Logname : in String;
- Passwd : in String;
- Success : out boolean);
- entry Receive(Content : in String);
- entry Create_Wopr;
- entry Create_Missil;
- entry Launch_One(Num : in Positive);
- entry Launch_All;
- entry Refresh;
- end Process_Type;
- type Image_Canvas_Record is new Interactive_Canvas_Record with record
- Background : Gdk_Pixbuf;
- Draw_Grid : Boolean := False;
- Grid_GC : Gdk_GC;
- end record;
- type Image_Canvas is access all Image_Canvas_Record'Class;
- procedure Draw_Background
- (Canvas : access Image_Canvas_Record;
- Screen_Rect : Gdk.Rectangle.Gdk_Rectangle);
- type Display_Item_Record is new buffered_Item_Record with record
- Canvas : Interactive_Canvas;
- Color : Gdk.Color.Gdk_Color;
- W, H : Gint;
- Num : Positive;
- Timeout_Id : Gtk.Main.Timeout_Handler_Id;
- Decalage : Duration := 0.0;
- end record;
- type Display_Item is access all Display_Item_Record'Class;
- Max_Colors : constant := 20;
- type Color_Type is range 1 .. Max_Colors;
- Color_Names : constant array (Color_Type) of String_Access :=
- (new String'("forest green"),
- new String'("red"),
- new String'("blue"),
- new String'("yellow"),
- new String'("peach puff"),
- new String'("azure"),
- new String'("seashell"),
- new String'("lavender"),
- new String'("grey"),
- new String'("turquoise"),
- new String'("khaki"),
- new String'("tan"),
- new String'("orange red"),
- new String'("MediumPurple"),
- new String'("ivory1"),
- new String'("DeepSkyBlue1"),
- new String'("burlywood1"),
- new String'("wheat1"),
- new String'("orange1"),
- new String'("pink"));
- Colors : array (Color_Type) of Gdk_Color;
- type Wopr_Attributes_Window is
- record
- Dialog : Gtk_window;
- Degr_Lat : Gtk_Spin_Button;
- Minu_Lat : Gtk_Spin_Button;
- Seco_Lat : Gtk_Spin_Button;
- Degr_Lon : Gtk_Spin_Button;
- Minu_Lon : Gtk_Spin_Button;
- Seco_Lon : Gtk_Spin_Button;
- Lat_Hbox : Gtk_Hbox;
- Lon_Hbox : Gtk_Hbox;
- Lat_Label: Gtk_Label;
- Lon_Label : Gtk_Label;
- Ok_Button: Gtk_Button;
- Cancel_Button: Gtk_Button;
- Button_Hbox : Gtk_Hbox;
- Main_Vbox : Gtk_Vbox;
- end record;
- type Missil_Attributes_Window is
- record
- Dialog : Gtk_window;
- Source_Label : Gtk_Label;
- Source_Degr_Lat : Gtk_Spin_Button;
- Source_Minu_Lat : Gtk_Spin_Button;
- Source_Seco_Lat : Gtk_Spin_Button;
- Source_Degr_Lon : Gtk_Spin_Button;
- Source_Minu_Lon : Gtk_Spin_Button;
- Source_Seco_Lon : Gtk_Spin_Button;
- Source_Lat_Hbox : Gtk_Hbox;
- Source_Lon_Hbox : Gtk_Hbox;
- Target_Label : Gtk_Label;
- Target_Degr_Lat : Gtk_Spin_Button;
- Target_Minu_Lat : Gtk_Spin_Button;
- Target_Seco_Lat : Gtk_Spin_Button;
- Target_Degr_Lon : Gtk_Spin_Button;
- Target_Minu_Lon : Gtk_Spin_Button;
- Target_Seco_Lon : Gtk_Spin_Button;
- Target_Lat_Hbox : Gtk_Hbox;
- Target_Lon_Hbox : Gtk_Hbox;
- Charge : Gtk_Spin_Button;
- Charge_Label : Gtk_Label;
- Charge_Hbox : Gtk_Hbox;
- Lat_Label: Gtk_Label;
- Lon_Label : Gtk_Label;
- Ok_Button: Gtk_Button;
- Cancel_Button: Gtk_Button;
- Button_Hbox : Gtk_Hbox;
- Main_Vbox : Gtk_Vbox;
- end record;
- type Missil_Unit_Config is
- record
- Source_Degr_Lat : Gtk_Spin_Button;
- Source_Minu_Lat : Gtk_Spin_Button;
- Source_Seco_Lat : Gtk_Spin_Button;
- Source_Degr_Lon : Gtk_Spin_Button;
- Source_Minu_Lon : Gtk_Spin_Button;
- Source_Seco_Lon : Gtk_Spin_Button;
- Target_Degr_Lat : Gtk_Spin_Button;
- Target_Minu_Lat : Gtk_Spin_Button;
- Target_Seco_Lat : Gtk_Spin_Button;
- Target_Degr_Lon : Gtk_Spin_Button;
- Target_Minu_Lon : Gtk_Spin_Button;
- Target_Seco_Lon : Gtk_Spin_Button;
- Charge : Gtk_Spin_Button;
- end record;
- type Missil_Unit_Access is access all Missil_Unit_Config;
- package Missils_Config_Vectors is new Ada.Containers.Vectors(Positive, Missil_Unit_Access, "=");
- type Missil_Group_Config is
- record
- Dialog : Gtk_window;
- Source_Label : Gtk_Label;
- Target_Label : Gtk_Label;
- Lat_Label: Gtk_Label;
- Lon_Label : Gtk_Label;
- Source_Lat_Hbox : Gtk_Hbox;
- Source_Lon_Hbox : Gtk_Hbox;
- Target_Lat_Hbox : Gtk_Hbox;
- Target_Lon_Hbox : Gtk_Hbox;
- Charge_Label : Gtk_Label;
- Charge_Hbox : Gtk_Hbox;
- Ok_Button: Gtk_Button;
- Cancel_Button: Gtk_Button;
- Button_Hbox : Gtk_Hbox;
- Main_Vbox : Gtk_Vbox;
- Missil_vector : Missils_Config_Vectors.Vector;
- end record;
- type Item_Table_Type is array (Positive range <>) of Canvas_Item;
- type Main_Window_Type is limited
- record
- Main_Window : Gtk_Window;
- Main_Vbox : Gtk_Vbox;
- Menu_Hbox : Gtk_Hbox;
- Main_Menu_bar : Gtk_Menu_Bar;
- File_Menu : Gtk_Menu;
- File_Menu_Item : Gtk_Menu_Item;
- Exit_Menu_Item : Gtk_Menu_Item;
- Zoom_Menu : Gtk_Menu;
- Zoom_Menu_Item : Gtk_Menu_Item;
- Zoom_Backward_Item : Gtk_Menu_Item;
- Zoom_Foreward_Item : Gtk_Menu_Item;
- Canvas_Menu : Gtk_Menu;
- Canvas_Menu_Item : Gtk_Menu_Item;
- Clear_Canvas_Menu_Item : Gtk_Menu_Item;
- Search_Menu : Gtk_Menu;
- Search_Menu_Item : Gtk_Menu_Item;
- Ant_Colony_Menu_Item : Gtk_Menu_Item;
- Ant_Colony_Conf_Menu_Item : Gtk_Menu_Item;
- Missils_Menu : Gtk_Menu;
- Missils_Menu_item : Gtk_Menu_Item;
- Launch_All_item : Gtk_Menu_Item;
- Launch_One_item : Gtk_Menu_Item;
- Create_One_Item : Gtk_Menu_Item;
- Create_Group_Item : Gtk_Menu_Item;
- Config_Group_Item : Gtk_Menu_Item;
- Host_Label : Gtk_Label;
- Host_Entry : Gtk_Gentry;
- Date_Label : Gtk_Label;
- Main_Frame : Gtk_Frame;
- Scrolled : Gtk_Scrolled_Window;
- Canvas : Image_Canvas := new Image_Canvas_Record;
- Status_Bar : Gtk_Status_Bar;
- Geometry : Gdk_Geometry := (1, 1, 1200, 855,
- 1200, 855, 1, 1, 1.0, 1.0,
- Gravity_Center);
- Logname : access String;
- Login_Dialog : Gtk_Window;
- Login_Vbox : Gtk_Vbox;
- Login_Hbox : Gtk_Hbox;
- Login_Label : Gtk_Label;
- Login_Logname : Gtk_Gentry;
- Logname_Hbox : Gtk_Hbox;
- Logname_label : Gtk_Label;
- Login_Passwd : Gtk_Gentry;
- Passwd_Hbox : Gtk_Hbox;
- passwd_label : Gtk_Label;
- Login_Ok : Gtk_Button;
- Login_cancel : Gtk_Button;
- Main_Hpaned : Gtk_Paned;
- Right_Scroll : Gtk_Scrolled_Window;
- Tree_View_Names : Gtk_Tree_View;
- Model : Gtk_Tree_Store;
- Col : Gtk_Tree_View_Column;
- Num_Col : Gint := 0;
- Wopr_Window : Wopr_Attributes_Window;
- Missil : Missil_Attributes_Window;
- Process : Process_Type(Main_Window_Type'Access);
- Wopr : Wopr_Type;
- Items_List : Item_Table_type(1..500);
- Num : Positive := 1;
- External_Items_List : Item_Table_type(1..5000);
- External_Num : Positive := 1;
- One_Missil : Missil_Type;
- Enemy : Missils_Vectors.Vector;
- Missils_Group : Missil_Group_Config;
- One_Missil_Launch : Gtk_Spin_Button;
- Launch_Window : Gtk_Window;
- end record;
- procedure Initialize(Main_Window : out Main_Window_Access);
- Green_Gc : Gdk.GC.Gdk_GC;
- Layout : Pango_Layout;
- procedure Draw_wopr (Item : access Display_Item_Record'Class) is
- begin
- Set_Foreground (Green_Gc, Display_Item (Item).Color);
- Draw_Rectangle
- (Pixmap (Item),
- GC => Green_Gc,
- Filled => True,
- X => 0,
- Y => 0,
- Width => Item.W,
- Height => Item.H);
- Set_Foreground (Green_Gc, Black (Get_Default_Colormap));
- Set_Text (Layout, "Wopr");
- Draw_Layout
- (Pixmap (Item),
- Green_Gc,
- 10,
- 10,
- Layout);
- Draw_Shadow
- (Style => Get_Style (Item.Canvas),
- Window => Pixmap (Item),
- State_Type => State_Normal,
- Shadow_Type => Shadow_Out,
- X => 0,
- Y => 0,
- Width => Item.W,
- Height => Item.H);
- end Draw_wopr;
- ----------------
- -- Initialize --
- ----------------
- procedure Initialize_Wopr(Main_Window : in Main_Window_Access;
- Item : access Display_Item_Record'Class) is
- begin
- Item.Canvas := Interactive_Canvas (Main_Window.Canvas);
- Item.Color := Colors (13);
- Item.W := 50;
- Item.H := 35;
- Item.Num := 1;
- Main_Window.Items_List (Item.Num) := Canvas_Item (Item);
- Main_Window.Num := Main_Window.Num + 1;
- Set_Screen_Size (Item, Item.W, Item.H);
- Draw_wopr (Item);
- end Initialize_wopr;
- ---------------------
- -- Add_Single_Item --
- ---------------------
- procedure Add_Wopr_Item (Main_window : in Main_Window_Access) is
- Item : constant Display_Item := new Display_Item_Record;
- begin
- Initialize_wopr (Main_Window, Item);
- Put (Main_Window.Canvas, Item, Gint(Main_Window.Wopr.Wopr_Attributes.Source.X), Gint(Main_Window.Wopr.Wopr_Attributes.Source.Y));
- Refresh_Canvas (Main_Window.Canvas);
- Show_Item (Main_Window.Canvas, Item);
- end Add_Wopr_Item;
- package Date_Timeout is new Gtk.Main.Timeout(Main_Window_Access);
- package Main_Handlers is new Gtk.Handlers.User_Callback(Gtk.Widget.Gtk_Widget_Record, Main_Window_access);
- package Main_Return_Handlers is new Gtk.Handlers.User_Return_Callback(Gtk.Widget.Gtk_Widget_Record, Boolean, Main_Window_Access);
- procedure Main_Quit
- (widget : access Gtk_Widget_Record'class;
- Main_Window : in Main_Window_Access) is
- Dialog : Gtk.Dialog.Gtk_Dialog;
- Yes : Gtk.Widget.Gtk_Widget;
- No : Gtk.Widget.Gtk_Widget;
- Help : Gtk.Widget.Gtk_Widget;
- begin
- loop
- Gtk.Dialog.Gtk_New(Dialog, "Quit ?", Main_Window.Main_Window, Gtk.dialog.modal);
- Yes := Gtk.Dialog.Add_Button(Dialog, "Yes", Gtk.Dialog.Gtk_Response_Yes);
- No := Gtk.Dialog.Add_Button(Dialog, "No", Gtk.Dialog.Gtk_Response_No);
- Help := Gtk.Dialog.Add_Button(Dialog, "Help", Gtk.Dialog.Gtk_Response_Help);
- case Gtk.Dialog.Run(Dialog) is
- when Gtk.Dialog.Gtk_Response_Yes =>
- Gtk.Dialog.Destroy(Dialog);
- abort Main_Window.Process;
- Gtk.Main.Gtk_Exit (0);
- exit;
- when Gtk.Dialog.Gtk_Response_No =>
- Gtk.Dialog.Destroy(Dialog);
- exit;
- when Gtk.Dialog.Gtk_Response_Help =>
- Gtk.Dialog.Destroy(Dialog);
- when others =>
- Gtk.Dialog.Destroy(Dialog);
- end case;
- end loop;
- end Main_Quit;
- function Main_Destroy
- (widget : access Gtk_Widget_Record'class;
- Main_Window : in Main_Window_Access) return Boolean is
- Dialog : Gtk.Dialog.Gtk_Dialog;
- Yes : Gtk.Widget.Gtk_Widget;
- No : Gtk.Widget.Gtk_Widget;
- Help : Gtk.Widget.Gtk_Widget;
- begin
- loop
- Gtk.Dialog.Gtk_New(Dialog, "Quit ?", Main_Window.Main_Window, Gtk.dialog.modal);
- Yes := Gtk.Dialog.Add_Button(Dialog, "Yes", Gtk.Dialog.Gtk_Response_Yes);
- No := Gtk.Dialog.Add_Button(Dialog, "No", Gtk.Dialog.Gtk_Response_No);
- Help := Gtk.Dialog.Add_Button(Dialog, "Help", Gtk.Dialog.Gtk_Response_Help);
- case Gtk.Dialog.Run(Dialog) is
- when Gtk.Dialog.Gtk_Response_Yes =>
- Gtk.Dialog.Destroy(Dialog);
- abort Main_Window.Process;
- Gtk.Main.Gtk_Exit (0);
- return False;
- when Gtk.Dialog.Gtk_Response_No =>
- Gtk.Dialog.Destroy(Dialog);
- return True;
- when Gtk.Dialog.Gtk_Response_Help =>
- Gtk.Dialog.Destroy(Dialog);
- when others =>
- Gtk.Dialog.Destroy(Dialog);
- end case;
- end loop;
- end Main_Destroy;
- procedure Draw_Background
- (Canvas : access Image_Canvas_Record;
- Screen_Rect : Gdk.Rectangle.Gdk_Rectangle)
- is
- X_Left : constant Glib.Gint := Left_World_Coordinates (Canvas);
- Y_Top : constant Glib.Gint := Top_World_Coordinates (Canvas);
- begin
- if Canvas.Background /= null then
- -- This is slightly complex, since we need to properly handle zooming
- -- and tiling.
- declare
- X, Y, W, H, Ys : Gint;
- Xs : Gint := Screen_Rect.X;
- Bw : constant Gint := Get_Width (Canvas.Background)
- * Gint (Get_Zoom (Canvas)) / 100;
- Bh : constant Gint := Get_Height (Canvas.Background)
- * Gint (Get_Zoom (Canvas)) / 100;
- Scaled : Gdk_Pixbuf := Canvas.Background;
- begin
- -- A real application would cache this scaled pixmap, and update
- -- the cache when the "zoomed" signal is emitted.
- if Get_Zoom (Canvas) /= 100 then
- Scaled := Scale_Simple (Canvas.Background, Bw, Bh);
- end if;
- while Xs < Screen_Rect.X + Screen_Rect.Width loop
- Ys := Screen_Rect.Y;
- X := (X_Left + Xs) mod Bw;
- W := Gint'Min (Screen_Rect.Width + Screen_Rect.X - Xs, Bw - X);
- while Ys < Screen_Rect.Y + Screen_Rect.Height loop
- Y := (Y_Top + Ys) mod Bh;
- H := Gint'Min
- (Screen_Rect.Height + Screen_Rect.Y - Ys, Bh - Y);
- Render_To_Drawable
- (Pixbuf => Scaled,
- Drawable => Get_Window (Canvas),
- Gc => Get_Black_GC (Get_Style (Canvas)),
- Src_X => X,
- Src_Y => Y,
- Dest_X => Xs,
- Dest_Y => Ys,
- Width => W,
- Height => H);
- Ys := Ys + H;
- end loop;
- Xs := Xs + W;
- end loop;
- if Get_Zoom (Canvas) /= 100 then
- Unref (Scaled);
- end if;
- end;
- else
- Draw_Rectangle
- (Get_Window (Canvas),
- Get_Background_GC (Get_Style (Canvas), State_Normal),
- Filled => True,
- X => Screen_Rect.X,
- Y => Screen_Rect.Y,
- Width => Gint (Screen_Rect.Width),
- Height => Gint (Screen_Rect.Height));
- end if;
- if Canvas.Draw_Grid then
- Draw_Grid (Interactive_Canvas (Canvas), Canvas.Grid_GC, Screen_Rect);
- end if;
- end Draw_Background;
- procedure Set_Background(Widget : access Gtk_Widget_Record'Class;
- Main_window : Main_Window_access)
- is
- Error : GError;
- begin
- Gdk_New_From_File
- (Main_Window.Canvas.Background,
- Filename => "./background4.jpg",
- Error => Error);
- Main_Window.Canvas.Grid_GC := Get_White_GC (Get_Style (Main_Window.Canvas));
- Refresh_Canvas (Main_Window.Canvas);
- end Set_Background;
- Zoom_Levels : constant array (Positive range <>) of Guint :=
- (100, 125, 150, 200, 300, 400);
- -------------
- -- Zoom_In --
- -------------
- procedure Zoom_In(Widget : access Gtk_Widget_Record'Class;
- Main_Window : in Main_Window_Access) is
- --H_Adjustment : Gtk_Adjustment;
- --V_Adjustment : Gtk_Adjustment;
- begin
- for J in Zoom_Levels'First .. Zoom_Levels'Last - 1 loop
- if Zoom_Levels (J) = Get_Zoom (Main_Window.Canvas) then
- Zoom (Main_Window.Canvas, Zoom_Levels (J + 1), 5);
- -- Gtk_New(H_Adjustment,
- -- 0.0,
- -- 0.0,
- -- 1024.0*(Gdouble(Zoom_Levels(J+1))/100.0),
- -- Gdouble(Zoom_Levels(J+1))/100.0,
- -- Gdouble(Zoom_Levels(J+1))/100.0,
- -- 1024.0/(Gdouble(Zoom_Levels(J+1))/100.0));
- -- Gtk_New(V_Adjustment,
- -- 0.0,
- -- 0.0,
- -- 768.0*(Gdouble(Zoom_Levels(J+1))/100.0),
- -- Gdouble(Zoom_Levels(J+1))/100.0,
- -- Gdouble(Zoom_Levels(J+1))/100.0,
- -- 768.0/(Gdouble(Zoom_Levels(J+1))/100.0));
- -- Set_HAdjustment(Main_Window.Scrolled, H_Adjustment);
- -- Set_Vadjustment(Main_Window.Scrolled, V_Adjustment);
- end if;
- end loop;
- end Zoom_In;
- --------------
- -- Zoom_Out --
- --------------
- procedure Zoom_Out(Widget : access Gtk_Widget_Record'Class;
- Main_Window : in Main_Window_Access) is
- --H_Adjustment : Gtk_Adjustment;
- --V_Adjustment : Gtk_Adjustment;
- begin
- for J in Zoom_Levels'First + 1 .. Zoom_Levels'Last loop
- if Zoom_Levels (J) = Get_Zoom (Main_Window.Canvas) then
- Zoom (Main_Window.Canvas, Zoom_Levels (J - 1), 5);
- -- Gtk_New(H_Adjustment,
- -- 0.0,
- -- 0.0,
- -- 1024.0*(Gdouble(Zoom_Levels(J+1))/100.0),
- -- Gdouble(Zoom_Levels(J+1))/100.0,
- -- Gdouble(Zoom_Levels(J+1))/100.0,
- -- 1024.0/(Gdouble(Zoom_Levels(J+1))/100.0));
- -- Gtk_New(V_Adjustment,
- -- 0.0,
- -- 0.0,
- -- 768.0*(Gdouble(Zoom_Levels(J+1))/100.0),
- -- Gdouble(Zoom_Levels(J+1))/100.0,
- -- Gdouble(Zoom_Levels(J+1))/100.0,
- -- 768.0/(Gdouble(Zoom_Levels(J+1))/100.0));
- -- Set_hadjustment(Main_Window.Scrolled, H_Adjustment);
- -- Set_Vadjustment(Main_Window.Scrolled, V_Adjustment);
- end if;
- end loop;
- end Zoom_Out;
- function UpDate(Main_Window : Main_Window_Access) return Boolean is
- begin
- Set_Label(Main_Window.Date_label, "Date : " & Long_Time2string(clock));
- Queue_draw(Main_Window.Date_label);
- return True;
- end UpDate;
- procedure Login
- (widget : access Gtk_Widget_Record'class;
- Main_Window : in Main_Window_Access) is
- Success : Boolean;
- Ok_dialog : Gtk_dialog;
- Ok : Gtk_Widget;
- begin
- Main_Window.Process.Login(Get_Text(Main_Window.Host_entry),
- Get_Text(Main_Window.Login_Logname),
- Get_Text(Main_Window.Login_Passwd),
- success);
- if Success then
- Main_Window.Logname := new String ' (Get_Text(Main_Window.Login_Logname));
- Destroy(Main_Window.Login_Dialog);
- else
- Gtk.Dialog.Gtk_New(Ok_Dialog, "Login failure", Main_Window.Main_Window, Gtk.dialog.modal);
- Ok := Gtk.Dialog.Add_Button(Ok_Dialog, "OK", Gtk.Dialog.Gtk_Response_Ok);
- case Gtk.Dialog.Run(Ok_Dialog) is
- when Gtk.Dialog.Gtk_Response_Ok =>
- Gtk.Dialog.Destroy(Ok_Dialog);
- when others =>
- Gtk.Dialog.Destroy(Ok_Dialog);
- end case;
- end if;
- end Login;
- procedure Host_Entry_activate
- (widget : access Gtk_Widget_Record'class;
- Main_Window : in Main_Window_Access) is
- Text : access String := new String ' (Get_Text(Main_Window.Host_entry));
- begin
- Gtk_New(Main_Window.Login_Dialog);
- Set_Default_Size(Main_Window.Login_dialog, 250, 150);
- Set_Position(Main_Window.Login_dialog, Win_Pos_Center);
- Set_Title(Main_Window.Login_Dialog, "Login...");
- Gtk_New_Vbox(Main_Window.Login_Vbox);
- Gtk_New_Hbox(Main_Window.Login_Hbox);
- Gtk_New(Main_Window.Login_Label, "Login to : " & Text.all);
- Gtk_New(Main_Window.Login_Logname);
- Gtk_New_Hbox(Main_Window.Logname_Hbox);
- Gtk_New(Main_Window.Logname_Label, "Logname : ");
- Gtk_New(Main_Window.Login_Passwd);
- Set_visibility(Main_Window.Login_Passwd, false);
- Gtk_New(Main_Window.Passwd_label, "Passowrd : ");
- Gtk_New_Hbox(Main_Window.Passwd_Hbox);
- Gtk_New_From_stock(Main_Window.Login_Ok, Stock_Ok);
- Gtk_New_From_stock(Main_Window.Login_Cancel, Stock_Cancel);
- Pack_Start(Main_Window.Logname_Hbox, Main_Window.Logname_Label);
- Pack_Start(Main_Window.Logname_Hbox, Main_Window.Login_Logname, False, False, 0);
- Pack_Start(Main_Window.Passwd_Hbox, Main_Window.Passwd_Label);
- Pack_Start(Main_Window.Passwd_Hbox, Main_Window.Login_Passwd, False, False, 0);
- Pack_Start(Main_Window.Login_Vbox, Main_Window.Login_Label);
- Pack_Start(Main_Window.Login_Vbox, Main_Window.Logname_Hbox);
- Pack_Start(Main_Window.Login_Vbox, Main_Window.passwd_Hbox);
- Pack_Start(Main_Window.Login_Hbox, Main_Window.Login_Ok, False, False, 0);
- Pack_Start(Main_Window.Login_Hbox, Main_Window.Login_Cancel, False, False, 0);
- Pack_Start(Main_Window.Login_Vbox, Main_Window.Login_Hbox);
- Add(Main_Window.Login_Dialog, Main_Window.Login_Vbox);
- Show_All(Main_Window.Login_Dialog);
- Main_handlers.Connect
- (Main_Window.Login_Ok, "clicked", Main_handlers.To_Marshaller (login'access), Main_Window);
- end Host_Entry_Activate;
- -----------
- -- Clear --
- -----------
- procedure Clear_canvas (widget : access Gtk_Widget_Record'class;
- Main_Window : in Main_Window_Access) is
- function Remove_Internal
- (Canvas : access Interactive_Canvas_Record'Class;
- Item : access Canvas_Item_Record'Class) return Boolean is
- begin
- Remove (Canvas, Item);
- return True;
- end Remove_Internal;
- begin
- Text_Io.Put("Clear");
- For_Each_Item (Main_Window.Canvas, Remove_Internal'Unrestricted_Access);
- Text_Io.Put("Clear 1");
- Refresh_Canvas (Main_Window.Canvas);
- end Clear_canvas;
- package Interactive_Simple_Cb is new Gtk.Handlers.Callback
- (interactive_Canvas_Record);
- procedure On_List_Selection(widget : access Gtk_Widget_Record'class;
- Main_Window : in Main_Window_Access) is
- Selection : Gtk_Tree_Selection;
- Iter : Gtk_Tree_Iter;
- Model : Gtk_Tree_Model;
- Value : Gvalue;
- Logname : access String;
- begin
- Text_Io.Put("Names Selection");
- Selection := Get_Selection(Main_Window.Tree_View_names);
- Text_Io.Put("Get_selection");
- Get_Selected(Selection, Model, iter);
- if Iter /= Null_Iter then
- Text_Io.Put("Get_Gvalue");
- Get_Value(Model, Iter, 0, value);
- Text_Io.Put("Get_String");
- Logname := new String' (Get_String(Value, 128));
- Text_Io.Put_Line(Logname.all);
- Main_Window.Process.Receive(Logname.all);
- end if;
- end On_List_Selection;
- procedure Add_Canvas_Link
- (Canvas : access Interactive_Canvas_Record'Class;
- Item1, Item2 : access Canvas_Item_Record'Class; Text : String := "");
- -- Add a link between Item1 and Item2
- ---------------------------
- -- Draw_To_Double_Buffer --
- ---------------------------
- procedure Draw_External_Missil (Item : access Display_Item_Record'Class) is
- begin
- Set_Foreground (Green_Gc, Display_Item (Item).Color);
- Draw_Rectangle
- (Pixmap (Item),
- GC => Green_Gc,
- Filled => True,
- X => 0,
- Y => 0,
- Width => Item.W,
- Height => Item.H);
- Set_Foreground (Green_Gc, Black (Get_Default_Colormap));
- Set_Text (Layout, "Missil" & Positive'Image (Display_Item (Item).Num));
- Draw_Layout
- (Pixmap (Item),
- Green_Gc,
- 10,
- 10,
- Layout);
- Draw_Shadow
- (Style => Get_Style (Item.Canvas),
- Window => Pixmap (Item),
- State_Type => State_Normal,
- Shadow_Type => Shadow_Out,
- X => 0,
- Y => 0,
- Width => Item.W,
- Height => Item.H);
- end Draw_External_Missil;
- procedure Draw_Missil (Item : access Display_Item_Record'Class) is
- begin
- Set_Foreground (Green_Gc, Display_Item (Item).Color);
- Draw_Rectangle
- (Pixmap (Item),
- GC => Green_Gc,
- Filled => True,
- X => 0,
- Y => 0,
- Width => Item.W,
- Height => Item.H);
- Set_Foreground (Green_Gc, Black (Get_Default_Colormap));
- Set_Text (Layout, "Missil" & Positive'Image (Display_Item (Item).Num/2));
- Draw_Layout
- (Pixmap (Item),
- Green_Gc,
- 10,
- 10,
- Layout);
- Draw_Shadow
- (Style => Get_Style (Item.Canvas),
- Window => Pixmap (Item),
- State_Type => State_Normal,
- Shadow_Type => Shadow_Out,
- X => 0,
- Y => 0,
- Width => Item.W,
- Height => Item.H);
- end Draw_Missil;
- procedure Draw_Target (Item : access Display_Item_Record'Class) is
- begin
- Set_Foreground (Green_Gc, Display_Item (Item).Color);
- Draw_Rectangle
- (Pixmap (Item),
- GC => Green_Gc,
- Filled => True,
- X => 0,
- Y => 0,
- Width => Item.W,
- Height => Item.H);
- Set_Foreground (Green_Gc, Black (Get_Default_Colormap));
- Set_Text (Layout, "Target" & Positive'Image (Display_Item (Item).Num/2 -1));
- Draw_Layout
- (Pixmap (Item),
- Green_Gc,
- 10,
- 10,
- Layout);
- Draw_Shadow
- (Style => Get_Style (Item.Canvas),
- Window => Pixmap (Item),
- State_Type => State_Normal,
- Shadow_Type => Shadow_Out,
- X => 0,
- Y => 0,
- Width => Item.W,
- Height => Item.H);
- end Draw_Target;
- procedure Initialize_missil(Main_Window : in Main_Window_Access;
- Item : access Display_Item_Record'Class;
- Source_X : Gint := 0;
- Source_Y : Gint := 0) is
- begin
- Item.Canvas := Interactive_Canvas (Main_Window.Canvas);
- Item.Color := Colors (14);
- Item.W := 70;
- Item.H := 35;
- Item.Num := Main_Window.Num + 1;
- if Main_Window.num <= Main_Window.Items_List'Last then
- Main_Window.Items_List (Item.Num) := Canvas_Item (Item);
- end if;
- Main_Window.Num := Main_Window.Num + 1;
- Set_Screen_Size (Item, Item.W, Item.H);
- Draw_missil (Item);
- end Initialize_missil;
- procedure Initialize_External_Missil(Main_Window : in Main_Window_Access;
- Item : access Display_Item_Record'Class) is
- begin
- Item.Canvas := Interactive_Canvas (Main_Window.Canvas);
- Item.Color := Colors (1);
- Item.W := 70;
- Item.H := 35;
- Item.Num := Main_Window.External_Num;
- if Main_Window.External_Num <= Main_Window.External_Items_List'Last then
- Main_Window.External_Items_List (Item.Num) := Canvas_Item (Item);
- Main_Window.External_Num := Main_Window.External_Num + 1;
- end if;
- Set_Screen_Size (Item, Item.W, Item.H);
- Draw_External_Missil (Item);
- end Initialize_External_Missil;
- procedure Initialize_target(Main_Window : in Main_Window_Access;
- Item : access Display_Item_Record'Class) is
- begin
- Item.Canvas := Interactive_Canvas (Main_Window.Canvas);
- Item.Color := Colors (10);
- Item.W := 70;
- Item.H := 35;
- Item.Num := Main_Window.Num + 1;
- if Main_Window.num <= Main_Window.Items_List'Last then
- Main_Window.Items_List (Item.Num) := Canvas_Item (Item);
- end if;
- Main_Window.Num := Main_Window.Num + 1;
- Set_Screen_Size (Item, Item.W, Item.H);
- Draw_Target (Item);
- end Initialize_target;
- ---------------------
- -- Add_Single_Item --
- ---------------------
- procedure Add_Missil_With_Cible(Main_window : in Main_Window_Access;
- Source_X : Gint;
- Source_Y : Gint;
- Target_X : Gint;
- Target_Y : Gint;
- Charge : Charge_Type) is
- missil : constant Display_Item := new Display_Item_Record;
- cible : constant Display_Item := new Display_Item_Record;
- begin
- Initialize_missil (Main_Window, missil);
- Initialize_target (Main_Window, cible);
- Add_Canvas_Link (Main_Window.Canvas, Main_Window.Items_List(1), missil, "");
- Add_Canvas_Link (Main_Window.Canvas, missil, Cible, "Charge : " & Charge_Type'Image(Charge));
- Put (Main_Window.Canvas, Missil, Source_X, Source_Y);
- Put (Main_Window.Canvas, Cible, Target_X, Target_Y);
- Refresh_Canvas (Main_Window.Canvas);
- Show_Item (Main_Window.Canvas, Missil);
- Show_Item (Main_Window.Canvas, Cible);
- end Add_Missil_With_cible;
- procedure Add_Canvas_Link
- (Canvas : access Interactive_Canvas_Record'Class;
- Item1, Item2 : access Canvas_Item_Record'Class; Text : String := "")
- is
- Link : constant Canvas_Link := new Canvas_Link_Record;
- begin
- Add_Link (Canvas, Link, Item1, Item2, Both_Arrow, Text);
- end Add_Canvas_Link;
- procedure Create_missil
- (widget : access Gtk_Widget_Record'class;
- Main_Window : Main_Window_access) is
- Degr_Lat : Gdouble := 0.0;
- Minu_Lat : Gdouble := 0.0;
- Seco_Lat : Gdouble := 0.0;
- Degr_Lon : Gdouble := 0.0;
- Minu_Lon : Gdouble := 0.0;
- Seco_Lon : Gdouble := 0.0;
- Lon_Unit : constant Float := 1024.0/(360.0*60.0*60.0);
- Lat_Unit : constant Float := 768.0/(180.0*60.0*60.0);
- begin
- Degr_Lat := Get_Value(Main_Window.Missil.Source_Degr_Lat);
- Minu_Lat := Get_Value(Main_Window.Missil.Source_Minu_Lat);
- Seco_Lat := Get_Value(Main_Window.Missil.Source_Seco_Lat);
- Degr_Lon := Get_Value(Main_Window.Missil.Source_Degr_Lon);
- Minu_Lon := Get_Value(Main_Window.Missil.Source_Minu_Lon);
- Seco_Lon := Get_Value(Main_Window.Missil.Source_Seco_Lon);
- Text_Io.New_Line;
- Text_Io.Put_Line("Initialize Missil Attributes....");
- Text_Io.New_Line;
- if Degr_Lon >= 0.0 then
- Text_Io.Put_Line("Longitude := " & Float'Image(512.0 + Float(Degr_Lon)* (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit));
- Main_Window.One_Missil.Missil_Attributes.Source.X := 512.0 + Float(Degr_Lon) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit;
- else
- Text_Io.Put_Line("Longitude := " & Float'Image(512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit)));
- Main_Window.One_Missil.Missil_Attributes.Source.X := 512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit);
- end if;
- if Degr_Lat >= 0.0 then
- Text_Io.Put_Line("Latitude := " & Float'Image(384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit));
- Main_Window.One_Missil.Missil_Attributes.Source.Y := 384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit;
- else
- Text_Io.Put_Line("Latitude := " & Float'Image(384.0 - ((Float(Degr_Lat)* (-1.0)) *(3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit)));
- Main_Window.One_Missil.Missil_Attributes.Source.Y := 384.0 - ((Float(Degr_Lat)*(-1.0))* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit);
- end if;
- Degr_Lat := Get_Value(Main_Window.Missil.Target_Degr_Lat);
- Minu_Lat := Get_Value(Main_Window.Missil.Target_Minu_Lat);
- Seco_Lat := Get_Value(Main_Window.Missil.Target_Seco_Lat);
- Degr_Lon := Get_Value(Main_Window.Missil.Target_Degr_Lon);
- Minu_Lon := Get_Value(Main_Window.Missil.Target_Minu_Lon);
- Seco_Lon := Get_Value(Main_Window.Missil.Target_Seco_Lon);
- Text_Io.New_Line;
- Text_Io.New_Line;
- if Degr_Lon >= 0.0 then
- Text_Io.Put_Line("Longitude := " & Float'Image(512.0 + Float(Degr_Lon)* (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit));
- Main_Window.One_Missil.Missil_Attributes.Target.X := 512.0 + Float(Degr_Lon) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit;
- else
- Text_Io.Put_Line("Longitude := " & Float'Image(512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit)));
- Main_Window.One_Missil.Missil_Attributes.Target.X := 512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit);
- end if;
- if Degr_Lat >= 0.0 then
- Text_Io.Put_Line("Latitude := " & Float'Image(384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit));
- Main_Window.One_Missil.Missil_Attributes.Target.Y := 384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit;
- else
- Text_Io.Put_Line("Latitude := " & Float'Image(384.0 - ((Float(Degr_Lat)* (-1.0)) *(3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit)));
- Main_Window.One_Missil.Missil_Attributes.Target.Y := 384.0 - ((Float(Degr_Lat)*(-1.0))* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit);
- end if;
- Main_Window.One_Missil.Missil_Attributes.charge := Float(Get_Value(Main_Window.Missil.Charge));
- Main_Window.Process.Create_Missil;
- Destroy(Main_Window.Missil.Dialog);
- end Create_Missil;
- procedure Get_missil_Attributes(widget : access Gtk_Widget_Record'class;
- Main_Window : in Main_Window_access) is
- begin
- Gtk_New(Main_Window.Missil.Dialog);
- Set_Position(Main_Window.Missil.dialog, Win_Pos_Center);
- Gtk_New(Main_Window.Missil.Source_Label, "Position : ");
- Gtk_New(Main_Window.Missil.Source_Degr_Lat, -90.0, 90.0, 1.0);
- Gtk_New(Main_Window.Missil.Source_Minu_Lat, 0.0, 60.0, 1.0);
- Gtk_New(Main_Window.Missil.Source_Seco_Lat, 0.0, 60.0, 1.0);
- Gtk_New(Main_Window.Missil.Source_Degr_Lon, -180.0, 180.0, 1.0);
- Gtk_New(Main_Window.Missil.Source_Minu_Lon, 0.0, 60.0, 1.0);
- Gtk_New(Main_Window.Missil.Source_Seco_Lon, 0.0, 60.0, 1.0);
- Gtk_New_Hbox(Main_Window.Missil.Source_Lat_Hbox);
- Gtk_New_Hbox(Main_Window.Missil.Source_Lon_Hbox);
- Gtk_New(Main_Window.Missil.Lat_Label, "Latitude :");
- Gtk_New(Main_Window.Missil.Lon_Label, "Longitude :");
- Gtk_New(Main_Window.Missil.target_Label, "Target : ");
- Gtk_New(Main_Window.Missil.Target_Degr_Lat, -90.0, 90.0, 1.0);
- Gtk_New(Main_Window.Missil.Target_Minu_Lat, 0.0, 60.0, 1.0);
- Gtk_New(Main_Window.Missil.Target_Seco_Lat, 0.0, 60.0, 1.0);
- Gtk_New(Main_Window.Missil.Target_Degr_Lon, -180.0, 180.0, 1.0);
- Gtk_New(Main_Window.Missil.Target_Minu_Lon, 0.0, 60.0, 1.0);
- Gtk_New(Main_Window.Missil.Target_Seco_Lon, 0.0, 60.0, 1.0);
- Gtk_New(Main_Window.Missil.Charge_Label, "Charge : ");
- Gtk_New(Main_Window.Missil.charge, 0.0, Gdouble(Main_Window.Wopr.Wopr_Attributes.Charge), 0.0001);
- Text_Io.Put_Line("toto 0");
- Gtk_New_From_stock(Main_Window.Missil.Ok_button, Stock_Ok);
- Gtk_New_From_stock(Main_Window.Missil.Cancel_button, Stock_Cancel);
- Gtk_New_Hbox(Main_Window.Missil.Target_Lat_Hbox);
- Gtk_New_Hbox(Main_Window.Missil.Target_Lon_Hbox);
- Gtk_New_Hbox(Main_Window.Missil.Charge_Hbox);
- Gtk_New_Hbox(Main_Window.Missil.button_Hbox);
- Gtk_New_Vbox(Main_Window.Missil.Main_Vbox);
- Pack_Start(Main_Window.Missil.Main_vbox, Main_Window.Missil.Source_Label);
- Pack_Start(Main_Window.Missil.Source_Lat_Hbox, Main_Window.Missil.Lat_Label);
- Pack_Start(Main_Window.Missil.Source_Lat_Hbox, Main_Window.Missil.Source_Degr_lat);
- Pack_Start(Main_Window.Missil.Source_Lat_Hbox, Main_Window.Missil.Source_Minu_lat);
- Pack_Start(Main_Window.Missil.Source_Lat_Hbox, Main_Window.Missil.Source_Seco_lat);
- Pack_Start(Main_Window.Missil.Source_Lon_Hbox, Main_Window.Missil.Lon_Label);
- Pack_Start(Main_Window.Missil.Source_Lon_Hbox, Main_Window.Missil.Source_Degr_Lon);
- Pack_Start(Main_Window.Missil.Source_Lon_Hbox, Main_Window.Missil.Source_Minu_Lon);
- Pack_Start(Main_Window.Missil.Source_Lon_Hbox, Main_Window.Missil.Source_Seco_Lon);
- Gtk_New(Main_Window.Missil.Lat_Label, "Latitude :");
- Gtk_New(Main_Window.Missil.Lon_Label, "Longitude :");
- Pack_Start(Main_Window.Missil.Target_Lat_Hbox, Main_Window.Missil.Lat_Label);
- Text_Io.Put_Line("toto 1");
- Pack_Start(Main_Window.Missil.Target_Lat_Hbox, Main_Window.Missil.Target_Degr_lat);
- Text_Io.Put_Line("toto 2");
- Pack_Start(Main_Window.Missil.Target_Lat_Hbox, Main_Window.Missil.Target_Minu_lat);
- Text_Io.Put_Line("toto 3");
- Pack_Start(Main_Window.Missil.Target_Lat_Hbox, Main_Window.Missil.Target_Seco_lat);
- Text_Io.Put_Line("toto 4");
- Pack_Start(Main_Window.Missil.Target_Lon_Hbox, Main_Window.Missil.Lon_Label);
- Pack_Start(Main_Window.Missil.Target_Lon_Hbox, Main_Window.Missil.Target_Degr_Lon);
- Pack_Start(Main_Window.Missil.Target_Lon_Hbox, Main_Window.Missil.Target_Minu_Lon);
- Pack_Start(Main_Window.Missil.Target_Lon_Hbox, Main_Window.Missil.Target_Seco_Lon);
- Pack_Start(Main_Window.Missil.Charge_Hbox, Main_Window.Missil.Charge_Label);
- Pack_Start(Main_Window.Missil.Charge_Hbox, Main_Window.Missil.Charge);
- Pack_Start(Main_Window.Missil.Button_Hbox, Main_Window.Missil.Ok_Button);
- Pack_Start(Main_Window.Missil.Button_Hbox, Main_Window.Missil.Cancel_button);
- Pack_Start(Main_Window.Missil.Main_Vbox, Main_Window.Missil.Source_Lat_Hbox);
- Pack_Start(Main_Window.Missil.Main_Vbox, Main_Window.Missil.Source_Lon_Hbox);
- Pack_Start(Main_Window.Missil.Main_vbox, Main_Window.Missil.Target_Label);
- Pack_Start(Main_Window.Missil.Main_Vbox, Main_Window.Missil.Target_Lat_Hbox);
- Pack_Start(Main_Window.Missil.Main_Vbox, Main_Window.Missil.Target_Lon_Hbox);
- Pack_Start(Main_Window.Missil.Main_Vbox, Main_Window.Missil.Charge_Hbox);
- Pack_Start(Main_Window.Missil.Main_Vbox, Main_Window.Missil.Button_Hbox);
- Text_Io.Put("TOTO 2");
- Main_Handlers.Connect
- (Main_Window.Missil.Ok_Button, "clicked", Main_Handlers.To_Marshaller (Create_Missil'access), Main_Window.all'access);
- Add(Main_Window.Missil.Dialog, Main_Window.Missil.Main_Vbox);
- Show_All(Main_Window.Missil.Dialog);
- end Get_missil_Attributes;
- procedure Missil_Create_Group(widget : access Gtk_Widget_Record'class;
- Main_Window : in Main_Window_access) is
- Lon_Unit : constant Float := 1024.0/(360.0*60.0*60.0);
- Lat_Unit : constant Float := 768.0/(180.0*60.0*60.0);
- begin
- Text_Io.Put_Line("Destroy window.");
- Text_Io.Put_Line("Initialize Missils group Attributes....");
- if not Missils_Config_Vectors.Is_empty(Main_Window.Missils_Group.Missil_Vector) then
- for I in 1..Missils_Config_Vectors.Last_Index(Main_Window.Missils_Group.Missil_Vector) loop
- declare
- Degr_Lat : Gdouble := 0.0;
- Minu_Lat : Gdouble := 0.0;
- Seco_Lat : Gdouble := 0.0;
- Degr_Lon : Gdouble := 0.0;
- Minu_Lon : Gdouble := 0.0;
- Seco_Lon : Gdouble := 0.0;
- Missil : Missil_Unit_Access := Missils_Config_Vectors.Element(Main_Window.Missils_Group.Missil_Vector, I);
- begin
- Text_Io.Put_Line("Missil 0");
- Degr_Lat := Get_Value(Missil.Source_Degr_Lat);
- Text_Io.Put_Line("Missil 0.0");
- Minu_Lat := Get_Value(Missil.Source_Minu_Lat);
- Text_Io.Put_Line("Missil 0.1");
- Seco_Lat := Get_Value(Missil.Source_Seco_Lat);
- Text_Io.Put_Line("Missil 0.2");
- Degr_Lon := Get_Value(Missil.Source_Degr_Lon);
- Text_Io.Put_Line("Missil 0.3");
- Minu_Lon := Get_Value(Missil.Source_Minu_Lon);
- Text_Io.Put_Line("Missil 0.4");
- Seco_Lon := Get_Value(Missil.Source_Seco_Lon);
- Text_Io.Put_Line("Missil 1");
- if Degr_Lon >= 0.0 then
- Text_Io.Put_Line("Longitude := " & Float'Image(512.0 + Float(Degr_Lon)* (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit));
- Main_Window.One_Missil.Missil_Attributes.Source.X := 512.0 + Float(Degr_Lon) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit;
- else
- Text_Io.Put_Line("Longitude := " & Float'Image(512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit)));
- Main_Window.One_Missil.Missil_Attributes.Source.X := 512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit);
- end if;
- if Degr_Lat >= 0.0 then
- Text_Io.Put_Line("Latitude := " & Float'Image(384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit));
- Main_Window.One_Missil.Missil_Attributes.Source.Y := 384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit;
- else
- Text_Io.Put_Line("Latitude := " & Float'Image(384.0 - ((Float(Degr_Lat)* (-1.0)) *(3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit)));
- Main_Window.One_Missil.Missil_Attributes.Source.Y := 384.0 - ((Float(Degr_Lat)*(-1.0))* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit);
- end if;
- Text_Io.Put_Line("Missil 2");
- Degr_Lat := Get_Value(Missil.Target_Degr_Lat);
- Minu_Lat := Get_Value(Missil.Target_Minu_Lat);
- Seco_Lat := Get_Value(Missil.Target_Seco_Lat);
- Degr_Lon := Get_Value(Missil.Target_Degr_Lon);
- Minu_Lon := Get_Value(Missil.Target_Minu_Lon);
- Seco_Lon := Get_Value(Missil.Target_Seco_Lon);
- Text_Io.New_Line;
- Text_Io.New_Line;
- if Degr_Lon >= 0.0 then
- Text_Io.Put_Line("Longitude := " & Float'Image(512.0 + Float(Degr_Lon)* (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit));
- Main_Window.One_Missil.Missil_Attributes.Target.X := 512.0 + Float(Degr_Lon) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit;
- else
- Text_Io.Put_Line("Longitude := " & Float'Image(512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit)));
- Main_Window.One_Missil.Missil_Attributes.Target.X := 512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit);
- end if;
- if Degr_Lat >= 0.0 then
- Text_Io.Put_Line("Latitude := " & Float'Image(384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit));
- Main_Window.One_Missil.Missil_Attributes.Target.Y := 384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit;
- else
- Text_Io.Put_Line("Latitude := " & Float'Image(384.0 - ((Float(Degr_Lat)* (-1.0)) *(3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit)));
- Main_Window.One_Missil.Missil_Attributes.Target.Y := 384.0 - ((Float(Degr_Lat)*(-1.0))* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit);
- end if;
- Text_Io.Put_Line("Missil 3");
- Main_Window.One_Missil.Missil_Attributes.charge := Float(Get_Value(Missil.Charge));
- Text_Io.Put_Line("Missil 4");
- Main_Window.Process.Create_Missil;
- end;
- end loop;
- end if;
- Destroy(Main_Window.Missils_Group.Dialog);
- end Missil_Create_Group;
- procedure Missil_Config_Group(widget : access Gtk_Widget_Record'class;
- Main_Window : in Main_Window_access) is
- begin
- Gtk_New(Main_Window.Missils_group.Dialog);
- Set_Position(Main_Window.Missils_group.dialog, Win_Pos_Center);
- Gtk_New_Hbox(Main_Window.Missils_Group.button_Hbox);
- Text_Io.Put_Line("toto 0");
- Gtk_New_From_stock(Main_Window.Missils_group.Ok_button, Stock_Ok);
- Text_Io.Put_Line("toto -1");
- Gtk_New_From_stock(Main_Window.Missils_group.Cancel_button, Stock_Cancel);
- Text_Io.Put_Line("toto -2");
- Gtk_New_Vbox(Main_Window.Missils_Group.Main_Vbox);
- Text_Io.Put_Line("toto -3");
- Missils_Config_Vectors.Clear(Main_Window.Missils_Group.Missil_Vector);
- for I in 1..4 loop
- declare
- Missil : Missil_Unit_Access := new Missil_Unit_Config;
- begin
- Gtk_New(Main_Window.Missils_Group.Source_Label, "Position : ");
- Gtk_New(Main_Window.Missils_Group.Lat_Label, "Latitude :");
- Gtk_New(Main_Window.Missils_Group.Lon_Label, "Longitude :");
- Gtk_New(Missil.Source_Degr_Lat, -90.0, 90.0, 1.0);
- Gtk_New(Missil.Source_Minu_Lat, 0.0, 60.0, 1.0);
- Gtk_New(Missil.Source_Seco_Lat, 0.0, 60.0, 1.0);
- Gtk_New(Missil.Source_Degr_Lon, -180.0, 180.0, 1.0);
- Gtk_New(Missil.Source_Minu_Lon, 0.0, 60.0, 1.0);
- Gtk_New(Missil.Source_Seco_Lon, 0.0, 60.0, 1.0);
- Gtk_New_Hbox(Main_Window.Missils_Group.Source_Lat_Hbox);
- Gtk_New_Hbox(Main_Window.Missils_Group.Source_Lon_Hbox);
- Gtk_New(Main_Window.Missils_Group.Lat_Label, "Latitude :");
- Gtk_New(Main_Window.Missils_Group.Lon_Label, "Longitude :");
- Gtk_New(Main_Window.Missils_Group.target_Label, "Target : ");
- Gtk_New(Missil.Target_Degr_Lat, -90.0, 90.0, 1.0);
- Gtk_New(Missil.Target_Minu_Lat, 0.0, 60.0, 1.0);
- Gtk_New(Missil.Target_Seco_Lat, 0.0, 60.0, 1.0);
- Gtk_New(Missil.Target_Degr_Lon, -180.0, 180.0, 1.0);
- Gtk_New(Missil.Target_Minu_Lon, 0.0, 60.0, 1.0);
- Gtk_New(Missil.Target_Seco_Lon, 0.0, 60.0, 1.0);
- Gtk_New(Main_Window.Missils_Group.Charge_Label, "Charge : ");
- Gtk_New(Missil.charge, 0.0, Gdouble(Main_Window.Wopr.Wopr_Attributes.Charge)/4.0, 0.0001);
- Text_Io.Put_Line("toto -10");
- Gtk_New_Hbox(Main_Window.Missils_Group.Target_Lat_Hbox);
- Gtk_New_Hbox(Main_Window.Missils_Group.Target_Lon_Hbox);
- Gtk_New_Hbox(Main_Window.Missils_Group.Charge_Hbox);
- Text_Io.Put_Line("toto -9");
- Pack_Start(Main_Window.Missils_group.Main_vbox, Main_Window.Missils_group.Source_Label);
- Text_Io.Put_Line("toto -9.1");
- Pack_Start(Main_Window.Missils_Group.Source_Lat_Hbox, Main_Window.Missils_Group.Lat_Label);
- Text_Io.Put_Line("toto -9.2");
- Pack_Start(Main_Window.Missils_Group.Source_Lat_Hbox, Missil.Source_Degr_lat);
- Text_Io.Put_Line("toto -9.3");
- Pack_Start(Main_Window.Missils_Group.Source_Lat_Hbox, Missil.Source_Minu_lat);
- Text_Io.Put_Line("toto -9.4");
- Pack_Start(Main_Window.Missils_Group.Source_Lat_Hbox, Missil.Source_Seco_lat);
- Text_Io.Put_Line("toto -8");
- Pack_Start(Main_Window.Missils_Group.Source_Lon_Hbox, Main_Window.Missils_Group.Lon_Label);
- Pack_Start(Main_Window.Missils_Group.Source_Lon_Hbox, Missil.Source_Degr_Lon);
- Pack_Start(Main_Window.Missils_Group.Source_Lon_Hbox, Missil.Source_Minu_Lon);
- Pack_Start(Main_Window.Missils_Group.Source_Lon_Hbox, Missil.Source_Seco_Lon);
- Text_Io.Put_Line("toto -7");
- Gtk_New(Main_Window.Missils_Group.Lat_Label, "Latitude :");
- Gtk_New(Main_Window.Missils_Group.Lon_Label, "Longitude :");
- Pack_Start(Main_Window.Missils_Group.Target_Lat_Hbox, Main_Window.Missils_Group.Lat_Label);
- Text_Io.Put_Line("toto 1");
- Pack_Start(Main_Window.Missils_Group.Target_Lat_Hbox, Missil.Target_Degr_lat);
- Text_Io.Put_Line("toto 2");
- Pack_Start(Main_Window.Missils_Group.Target_Lat_Hbox, Missil.Target_Minu_lat);
- Text_Io.Put_Line("toto 3");
- Pack_Start(Main_Window.Missils_Group.Target_Lat_Hbox, Missil.Target_Seco_lat);
- Text_Io.Put_Line("toto 4");
- Pack_Start(Main_Window.Missils_Group.Target_Lon_Hbox, Main_Window.Missils_group.Lon_Label);
- Pack_Start(Main_Window.Missils_Group.Target_Lon_Hbox, Missil.Target_Degr_Lon);
- Pack_Start(Main_Window.Missils_Group.Target_Lon_Hbox, Missil.Target_Minu_Lon);
- Pack_Start(Main_Window.Missils_Group.Target_Lon_Hbox, Missil.Target_Seco_Lon);
- Pack_Start(Main_Window.Missils_Group.Charge_Hbox, Main_Window.Missils_Group.Charge_Label);
- Pack_Start(Main_Window.Missils_Group.Charge_Hbox, Missil.Charge);
- Text_Io.Put_Line("toto 5");
- Pack_Start(Main_Window.Missils_Group.Main_Vbox, Main_Window.Missils_Group.Source_Lat_Hbox);
- Pack_Start(Main_Window.Missils_Group.Main_Vbox, Main_Window.Missils_Group.Source_Lon_Hbox);
- Text_Io.Put_Line("toto 6");
- Pack_Start(Main_Window.Missils_Group.Main_vbox, Main_Window.Missils_Group.Target_Label);
- Pack_Start(Main_Window.Missils_Group.Main_Vbox, Main_Window.Missils_Group.Target_Lat_Hbox);
- Pack_Start(Main_Window.Missils_Group.Main_Vbox, Main_Window.Missils_Group.Target_Lon_Hbox);
- Pack_Start(Main_Window.Missils_Group.Main_Vbox, Main_Window.Missils_Group.Charge_Hbox);
- Text_Io.Put_Line("toto 7");
- Missils_Config_Vectors.Insert(Main_Window.Missils_Group.Missil_Vector, I, Missil, 1);
- end;
- end loop;
- Pack_Start(Main_Window.Missils_Group.Button_Hbox, Main_Window.Missils_Group.Ok_Button);
- Text_Io.Put_Line("toto -30");
- Pack_Start(Main_Window.Missils_Group.Button_Hbox, Main_Window.Missils_Group.Cancel_button);
- Text_Io.Put_Line("toto -31");
- Pack_Start(Main_Window.Missils_group.Main_Vbox, Main_Window.Missils_Group.Button_Hbox);
- Text_Io.Put("TOTO 2");
- Main_Handlers.Connect
- (Main_Window.Missils_Group.Ok_Button, "clicked", Main_Handlers.To_Marshaller (Missil_Create_group'access), Main_Window.all'access);
- Add(Main_Window.Missils_Group.Dialog, Main_Window.Missils_Group.Main_Vbox);
- Show_All(Main_Window.Missils_group.Dialog);
- end Missil_Config_Group;
- procedure Launch_One(widget : access Gtk_Widget_Record'Class;
- Main_Window : in Main_Window_access) is
- begin
- Text_Io.Put("Launch One Missil");
- Main_Window.Process.Launch_One(Positive(Get_Value(Main_Window.One_Missil_Launch)));
- Destroy(Main_Window.Launch_Window);
- end Launch_One;
- procedure Launch_all(widget : access Gtk_Widget_Record'Class;
- Main_Window : in Main_Window_access) is
- begin
- Text_Io.Put("Launch All Missil");
- Main_Window.Process.Launch_All;
- end Launch_All;
- procedure get_One(widget : access Gtk_Widget_Record'class;
- Main_Window : in Main_Window_access) is
- Ok_Button: Gtk_Button;
- Cancel_Button: Gtk_Button;
- Button_Hbox : Gtk_Hbox;
- Main_Vbox : Gtk_Vbox;
- begin
- Text_Io.Put("Get Launch One Missil");
- Gtk_New(Main_Window.Launch_Window, Window_Toplevel);
- Set_Position(Main_Window.Launch_Window, Win_Pos_Center);
- Gtk_New_From_stock(Ok_button, Stock_Ok);
- Gtk_New_From_stock(Cancel_button, Stock_Cancel);
- Gtk_New_Hbox(Button_Hbox);
- Gtk_New_Vbox(Main_Vbox);
- Gtk_New(Main_Window.One_Missil_Launch, 1.0, Gdouble(Missils_Vectors.Last_Index(Main_Window.Wopr.Missils)), 1.0);
- Pack_Start(Main_Vbox, Main_Window.One_Missil_Launch);
- Pack_Start(button_Hbox, Ok_button);
- Pack_Start(button_Hbox, Cancel_button);
- Pack_Start(Main_Vbox, Button_Hbox);
- Main_Handlers.Connect
- (Ok_Button, "clicked", Main_Handlers.To_Marshaller (Launch_one'access), Main_Window.all'access);
- Add(Main_Window.Launch_Window, Main_Vbox);
- Show_All(Main_Window.Launch_Window);
- end Get_One;
- procedure Initialize(Main_Window : out Main_Window_Access) is
- Timeout_Id : Gtk.Main.Timeout_Handler_Id;
- Text_Render : Gtk_Cell_Renderer_Text;
- begin
- Main_Window := new Main_Window_Type;
- Gtk_New(Main_Window.Main_Window);
- Text_Io.Put_line("TOTO 0");
- Gtkada.Canvas.initialize(Main_Window.Canvas, false);
- Text_Io.Put_line("TOTO 1");
- Set_Title(Main_Window.Main_Window,"Warborg - Xborg 2012 beta");
- Set_Geometry_Hints(Main_Window.Main_Window, null,
- Main_Window.Geometry, Gdk_Hint_Max_size);
- Set_Default_Size(Main_Window.Main_Window, 1200, 855);
- Set_Position(Main_Window.Main_Window, Win_Pos_Center);
- Set_Resizable(Main_Window.Main_Window, False);
- Gtk_New_Vbox(Main_Window.Main_Vbox);
- Gtk_New_Hbox(Main_Window.Menu_Hbox);
- Gtk_New(Main_Window.Main_Menu_Bar);
- Gtk_New(Main_Window.File_Menu);
- Gtk_New(Main_Window.File_Menu_Item, "File");
- Gtk_New(Main_Window.Exit_Menu_Item, "Quit");
- Gtk_New(Main_Window.Zoom_Menu);
- Gtk_New(Main_Window.Zoom_Menu_Item, "Zoom");
- Gtk_New(Main_Window.Zoom_Foreward_Item, "Zoom avant");
- Gtk_New(Main_Window.Zoom_Backward_item, "Zoom arrière");
- Gtk_New(Main_Window.Search_Menu);
- Gtk_New(Main_Window.Search_Menu_Item, "Search");
- Gtk_New(Main_Window.Ant_Colony_Menu_Item, "Ant Colony");
- Gtk_New(Main_Window.Ant_Colony_Conf_Menu_Item, "Ant Colony config");
- -- Initialize Canvas menu
- Gtk_New(Main_Window.Canvas_Menu);
- Gtk_New(Main_Window.Canvas_Menu_Item, "Canvas");
- Gtk_New(Main_Window.Clear_Canvas_Menu_Item, "Effacer le canvas");
- Gtk_New(Main_Window.Missils_Menu);
- Gtk_New(Main_Window.Missils_Menu_Item, "Missils");
- Gtk_New(Main_Window.Launch_all_Item, "Launch All");
- Gtk_New(Main_Window.Launch_One_Item, "Launch One");
- Gtk_New(Main_Window.Create_One_Item, "Create One");
- Gtk_New(Main_Window.Create_Group_Item, "Create Group");
- Gtk_New(Main_Window.Date_Label, "Data : no date");
- Set_Submenu(Main_Window.File_Menu_Item, Main_Window.File_Menu);
- Append(Main_Window.File_Menu, Main_Window.Exit_Menu_Item);
- Append(Main_Window.Main_Menu_Bar, Main_Window.File_Menu_Item);
- Set_Submenu(Main_Window.Zoom_Menu_Item, Main_Window.Zoom_Menu);
- Append(Main_Window.Zoom_Menu, Main_Window.Zoom_Foreward_item);
- Append(Main_Window.Zoom_Menu, Main_Window.Zoom_Backward_item);
- Append(Main_Window.Main_Menu_Bar, Main_Window.Zoom_Menu_item);
- Set_Submenu(Main_Window.Canvas_Menu_item, Main_Window.Canvas_menu);
- Append(Main_Window.Canvas_Menu, Main_Window.Clear_Canvas_Menu_item);
- Append(Main_Window.Main_Menu_Bar, Main_Window.Canvas_Menu_Item);
- Set_Submenu(Main_Window.Search_Menu_Item, Main_Window.Search_Menu);
- Append(Main_Window.Search_Menu, Main_Window.Ant_Colony_Menu_Item);
- Append(Main_Window.Search_Menu, Main_Window.Ant_Colony_Conf_Menu_Item);
- Append(Main_Window.Main_Menu_Bar, Main_Window.Search_Menu_item);
- Set_Submenu(Main_Window.Missils_Menu_Item, Main_Window.Missils_Menu);
- Append(Main_Window.Missils_Menu, Main_Window.Launch_All_Item);
- Append(Main_Window.Missils_Menu, Main_Window.Launch_One_Item);
- Append(Main_Window.Missils_Menu, Main_Window.Create_One_Item);
- Append(Main_Window.Missils_Menu, Main_Window.Create_Group_Item);
- Append(Main_Window.Main_Menu_Bar, Main_Window.Missils_Menu_item);
- Gtk_New(Main_Window.Host_Label, "Hostname : ");
- Gtk_New(Main_Window.Host_Entry);
- Gtk_New(Main_Window.Status_Bar);
- Gtk_New(Main_Window.Main_Frame);
- Gtk_New(Main_Window.Scrolled);
- --Set_Policy (Main_Window.Scrolled, Policy_Automatic, Policy_automatic);
- Add(Main_Window.Scrolled, Main_Window.Canvas);
- Add(Main_Window.Main_frame, Main_Window.Scrolled);
- Gtk_New_Hpaned(Main_Window.Main_Hpaned);
- Gtk_New(Main_Window.Right_Scroll);
- --Set_Policy (Main_Window.Right_Scroll, Policy_Automatic, Policy_automatic);
- Gtk_New (Main_Window.Model,
- (0 => GType_String));
- Gtk_New(Main_Window.Tree_View_Names, Main_Window.Model);
- Gtk_New (Text_Render);
- Gtk_New (Main_Window.Col);
- Main_Window.Num_col := Append_Column (Main_Window.Tree_View_Names, Main_Window.Col);
- Set_Title (Main_Window.Col, "Player Names");
- Pack_Start (Main_Window.Col, Text_Render, True);
- Set_Sizing (Main_Window.Col, Tree_View_Column_Autosize);
- Add_Attribute (Main_Window.Col, Text_Render, "text", 0);
- Add_With_Viewport (Main_Window.Right_Scroll, Main_Window.Tree_View_names);
- Pack_Start(Main_Window.Menu_Hbox, Main_Window.Main_Menu_Bar, False, False, 0);
- Pack_Start(Main_Window.Menu_Hbox, Main_Window.Host_label, False, False, 5);
- Pack_Start(Main_Window.Menu_Hbox, Main_Window.Host_Entry, False, False, 0);
- Pack_Start(Main_Window.Menu_Hbox, Main_Window.Date_Label, False, False, 10);
- Pack_Start(Main_Window.Main_Vbox, Main_Window.Menu_Hbox, False, False, 0);
- Add1(Main_Window.Main_Hpaned, Main_Window.Main_Frame);
- pack2(Main_Window.Main_Hpaned, Main_Window.Right_Scroll, False, False);
- Set_Position(Main_Window.Main_Hpaned, 1024);
- Pack_Start(Main_Window.Main_Vbox, Main_Window.Main_hpaned, True, True, 5);
- Pack_Start(Main_Window.Main_Vbox, Main_Window.Status_Bar, False, False, 0);
- Add(Main_Window.Main_Window, Main_Window.Main_Vbox);
- Realize (Main_Window.Canvas);
- Gdk_New (Green_Gc, Get_Window (Main_Window.Canvas));
- Set_Background(null, Main_Window);
- for J in Color_Names'Range loop
- Colors (J) := Parse (Color_Names (J).all);
- Alloc (Gtk.Widget.Get_Default_Colormap, Colors (J));
- end loop;
- Layout := Create_Pango_Layout (Main_Window.Main_Frame);
- Timeout_Id := Date_Timeout.Add(1000, Update'Access, Main_Window);
- Main_handlers.Connect
- (Main_Window.Exit_Menu_Item, "activate", Main_handlers.To_Marshaller (Main_Quit'access), Main_Window);
- Main_Return_Handlers.Connect
- (Main_Window.Main_window, "delete_event", Main_Return_Handlers.To_Marshaller (Main_destroy'access), Main_Window);
- Main_handlers.Connect
- (Main_Window.Zoom_Foreward_item, "activate", Main_Handlers.To_Marshaller (Zoom_In'Access), Main_Window);
- Main_Handlers.Connect
- (Main_Window.Zoom_Backward_item, "activate", Main_Handlers.To_Marshaller (Zoom_Out'Access), Main_Window);
- Main_handlers.Connect
- (Main_Window.Host_Entry, "activate",
- Main_handlers.To_Marshaller (Host_Entry_activate'access), Main_Window);
- Main_handlers.Connect
- (Main_Window.Create_One_item, "activate", Main_Handlers.To_Marshaller (Get_Missil_attributes'Access), Main_Window);
- Main_handlers.Connect
- (Main_Window.Launch_One_item, "activate", Main_Handlers.To_Marshaller (Get_one'Access), Main_Window);
- Main_handlers.Connect
- (Main_Window.Launch_All_item, "activate", Main_Handlers.To_Marshaller (Launch_All'Access), Main_Window);
- Main_handlers.Connect
- (Main_Window.Create_Group_item, "activate", Main_Handlers.To_Marshaller (Missil_Config_Group'Access), Main_Window);
- Main_handlers.Connect(Main_Window.Tree_View_names, "cursor_changed",
- Main_handlers.To_Marshaller (On_List_Selection'access), Main_Window);
- Main_handlers.Connect(Main_Window.Clear_Canvas_Menu_Item, "activate",
- Main_Handlers.To_Marshaller (Clear_Canvas'Access), Main_Window);
- Show_All(Main_Window.Main_Window);
- end Initialize;
- procedure Initialize(Main_Application : out Main_Access) is
- begin
- Main_Application := new Main_Application_Type;
- Initialize(Main_Application.Main_Window);
- end Initialize;
- function Add_Line
- (Model : access Gtk_Tree_Store_Record'Class;
- Text : String;
- Parent : Gtk_Tree_Iter := Null_Iter) return Gtk_Tree_Iter
- is
- Iter : Gtk_Tree_Iter;
- begin
- -- The implementation here is not the most efficient: it is often easier
- -- to import yourself the function gtk_tree_store_set with the correct
- -- set of arguments, as shown in the example in gtk-tree_store.ads
- Append (Model, Iter, Parent);
- Set (Model, Iter, 0, Text);
- return Iter;
- end Add_Line;
- procedure Create_wopr
- (widget : access Gtk_Widget_Record'class;
- Main_Window : Main_Window_access) is
- Degr_Lat : Gdouble := 0.0;
- Minu_Lat : Gdouble := 0.0;
- Seco_Lat : Gdouble := 0.0;
- Degr_Lon : Gdouble := 0.0;
- Minu_Lon : Gdouble := 0.0;
- Seco_Lon : Gdouble := 0.0;
- Lon_Unit : Float := 1024.0/(360.0*60.0*60.0);
- Lat_Unit : Float := 768.0/(180.0*60.0*60.0);
- begin
- Degr_Lat := Get_Value(Main_Window.Wopr_Window.Degr_Lat);
- Minu_Lat := Get_Value(Main_Window.Wopr_Window.Minu_Lat);
- Seco_Lat := Get_Value(Main_Window.Wopr_Window.Seco_Lat);
- Degr_Lon := Get_Value(Main_Window.Wopr_Window.Degr_Lon);
- Minu_Lon := Get_Value(Main_Window.Wopr_Window.Minu_Lon);
- Seco_Lon := Get_Value(Main_Window.Wopr_Window.Seco_Lon);
- Text_Io.New_Line;
- Text_Io.Put_Line("Initialize Wopr Attributes....");
- Text_Io.New_Line;
- if Degr_Lon >= 0.0 then
- Text_Io.Put_Line("Longitude := " & Float'Image(512.0 + Float(Degr_Lon)* (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit));
- Main_Window.Wopr.Wopr_Attributes.Source.X := 512.0 + Float(Degr_Lon) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit;
- else
- Text_Io.Put_Line("Longitude := " & Float'Image(512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit)));
- Main_Window.Wopr.Wopr_Attributes.Source.X := 512.0 - ((Float(Degr_Lon)*(-1.0)) * (3600.0*Lon_unit) + Float(Minu_Lon) * (60.0* Lon_Unit) +
- Float(Seco_Lon) * Lon_Unit);
- end if;
- if Degr_Lat >= 0.0 then
- Text_Io.Put_Line("Latitude := " & Float'Image(384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit));
- Main_Window.Wopr.Wopr_Attributes.Source.Y := 384.0 + Float(Degr_Lat)* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit;
- else
- Text_Io.Put_Line("Latitude := " & Float'Image(384.0 - ((Float(Degr_Lat)* (-1.0)) *(3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit)));
- Main_Window.Wopr.Wopr_Attributes.Source.Y := 384.0 - ((Float(Degr_Lat)*(-1.0))* (3600.0*Lat_unit) + Float(Minu_Lat) * (60.0* Lat_Unit) +
- Float(Seco_Lat) * Lat_Unit);
- end if;
- Main_Window.Process.Create_Wopr;
- Destroy(Main_Window.Wopr_Window.Dialog);
- end Create_Wopr;
- procedure Get_Wopr_Attributes(Main_Window : Main_Window_access) is
- begin
- Gtk_New(Main_Window.Wopr_Window.Dialog, Window_toplevel);
- Set_Position(Main_Window.Wopr_Window.dialog, Win_Pos_Center);
- Gtk_New(Main_Window.Wopr_Window.Degr_Lat, -90.0, 90.0, 1.0);
- Gtk_New(Main_Window.Wopr_Window.Minu_Lat, 0.0, 60.0, 1.0);
- Gtk_New(Main_Window.Wopr_Window.Seco_Lat, 0.0, 60.0, 1.0);
- Gtk_New(Main_Window.Wopr_Window.Degr_Lon, -180.0, 180.0, 1.0);
- Gtk_New(Main_Window.Wopr_Window.Minu_Lon, 0.0, 60.0, 1.0);
- Gtk_New(Main_Window.Wopr_Window.Seco_Lon, 0.0, 60.0, 1.0);
- Gtk_New_Hbox(Main_Window.Wopr_Window.Lat_Hbox);
- Gtk_New_Hbox(Main_Window.Wopr_Window.Lon_Hbox);
- Gtk_New(Main_Window.Wopr_Window.Lat_Label, "Latitude :");
- Gtk_New(Main_Window.Wopr_Window.Lon_Label, "Longitude :");
- Gtk_New_From_stock(Main_Window.Wopr_Window.Ok_button, Stock_Ok);
- Gtk_New_From_stock(Main_Window.Wopr_Window.Cancel_button, Stock_Cancel);
- Gtk_New_Hbox(Main_Window.Wopr_Window.Lat_Hbox);
- Gtk_New_Hbox(Main_Window.Wopr_Window.Lon_Hbox);
- Gtk_New_Hbox(Main_Window.Wopr_Window.button_Hbox);
- Gtk_New_Vbox(Main_Window.Wopr_Window.Main_Vbox);
- Pack_Start(Main_Window.Wopr_Window.Lat_Hbox, Main_Window.Wopr_Window.Lat_Label);
- Pack_Start(Main_Window.Wopr_Window.Lat_Hbox, Main_Window.Wopr_Window.Degr_lat);
- Pack_Start(Main_Window.Wopr_Window.Lat_Hbox, Main_Window.Wopr_Window.Minu_lat);
- Pack_Start(Main_Window.Wopr_Window.Lat_Hbox, Main_Window.Wopr_Window.Seco_lat);
- Pack_Start(Main_Window.Wopr_Window.Lon_Hbox, Main_Window.Wopr_Window.Lon_Label);
- Pack_Start(Main_Window.Wopr_Window.Lon_Hbox, Main_Window.Wopr_Window.Degr_Lon);
- Pack_Start(Main_Window.Wopr_Window.Lon_Hbox, Main_Window.Wopr_Window.Minu_Lon);
- Pack_Start(Main_Window.Wopr_Window.Lon_Hbox, Main_Window.Wopr_Window.Seco_Lon);
- Pack_Start(Main_Window.Wopr_Window.Button_Hbox, Main_Window.Wopr_Window.Ok_Button);
- Pack_Start(Main_Window.Wopr_Window.Button_Hbox, Main_Window.Wopr_Window.Cancel_button);
- Pack_Start(Main_Window.Wopr_Window.Main_Vbox, Main_Window.Wopr_Window.Lat_Hbox);
- Pack_Start(Main_Window.Wopr_Window.Main_Vbox, Main_Window.Wopr_Window.Lon_Hbox);
- Pack_Start(Main_Window.Wopr_Window.Main_Vbox, Main_Window.Wopr_Window.Button_Hbox);
- -- Marche pas.
- --Main_Return_Handlers.Connect
- -- (Main_Window.Wopr_Window.dialog, "delete_event", Main_Return_Handlers.To_Marshaller (Main_Destroy'access), Main_Window.all'access);
- Main_Handlers.Connect
- (Main_Window.Wopr_Window.Ok_Button, "clicked", Main_Handlers.To_Marshaller (Create_wopr'Access), Main_Window.all'access);
- Add(Main_Window.Wopr_Window.Dialog, Main_Window.Wopr_Window.Main_Vbox);
- Show_All(Main_Window.Wopr_Window.Dialog);
- end Get_Wopr_Attributes;
- procedure Add_Missil(Main_window : in Main_Window_Access;
- Source_X : in Gint;
- Source_Y : in Gint) is
- missil : constant Display_Item := new Display_Item_Record;
- begin
- Initialize_External_Missil (Main_Window, missil);
- Add_Canvas_Link (Main_Window.Canvas, missil, missil, "");
- Put (Main_Window.Canvas, Missil, Source_X, Source_Y);
- Refresh_Canvas (Main_Window.Canvas);
- Show_Item (Main_Window.Canvas, Missil);
- end Add_Missil;
- procedure Draw_Wopr_With_missils(Main_window : in Main_Window_Access) is
- begin
- Main_Window.Items_List := (others => null);
- Text_Io.Put_Line("TUTU 0");
- Main_Window.Num := 1;
- Text_Io.Put_Line("TUTU 1");
- Add_Wopr_Item(Main_Window.all'access);
- Text_Io.Put_Line("TUTU 2");
- if not Is_Empty(Main_Window.Wopr.Missils) then
- for I in 1..Last_Index(Main_Window.Wopr.Missils) loop
- Main_Window.One_Missil := Element(Main_Window.Wopr.Missils, I);
- Text_Io.Put_Line("Draw Missils");
- Text_Io.Put_Line("X : " & Gint'image(Gint(Main_Window.One_Missil.Missil_Attributes.Source.X)));
- Text_Io.Put_Line("Y : " & Gint'image(Gint(Main_Window.One_Missil.Missil_Attributes.Source.Y)));
- Text_Io.Put_Line("TUTU 3");
- Add_Missil_With_Cible(Main_Window.all'Access,
- Gint(Main_Window.One_Missil.Missil_Attributes.Source.X),
- Gint(Main_Window.One_Missil.Missil_Attributes.Source.Y),
- Gint(Main_Window.One_Missil.Missil_Attributes.Target.X),
- Gint(Main_Window.One_Missil.Missil_Attributes.Target.Y),
- Main_Window.One_Missil.Missil_Attributes.charge);
- Text_Io.Put_Line("TUTU 4");
- end loop;
- end if;
- end Draw_Wopr_With_Missils;
- type String_Access is access all String;
- procedure Free is
- new Ada.Unchecked_Deallocation(String, String_Access);
- task body Process_Type is
- task type Console_Type(Hostname : access String;
- Logname : access String;
- Passwd : access String) is
- entry Receive(Input : in String);
- entry Create_Wopr;
- entry Create_Missil;
- entry Launch_One(Num : in Positive);
- entry Launch_All;
- entry Refresh;
- end Console_Type;
- task body Console_Type is
- task type T_Socket_Names(Hostname : access string) is
- entry Start(Username : in String);
- end T_Socket_Names;
- task type T_Socket_Out(Hostname : access String;
- Logname : access String;
- Passwd : access String) is
- entry Create_Wopr;
- entry receive(Input : in String);
- entry Create_Missil;
- entry Launch_One(Num : in Positive);
- entry Launch_All;
- entry Refresh;
- end T_Socket_Out;
- task body T_Socket_Out is
- End_Of_Task : Boolean := False;
- Address : Sockets.Sock_Addr_Type;
- Socket : Sockets.Socket_type;
- Channel : Sockets.Stream_access;
- Output : String_Access;
- Missils_Count : Missil_Vector_Index_Type := 1;
- Missil_Attributes : Missil_Attributes_Type;
- Missils : Missils_Vectors.Vector;
- Missil : Missil_Type;
- Char : Character;
- begin
- Text_Io.Put_Line("Adresse : " & Hostname.all);
- Address.Addr :=
- Sockets.Addresses (Sockets.Get_Host_By_Name (Hostname.all), 1);
- Address.Port := 5876;
- Sockets.Create_Socket (Socket);
- Sockets.Set_Socket_Option
- (Socket,
- Sockets.Socket_Level,
- (Sockets.Reuse_Address, True));
- delay 0.2;
- Text_Io.Put("Avant connect...");
- Sockets.Connect_Socket (Socket, Address);
- Text_Io.Put("Après connect...");
- Channel := Sockets.stream(Socket);
- delay 0.2;
- Text_Io.Put_line("Socket_out started.");
- String'Output(Channel, Logname.all);
- Text_Io.Put_line("Sending logname");
- String'Output(Channel, Passwd.all);
- Text_Io.Put_line("Sending password");
- End_Of_task := not Boolean'Input(Channel);
- Text_Io.Put_line("receive status");
- Text_Io.Put_line("Debut");
- loop
- if Boolean'Input(Channel) then
- Clear(Main_Window.Wopr.Missils);
- Main_Window.Wopr.Wopr_Attributes := Wopr_Attributes_Type'Input(Channel);
- Add_Wopr_Item(Main_Window.all'access);
- if Boolean'Input(Channel) then
- Text_Io.Put_Line("receive missil count");
- Missils_Count := Missil_Vector_Index_Type'Input(Channel);
- Text_Io.Put_Line("missil count /= 0");
- for I in 1..Missils_Count loop
- Text_Io.Put_Line("receive missil");
- Missil_Attributes := Missil_Attributes_Type'Input(Channel);
- Text_Io.Put_Line("insert missil");
- Add_Missil_With_Cible(Main_Window.all'Access,
- Gint(Missil_Attributes.Source.X),
- Gint(Missil_Attributes.Source.Y),
- Gint(Missil_Attributes.Target.X),
- Gint(Missil_Attributes.Target.Y),
- Missil_Attributes.charge);
- Missil.Missil_Attributes := Missil_Attributes;
- Insert(Main_Window.Wopr.missils, Last_Index(Main_Window.Wopr.Missils)+ 1, Missil, 1);
- Text_Io.Put_Line("insert done.");
- end loop;
- end if;
- else
- Text_Io.Put_Line("Get Wopr...");
- Get_Wopr_Attributes(Main_Window.all'access);
- accept Create_Wopr do
- Main_Window.Wopr.Wopr_Attributes.Charge := 1.0;
- end Create_Wopr;
- Text_Io.Put_Line("Send Wopr...");
- Wopr_Attributes_Type'Output(Channel, Main_Window.Wopr.Wopr_Attributes);
- Text_Io.Put_Line("Draw Wopr...");
- Add_Wopr_Item(Main_Window.all'access);
- end if;
- if End_Of_Task then
- Text_Io.Put_line("End_of_task");
- end if;
- while not End_Of_Task loop
- Text_Io.Put_Line("Debut.");
- select
- accept Create_Missil do
- Command_Type'Output(Channel, Missil_Create);
- Missil_Attributes_type'Output(Channel, Main_Window.One_Missil.Missil_Attributes);
- if Boolean'Input(Channel) then
- Main_Window.Wopr.Wopr_Attributes.Charge :=
- Main_Window.Wopr.Wopr_Attributes.Charge -
- Main_Window.One_Missil.Missil_Attributes.Charge;
- insert(Main_Window.Wopr.Missils, Last_Index(Main_Window.Wopr.Missils) + 1, Main_Window.One_Missil, 1);
- Text_Io.Put_Line("insert missil");
- Text_Io.Put_Line("X : " & Gint'image(Gint(Main_Window.One_Missil.Missil_Attributes.Source.X)));
- Text_Io.Put_Line("Y : " & Gint'image(Gint(Main_Window.One_Missil.Missil_Attributes.Source.Y)));
- end if;
- end Create_Missil;
- or
- accept receive(Input : in String) do
- Command_Type'Output(Channel, Player_request);
- Text_Io.Put("push string");
- Free(Output);
- Output := new String ' (Input);
- String'Output(Channel, Output.all);
- Clear(Main_Window.Enemy);
- if Boolean'Input(Channel) then
- Missils_Count := Missil_Vector_Index_Type'Input(Channel);
- Text_Io.Put_Line("missil count /= 0");
- for I in 1..Missils_Count loop
- Text_Io.Put_Line("receive missil");
- Missil_Attributes := Missil_Attributes_Type'Input(Channel);
- Text_Io.Put_Line("Add missil");
- Text_Io.Put_Line("X : " & Gint'image(Gint(Missil_Attributes.Source.X)));
- Text_Io.Put_Line("Y : " & Gint'image(Gint(Missil_Attributes.Source.Y)));
- Text_Io.Put_Line("insert missil");
- Missil.Missil_Attributes := Missil_Attributes;
- Insert(Main_Window.enemy, Last_Index(Main_Window.enemy)+ 1, Missil, 1);
- Text_Io.Put_Line("insert done.");
- end loop;
- end if;
- end Receive;
- or
- accept Launch_One(Num : in Positive) do
- Command_Type'Output(Channel, Launch_One);
- Positive'Output(Channel, Num);
- end Launch_One;
- or
- accept Launch_all do
- Text_Io.Put_Line("Launch 4");
- Command_Type'Output(Channel, Launch_All);
- Text_Io.Put_Line("Launch N-3");
- end Launch_all;
- or
- accept Refresh do
- null;
- end Refresh;
- Clear(Main_Window.Enemy);
- Clear(Main_Window.Wopr.Missils);
- Command_Type'Output(Channel, Get_wopr);
- if Boolean'Input(Channel) then
- Main_Window.Wopr.Wopr_Attributes := Wopr_Attributes_Type'Input(Channel);
- if Boolean'Input(Channel) then
- Text_Io.Put_Line("receive missil count");
- Missils_Count := Missil_Vector_Index_Type'Input(Channel);
- Text_Io.Put_Line("missil count /= 0");
- for I in 1..Missils_Count loop
- Text_Io.Put_Line("receive missil");
- Missil.Missil_Attributes := Missil_Attributes_Type'Input(Channel);
- Text_Io.Put_Line("insert missil");
- Insert(Main_Window.Wopr.missils, Last_Index(Main_Window.Wopr.Missils)+ 1, Missil, 1);
- Text_Io.Put_Line("insert done.");
- end loop;
- end if;
- else
- End_Of_Task := True;
- end if;
- end select;
- delay 0.5;
- Text_Io.Put_Line("clear canvas...");
- Clear_canvas(null, Main_Window.all'access);
- Text_Io.Put_Line("clear canvas done.");
- Main_Window.External_Num := 1;
- Main_Window.Num := 1;
- Main_Window.Items_List := (others => null);
- Main_Window.External_Items_List := (others => null);
- if not End_Of_Task then
- Text_Io.Put_Line("Get char");
- --Text_Io.Get_Immediate(Char);
- Draw_Wopr_With_Missils(Main_Window.all'access);
- Text_Io.Put_Line("Get char");
- --Text_Io.Get_Immediate(Char);
- if not Is_Empty(Main_Window.enemy) then
- Text_Io.Put_Line("enemy not empty");
- for I in 1..Last_Index(Main_Window.enemy) loop
- Missil_Attributes := Element(Main_Window.enemy, I).Missil_attributes;
- Text_Io.Put_Line("Add missil");
- Text_Io.Put_Line("X : " & Gint'image(Gint(Missil_Attributes.Source.X)));
- Text_Io.Put_Line("Y : " & Gint'image(Gint(Missil_Attributes.Source.Y)));
- Add_Missil(Main_Window.all'Access,
- Gint(Missil_Attributes.Source.X),
- Gint(Missil_Attributes.Source.Y));
- Text_Io.Put_Line("add missil done.");
- Text_Io.Put_Line("Get char");
- --Text_Io.Get_Immediate(Char);
- end loop;
- end if;
- end if;
- end loop;
- End_Of_Task := False;
- end loop;
- Sockets.Close_Socket(Socket);
- end T_Socket_Out;
- task body T_Socket_Names is
- Address : Sockets.Sock_Addr_Type;
- Socket : Sockets.Socket_type;
- Channel : Sockets.Stream_access;
- Count : Natural := 0;
- Logname : String_access;
- Iter : Gtk_Tree_Iter := Null_Iter;
- begin
- Text_Io.New_Line;
- Text_Io.Put_line("DEMARRAGE DU THREAD NAMES");
- Address.Addr :=
- Sockets.Addresses (Sockets.Get_Host_By_Name (Hostname.all), 1);
- Address.Port := 5874;
- Sockets.Create_Socket (Socket);
- Sockets.Set_Socket_Option
- (Socket,
- Sockets.Socket_Level,
- (Sockets.Reuse_Address, True));
- delay 0.2;
- Text_Io.Put_line("NAMES Avant connect...");
- Sockets.Connect_Socket (Socket, Address);
- Text_Io.Put_line("NAMES Après connect...");
- Channel := Sockets.stream(Socket);
- accept Start(Username : in String) do
- String'Output(Channel, username);
- end Start;
- Count := Natural'Input(Channel);
- delay 0.2;
- loop
- case Command_Type'Input(Channel) is
- when Log_Lognames =>
- Count := Natural'Input(Channel);
- Text_Io.Put_Line("Clear list");
- Clear(Main_Window.Model);
- Text_Io.Put_line("input count NAMES...");
- if Count > 0 then
- Text_Io.Put_line("input count NAMES... /= 0");
- for I in 1..Count loop
- Xborg.Free(Logname);
- Logname := new String ' (String'Input(Channel));
- if Logname.all /= Main_Window.Logname.all then
- Text_Io.Put_Line("Add item");
- Iter := Add_Line(Main_Window.model, Logname.all);
- Text_Io.Put_Line("Item added");
- end if;
- end loop;
- Count := Count -1;
- end if;
- --Text_Io.Put_line("Avant show all");
- --Show_All(Main_Window.Tree_View_names);
- --Text_Io.Put_line("Après show all");
- when Refresh =>
- Main_Window.Process.Refresh;
- when others =>
- null;
- end case;
- end loop;
- end T_Socket_Names;
- Output_Deamon : T_Socket_Out(new String '(Hostname.all),
- Logname,
- new String ' (String(MD5.Digest(Passwd.all))));
- Logname_Deamon : T_Socket_names(Hostname);
- Need_All, Need_Refresh, Need_Wopr : Boolean := False;
- begin
- Logname_Deamon.start(Logname.all);
- loop
- select
- accept Create_Missil do
- Output_Deamon.Create_Missil;
- end Create_Missil;
- or
- accept Create_Wopr do
- Need_Wopr := True;
- --Output_Deamon.Create_Wopr;
- end Create_Wopr;
- or
- accept Receive(Input : in String) do
- Output_Deamon.Receive(Input);
- end Receive;
- or
- accept Launch_One(Num : in Positive) do
- Output_Deamon.Launch_One(Num);
- end Launch_One;
- or
- accept Launch_All do
- Need_All := True;
- Text_Io.Put_Line("Launch 2");
- --Output_Deamon.Launch_All;
- end Launch_All;
- or
- accept Refresh do
- Need_Refresh := True;
- --Output_Deamon.Refresh;
- end Refresh;
- end select;
- if Need_Wopr then
- Output_deamon.Create_Wopr;
- Need_Wopr := False;
- end if;
- if Need_Refresh then
- Output_deamon.Refresh;
- Need_Refresh := False;
- end if;
- if Need_All then
- Text_Io.Put_Line("Launch 3");
- Output_deamon.Launch_All;
- Text_Io.Put_Line("Launch N-2");
- Need_All := false;
- end if;
- end loop;
- end Console_Type;
- Console : access Console_Type;
- Need_All, Need_Refresh, Need_Wopr : Boolean := False;
- begin
- loop
- select
- accept Login(Address : in String;
- Logname : in String;
- Passwd : in String;
- Success : out boolean) do
- begin
- Console := new Console_Type(new String ' (Address),
- new String ' (Logname),
- new String ' (Passwd));
- Success := True;
- exception
- when others =>
- Success := False;
- end;
- end Login;
- or
- accept Receive(Content : in String) do
- begin
- Text_Io.Put_Line("Send text from : " & Content);
- Console.Receive(Content);
- end;
- end Receive;
- or
- accept Create_Wopr do
- Need_Wopr := True;
- end Create_Wopr;
- or
- accept Create_Missil do
- Console.Create_Missil;
- end Create_Missil;
- or
- accept Launch_One(Num : in Positive) do
- console.Launch_One(Num);
- end Launch_One;
- or
- accept Launch_All do
- Need_All := True;
- Text_Io.Put_Line("Launch 1");
- end Launch_all;
- or
- accept Refresh do
- Need_Refresh := True;
- end Refresh;
- end select;
- if Need_Wopr then
- Console.Create_Wopr;
- Need_Wopr := False;
- end if;
- if Need_Refresh then
- console.Refresh;
- Need_Refresh := False;
- end if;
- if Need_All then
- Text_Io.Put_Line("Launch 2");
- console.Launch_All;
- Text_Io.Put_Line("Launch N-1");
- Need_All := false;
- end if;
- end loop;
- end Process_Type;
- begin
- Gtk.Main.Init;
- Sockets.Initialize;
- end Warborg.Xborg;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement