public void Append(Widget w)
 {
     if (isEmpty)
     {
         vbox.Remove(emptyLabel);
         isEmpty = false;
     }
     vbox.PackStart(w, false, false, 0);
 }
Exemplo n.º 2
0
        void OnCloseWindow(object sender, EventArgs args)
        {
            // Disconnect external signal handlers to prevent bloweup
            TaskManager.TaskAdded         -= OnTaskAdded;
            TaskManager.TaskDeleted       -= OnTaskDeleted;
            TaskManager.TaskStatusChanged -= OnTaskStatusChanged;

            // The following code has to be done for the MenuBar to
            // appear properly the next time this window is opened.
            if (menu_bar != null)
            {
                content_vbox.Remove(menu_bar);
                ActionManager am = Tomboy.ActionManager;
                am ["NewTaskAction"].Activated             -= OnNewTask;
                am ["OpenTaskAction"].Activated            -= OnOpenTask;
                am ["CloseTaskListWindowAction"].Activated -= OnCloseWindow;
                am ["DeleteTaskAction"].Activated          -= OnDeleteTask;
                am ["ShowTaskHelpAction"].Activated        -= OnShowHelp;
            }

            Tomboy.ActionManager.UI.RemoveActionGroup(action_group);
            Tomboy.ActionManager.UI.RemoveUi(menubar_ui);

            Hide();
            Destroy();
            instance = null;
        }
Exemplo n.º 3
0
    public Application()
    {
        Glade.XML gxml = new Glade.XML(null, "tiler.glade", null, null);
        gxml.Autoconnect(this);

        if (MainWindow == null || DrawingArea == null || AppBar == null)
        {
            throw new Exception("soem widgets not found");
        }

        DrawingArea.AddEvents((int)Gdk.EventMask.ButtonPressMask);
        DrawingArea.AddEvents((int)Gdk.EventMask.ButtonReleaseMask);
        DrawingArea.AddEvents((int)Gdk.EventMask.ButtonMotionMask);

        // libglade missed interactivity property :-/
        MainLayout.Remove(AppBar);
        AppBar = new AppBar(true, true, PreferencesType.Always);
        AppBar.UserResponse += new EventHandler(OnAppBarUserResponse);
        MainLayout.PackStart(AppBar, false, false, 0);
        AppBar.Show();

        TileGroupComboBox.Entry.Activated
            += new EventHandler(OnTileGroupComboBoxEntryActivated);

        MainWindow.Show();
    }
Exemplo n.º 4
0
        void LoadNews()
        {
            //can get called from async handler
            if (destroyed)
            {
                return;
            }

            foreach (var c in box.Children)
            {
                RemoveAccessibiltyTitledWidget(c);
                box.Remove(c);
                c.Destroy();
            }

            try {
                var news = GetNewsXml();
                if (news.FirstNode == null)
                {
                    var label = new Label(GettextCatalog.GetString("No news found."))
                    {
                        Xalign = 0, Xpad = 6
                    };
                    label.Accessible.Name = "WelcomePage.NewsFeed.NoNews";

                    box.PackStart(label, true, false, 0);
                }
                else
                {
                    int idx = 1;
                    foreach (var child in OnLoadNews(news).Take(limit))
                    {
                        child.Accessible.Name = string.Format("WelcomePage.NewsFeed.NewsItem-{0}", idx);
                        AddNewsItem(box, child);
                        idx++;
                    }
                }

                var spacerLabel = new Label();
                spacerLabel.Accessible.SetShouldIgnore(true);
                box.PackStart(spacerLabel, true, false, 4);
            } catch (Exception ex) {
                LoggingService.LogWarning("Error loading news feed.", ex);
            }
            this.ShowAll();
        }
        void LoadNews()
        {
            //can get called from async handler
            if (destroyed)
            {
                return;
            }

            foreach (var c in box.Children)
            {
                box.Remove(c);
                c.Destroy();
            }

            try {
                var news = GetNewsXml();
                if (news.FirstNode == null)
                {
                    var label = new Label(GettextCatalog.GetString("No news found."))
                    {
                        Xalign = 0, Xpad = 6
                    };

                    box.PackStart(label, true, false, 0);
                }
                else
                {
                    foreach (var child in OnLoadNews(news).Take(limit))
                    {
                        AddNewsItem(box, child);
                    }
                }
                box.PackStart(new Label(), true, false, 4);
            } catch (Exception ex) {
                LoggingService.LogWarning("Error loading news feed.", ex);
            }
            this.ShowAll();
        }
Exemplo n.º 6
0
 void ClearVBox( VBox vbox )
 {
     foreach (Widget widget in vbox.Children)
     {
         widget.Destroy();
         vbox.Remove( widget );
     }
 }
        public void LoadWidgets(ProjectBackend project)
        {
            if (project == null)
            {
                box.Hide();
                return;
            }

            box.Show();

            foreach (PaletteGroup g in groups.Values)
            {
                box.Remove(g);
                g.Destroy();
            }

            groups.Clear();

            foreach (string[] grp in visibleGroups)
            {
                AddOrGetGroup(grp[0], grp[1]);
            }

            ArrayList classes = new ArrayList();

            if (libraries == null)
            {
                foreach (ClassDescriptor klass in Registry.AllClasses)
                {
                    if (klass.SupportsGtkVersion(project.TargetGtkVersion))
                    {
                        classes.Add(klass);
                    }
                }
            }
            else if (project != null)
            {
                foreach (WidgetLibrary lib in libraries)
                {
                    bool isInternalLib = project.IsInternalLibrary(lib.Name);
                    foreach (ClassDescriptor cd in lib.AllClasses)
                    {
                        if (!cd.Deprecated && cd.Category.Length > 0 && (isInternalLib || !cd.IsInternal) && cd.SupportsGtkVersion(project.TargetGtkVersion))
                        {
                            classes.Add(cd);
                        }
                    }
                }
            }

            classes.Sort(this);

            foreach (ClassDescriptor klass in classes)
            {
                if (!groups.Contains(klass.Category))
                {
                    continue;
                }

                WidgetFactory factory;
                if (klass.Category == "window")
                {
                    factory = new WindowFactory(project, klass);
                }
                else
                {
                    factory = new WidgetFactory(project, klass);
                }

                AddOrGetGroup(klass.Category).Append(factory);
            }

            if (localActionsBox != null)
            {
                localActionsBox.Destroy();
            }
            if (globalActionsBox != null)
            {
                globalActionsBox.Destroy();
            }

            PaletteGroup widgetGroup = AddOrGetGroup("actions", Catalog.GetString("Actions"));

            localActionsBox  = new ActionGroupBox();
            globalActionsBox = new ActionGroupBox();
            widgetGroup.Append(localActionsBox);
            widgetGroup.Append(globalActionsBox);

            if (project != null)
            {
                widgetGroup.Sensitive = true;
                localActionsBox.SetActionGroups(selection != null ? selection.LocalActionGroups : null);
                globalActionsBox.SetActionGroups(project.ActionGroups);
            }
            else
            {
                widgetGroup.Sensitive = false;
                localActionsBox.SetActionGroups(null);
                globalActionsBox.SetActionGroups(null);
            }

            // This is a workaround. In looks like the palette is not correctly
            // redrawn if it is rebuilt while it is not visible (the dock is hidden in MD).
            GLib.Idle.Add(delegate
            {
                ShowAll();
                return(false);
            });
        }
Exemplo n.º 8
0
        public override void Clicked()
        {
            Box       tmpBox, tmpBox2;
            Alignment tmpAlign;
            Box       vbox = new Gtk.VBox();

            vbox.Spacing = 3;
            Box hbox = new Gtk.HBox();

            hbox.Spacing = 3;

            Box dungeonVreContainer         = new Gtk.VBox();
            Box roomVreContainer            = new Gtk.VBox();
            ValueReferenceEditor dungeonVre = null;
            ValueReferenceEditor roomVre    = null;

            Alignment frame             = new Alignment(0, 0, 0, 0);
            var       dungeonSpinButton = new SpinButton(0, 15, 1);
            var       floorSpinButton   = new SpinButton(0, 15, 1);
            var       roomSpinButton    = new SpinButtonHexadecimal(0, 255, 1);

            roomSpinButton.Digits = 2;
            Minimap minimap = null;

            System.Action RoomChanged = () => {
                Dungeon dungeon = minimap.Map as Dungeon;
                Room    room    = minimap.GetRoom();

                roomSpinButton.Value = room.Index & 0xff;

                var vrs = new List <ValueReference>();
                vrs.Add(new StreamValueReference("Up", room.Index & 0xff, 0, 0, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Right", room.Index & 0xff, 1, 1, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Down", room.Index & 0xff, 2, 2, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Left", room.Index & 0xff, 3, 3, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Key", room.Index & 0xff, 4, 4, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Chest", room.Index & 0xff, 5, 5, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Boss", room.Index & 0xff, 6, 6, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Dark", room.Index & 0xff, 7, 7, DataValueType.ByteBit));

                Stream stream = Project.GetBinaryFile("rooms/" + Project.GameString + "/group" + dungeon.Group + "DungeonProperties.bin");
                foreach (StreamValueReference r in vrs)
                {
                    r.SetStream(stream);
                }

                if (roomVre != null)
                {
                    roomVreContainer.Remove(roomVre);
                }

                var vrg = new ValueReferenceGroup(vrs);
                roomVre = new ValueReferenceEditor(Project, vrg, 4, "Minimap Data");

                roomVreContainer.Add(roomVre);
            };

            System.Action DungeonChanged = () => {
                Dungeon dungeon = Project.GetIndexedDataType <Dungeon>(dungeonSpinButton.ValueAsInt);

                floorSpinButton.Adjustment.Upper = dungeon.NumFloors - 1;
                if (floorSpinButton.ValueAsInt >= dungeon.NumFloors)
                {
                    floorSpinButton.Value = dungeon.NumFloors - 1;
                }

                var vrs = new List <ValueReference>();
                vrs.Add(new ValueReference("Group", 0, DataValueType.String, false));
                vrs.Add(new ValueReference("Wallmaster dest room", 0, DataValueType.Byte));
                vrs.Add(new ValueReference("Bottom floor layout", 0, DataValueType.Byte, false));
                vrs.Add(new ValueReference("# of floors", 0, DataValueType.Byte, false));
                vrs.Add(new ValueReference("Base floor name", 0, DataValueType.Byte));
                vrs.Add(new ValueReference("Floors unlocked with compass", 0, DataValueType.Byte));

                Data data = dungeon.DataStart;
                foreach (ValueReference r in vrs)
                {
                    r.SetData(data);
                    data = data.NextData;
                }

                // Remove last ValueReferenceEditor
                if (dungeonVre != null)
                {
                    dungeonVreContainer.Remove(dungeonVre);
                }

                var vrg = new ValueReferenceGroup(vrs);
                dungeonVre = new ValueReferenceEditor(Project, vrg, "Base Data");

                dungeonVre.AddDataModifiedHandler(() => {
                    floorSpinButton.Adjustment.Upper = dungeon.NumFloors;
                    minimap.GenerateImage();
                    RoomChanged();
                });

                // Replace the "group" option with a custom widget for finer
                // control.
                SpinButton groupSpinButton = new SpinButton(4, 5, 1);
                groupSpinButton.Value         = dungeon.Group;
                groupSpinButton.ValueChanged += (c, d) => {
                    vrg.SetValue("Group", ">wGroup" + groupSpinButton.ValueAsInt + "Flags");
                };
                dungeonVre.ReplaceWidget(0, groupSpinButton);
                dungeonVre.ShowAll();

                // Tooltips
                dungeonVre.SetTooltip(0, "Also known as the high byte of the room index.");
                dungeonVre.SetTooltip(1, "The low byte of the room index wallmasters will send you to.");
                dungeonVre.SetTooltip(2, "The index of the layout for the bottom floor. Subsequent floors will use subsequent indices.");
                dungeonVre.SetTooltip(4, "Determines what the game will call the bottom floor. For a value of:\n$00: The bottom floor is 'B3'.\n$01: The bottom floor is 'B2'.\n$02: The bottom floor is 'B1'.\n$03: The bottom floor is 'F1'.");
                dungeonVre.SetTooltip(5, "A bitset of floors that will appear on the map when the compass is obtained.\n\nEg. If this is $05, then floors 0 and 2 will be unlocked (bits 0 and 2 are set).");

                dungeonVreContainer.Add(dungeonVre);
                minimap.SetMap(dungeon);
                minimap.Floor = floorSpinButton.ValueAsInt;

                RoomChanged();
            };

            dungeonSpinButton.ValueChanged += (a, b) => { DungeonChanged(); };
            floorSpinButton.ValueChanged   += (a, b) => { DungeonChanged(); };

            frame.Add(vbox);

            tmpBox = new Gtk.HBox();
            tmpBox.Add(new Gtk.Label("Dungeon "));
            tmpBox.Add(dungeonSpinButton);
            tmpBox.Add(new Gtk.Label("Floor "));
            tmpBox.Add(floorSpinButton);
            tmpAlign = new Alignment(0, 0, 0, 0);
            tmpAlign.Add(tmpBox);

            vbox.Add(tmpAlign);
            vbox.Add(hbox);

            // Leftmost column

            tmpBox = new VBox();
            tmpBox.Add(dungeonVreContainer);

            var addFloorButton = new Button("Add Floor");

            addFloorButton.Image    = new Gtk.Image(Gtk.Stock.Add, Gtk.IconSize.Button);
            addFloorButton.Clicked += (a, b) => {
                Dungeon dungeon = minimap.Map as Dungeon;

                int newFloorIndex = dungeon.FirstLayoutIndex + dungeon.NumFloors;

                // Shift all subsequent layouts 64 bytes down in the data file
                Stream layoutFile = Project.GetBinaryFile("rooms/" + Project.GameString + "/dungeonLayouts.bin");
                layoutFile.SetLength(layoutFile.Length + 64);
                for (int i = (int)layoutFile.Length / 64 - 1; i > newFloorIndex; i--)
                {
                    var buf = new byte[64];
                    layoutFile.Position = (i - 1) * 64;
                    layoutFile.Read(buf, 0, 64);
                    layoutFile.Write(buf, 0, 64);
                }

                // Clear the new floor
                layoutFile.Position = newFloorIndex * 64;
                for (int j = 0; j < 64; j++)
                {
                    layoutFile.WriteByte(0);
                }

                // Shift each dungeon's "FirstLayoutIndex" to match the shifted layouts.
                for (int i = 0; i < Project.GetNumDungeons(); i++)
                {
                    Dungeon d2 = Project.GetIndexedDataType <Dungeon>(i);
                    if (d2.FirstLayoutIndex >= newFloorIndex)
                    {
                        d2.FirstLayoutIndex++;
                    }
                }

                dungeon.NumFloors     = dungeon.NumFloors + 1;
                floorSpinButton.Value = dungeon.NumFloors - 1;
                DungeonChanged();
            };
            tmpAlign = new Gtk.Alignment(0.5f, 0, 0, 0);
            tmpAlign.Add(addFloorButton);
            tmpBox.Add(tmpAlign);

            var removeFloorButton = new Button("Remove Top Floor");

            removeFloorButton.Image    = new Gtk.Image(Gtk.Stock.Remove, Gtk.IconSize.Button);
            removeFloorButton.Clicked += (a, b) => {
                Dungeon dungeon = minimap.Map as Dungeon;

                if (dungeon.NumFloors <= 1)
                {
                    return;
                }

                Gtk.MessageDialog d = new MessageDialog(null,
                                                        DialogFlags.DestroyWithParent,
                                                        MessageType.Warning,
                                                        ButtonsType.YesNo,
                                                        "Are you quite certain that you wish to delete the top floor of this dungeon?");
                var response = (ResponseType)d.Run();
                d.Destroy();

                if (response == Gtk.ResponseType.Yes)
                {
                    int deletedFloorIndex = dungeon.FirstLayoutIndex + dungeon.NumFloors - 1;

                    // Shift all subsequent layouts 64 bytes up in the data file
                    Stream layoutFile = Project.GetBinaryFile("rooms/" + Project.GameString + "/dungeonLayouts.bin");
                    for (int i = deletedFloorIndex; i < layoutFile.Length / 64 - 1; i++)
                    {
                        var buf = new byte[64];
                        layoutFile.Position = (i + 1) * 64;
                        layoutFile.Read(buf, 0, 64);
                        layoutFile.Position = i * 64;
                        layoutFile.Write(buf, 0, 64);
                    }

                    layoutFile.SetLength(layoutFile.Length - 64);

                    // Shift each dungeon's "FirstLayoutIndex" to match the shifted layouts.
                    for (int i = 0; i < Project.GetNumDungeons(); i++)
                    {
                        Dungeon d2 = Project.GetIndexedDataType <Dungeon>(i);
                        if (d2.FirstLayoutIndex > deletedFloorIndex)
                        {
                            d2.FirstLayoutIndex--;
                        }
                    }

                    dungeon.NumFloors = dungeon.NumFloors - 1;

                    DungeonChanged();
                }
            };
            tmpAlign = new Gtk.Alignment(0.5f, 0, 0, 0);
            tmpAlign.Add(removeFloorButton);
            tmpBox.Add(tmpAlign);

            hbox.Add(tmpBox);

            // Middle column (minimap)

            minimap = new Minimap();
            minimap.TileSelectedEvent += (sender) => {
                RoomChanged();
            };

            hbox.Add(minimap);

            // Rightmost column

            tmpAlign = new Alignment(0, 0, 0, 0);
            tmpAlign.Add(roomVreContainer);

            tmpBox2 = new HBox();
            tmpBox2.Add(new Gtk.Label("Room "));
            roomSpinButton.ValueChanged += (a, b) => {
                (minimap.Map as Dungeon).SetRoom(minimap.SelectedX, minimap.SelectedY,
                                                 minimap.Floor, roomSpinButton.ValueAsInt);
                minimap.GenerateImage();
                RoomChanged();
            };
            tmpBox2.Add(roomSpinButton);

            tmpBox = new VBox();
            tmpBox.Add(tmpBox2);
            tmpBox.Add(tmpAlign);

            hbox.Add(tmpBox);



            Window w = new Window(null);

            w.Add(frame);
            w.ShowAll();

            Map map = manager.GetActiveMap();

            if (map is Dungeon)
            {
                dungeonSpinButton.Value = map.Index;
            }

            DungeonChanged();
        }
Exemplo n.º 9
0
 void RemoveProgressBar()
 {
     m_GtkvBoxMain.Remove(m_GtkProgressBox);
     this.ShowAll();
 }
Exemplo n.º 10
0
        public override void Clicked()
        {
            Box tmpBox, tmpBox2;
            Alignment tmpAlign;
            Box vbox = new Gtk.VBox();
            vbox.Spacing = 3;
            Box hbox = new Gtk.HBox();
            hbox.Spacing = 3;

            Box dungeonVreContainer = new Gtk.VBox();
            Box roomVreContainer = new Gtk.VBox();
            ValueReferenceEditor dungeonVre = null;
            ValueReferenceEditor roomVre = null;

            Alignment frame = new Alignment(0,0,0,0);
            var dungeonSpinButton = new SpinButton(0,15,1);
            var floorSpinButton = new SpinButton(0,15,1);
            var roomSpinButton = new SpinButtonHexadecimal(0,255,1);
            roomSpinButton.Digits = 2;
            Minimap minimap = null;

            System.Action RoomChanged = () => {
                Dungeon dungeon = minimap.Map as Dungeon;
                Room room = minimap.GetRoom();

                roomSpinButton.Value = room.Index&0xff;

                var vrs = new List<ValueReference>();
                vrs.Add(new StreamValueReference("Up", room.Index&0xff, 0,0, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Right", room.Index&0xff, 1,1, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Down", room.Index&0xff, 2,2, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Left", room.Index&0xff, 3,3, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Key", room.Index&0xff, 4,4, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Chest", room.Index&0xff, 5,5, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Boss", room.Index&0xff, 6,6, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Dark", room.Index&0xff, 7,7, DataValueType.ByteBit));

                Stream stream = Project.GetBinaryFile("rooms/group" + dungeon.Group + "DungeonProperties.bin");
                foreach (StreamValueReference r in vrs)
                    r.SetStream(stream);

                if (roomVre != null)
                    roomVreContainer.Remove(roomVre);

                var vrg = new ValueReferenceGroup(vrs);
                roomVre = new ValueReferenceEditor(Project, vrg, 4, "Minimap Data");

                roomVreContainer.Add(roomVre);
            };

            System.Action DungeonChanged = () => {
                Dungeon dungeon = Project.GetIndexedDataType<Dungeon>(dungeonSpinButton.ValueAsInt);

                floorSpinButton.Adjustment.Upper = dungeon.NumFloors-1;
                if (floorSpinButton.ValueAsInt >= dungeon.NumFloors)
                    floorSpinButton.Value = dungeon.NumFloors-1;

                var vrs = new List<ValueReference>();
                vrs.Add(new ValueReference("Group", 0, DataValueType.String, false));
                vrs.Add(new ValueReference("Wallmaster dest room", 0, DataValueType.Byte));
                vrs.Add(new ValueReference("Bottom floor layout", 0, DataValueType.Byte, false));
                vrs.Add(new ValueReference("# of floors", 0, DataValueType.Byte, false));
                vrs.Add(new ValueReference("Base floor name", 0, DataValueType.Byte));
                vrs.Add(new ValueReference("Floors unlocked with compass", 0, DataValueType.Byte));

                Data data = dungeon.DataStart;
                foreach (ValueReference r in vrs) {
                    r.SetData(data);
                    data = data.NextData;
                }

                // Remove last ValueReferenceEditor
                if (dungeonVre != null)
                    dungeonVreContainer.Remove(dungeonVre);

                var vrg = new ValueReferenceGroup(vrs);
                dungeonVre = new ValueReferenceEditor(Project, vrg, "Base Data");

                dungeonVre.AddDataModifiedHandler(() => {
                            floorSpinButton.Adjustment.Upper = dungeon.NumFloors;
                            minimap.GenerateImage();
                            RoomChanged();
                        });

                // Replace the "group" option with a custom widget for finer
                // control.
                SpinButton groupSpinButton = new SpinButton(4,5,1);
                groupSpinButton.Value = dungeon.Group;
                groupSpinButton.ValueChanged += (c,d) => {
                    vrg.SetValue("Group", ">wGroup" + groupSpinButton.ValueAsInt + "Flags");
                };
                dungeonVre.ReplaceWidget(0, groupSpinButton);
                dungeonVre.ShowAll();

                // Tooltips
                dungeonVre.AddTooltip(0, "Also known as the high byte of the room index.");
                dungeonVre.AddTooltip(1, "The low byte of the room index wallmasters will send you to.");
                dungeonVre.AddTooltip(2, "The index of the layout for the bottom floor. Subsequent floors will use subsequent indices.");
                dungeonVre.AddTooltip(4, "Determines what the game will call the bottom floor. For a value of:\n$00: The bottom floor is 'B3'.\n$01: The bottom floor is 'B2'.\n$02: The bottom floor is 'B1'.\n$03: The bottom floor is 'F1'.");
                dungeonVre.AddTooltip(5, "A bitset of floors that will appear on the map when the compass is obtained.\n\nEg. If this is $05, then floors 0 and 2 will be unlocked (bits 0 and 2 are set).");

                dungeonVreContainer.Add(dungeonVre);
                minimap.SetMap(dungeon);
                minimap.Floor = floorSpinButton.ValueAsInt;

                RoomChanged();
            };

            dungeonSpinButton.ValueChanged += (a,b) => { DungeonChanged(); };
            floorSpinButton.ValueChanged += (a,b) => { DungeonChanged(); };

            frame.Add(vbox);

            tmpBox = new Gtk.HBox();
            tmpBox.Add(new Gtk.Label("Dungeon "));
            tmpBox.Add(dungeonSpinButton);
            tmpBox.Add(new Gtk.Label("Floor "));
            tmpBox.Add(floorSpinButton);
            tmpAlign = new Alignment(0,0,0,0);
            tmpAlign.Add(tmpBox);

            vbox.Add(tmpAlign);
            vbox.Add(hbox);

            // Leftmost column

            tmpBox = new VBox();
            tmpBox.Add(dungeonVreContainer);

            var addFloorButton = new Button("Add Floor");
            addFloorButton.Image = new Gtk.Image(Gtk.Stock.Add, Gtk.IconSize.Button);
            addFloorButton.Clicked += (a,b) => {
                Dungeon dungeon = minimap.Map as Dungeon;

                int newFloorIndex = dungeon.FirstLayoutIndex + dungeon.NumFloors;

                // Shift all subsequent layouts 64 bytes down in the data file
                Stream layoutFile = Project.GetBinaryFile("rooms/dungeonLayouts.bin");
                layoutFile.SetLength(layoutFile.Length+64);
                for (int i=(int)layoutFile.Length/64-1; i>newFloorIndex; i--) {
                    var buf = new byte[64];
                    layoutFile.Position = (i-1)*64;
                    layoutFile.Read(buf, 0, 64);
                    layoutFile.Write(buf, 0, 64);
                }

                // Clear the new floor
                layoutFile.Position = newFloorIndex*64;
                for (int j=0;j<64;j++)
                    layoutFile.WriteByte(0);

                // Shift each dungeon's "FirstLayoutIndex" to match the shifted layouts.
                for (int i=0; i<Project.GetNumDungeons(); i++) {
                    Dungeon d2 = Project.GetIndexedDataType<Dungeon>(i);
                    if (d2.FirstLayoutIndex >= newFloorIndex)
                        d2.FirstLayoutIndex++;
                }

                dungeon.NumFloors = dungeon.NumFloors+1;
                floorSpinButton.Value = dungeon.NumFloors-1;
                DungeonChanged();
            };
            tmpAlign = new Gtk.Alignment(0.5f,0,0,0);
            tmpAlign.Add(addFloorButton);
            tmpBox.PackStart(tmpAlign);

            var removeFloorButton = new Button("Remove Top Floor");
            removeFloorButton.Image = new Gtk.Image(Gtk.Stock.Remove, Gtk.IconSize.Button);
            removeFloorButton.Clicked += (a,b) => {
                Dungeon dungeon = minimap.Map as Dungeon;

                if (dungeon.NumFloors <= 1)
                    return;

                Gtk.MessageDialog d = new MessageDialog(null,
                        DialogFlags.DestroyWithParent,
                        MessageType.Warning,
                        ButtonsType.YesNo,
                        "Are you quite certain that you wish to delete the top floor of this dungeon?");
                var response = (ResponseType)d.Run();
                d.Destroy();

                if (response == Gtk.ResponseType.Yes) {
                    int deletedFloorIndex = dungeon.FirstLayoutIndex + dungeon.NumFloors-1;

                    // Shift all subsequent layouts 64 bytes up in the data file
                    Stream layoutFile = Project.GetBinaryFile("rooms/dungeonLayouts.bin");
                    for (int i=deletedFloorIndex; i<layoutFile.Length/64-1; i++) {
                        var buf = new byte[64];
                        layoutFile.Position = (i+1)*64;
                        layoutFile.Read(buf, 0, 64);
                        layoutFile.Position = i*64;
                        layoutFile.Write(buf, 0, 64);
                    }

                    layoutFile.SetLength(layoutFile.Length-64);

                    // Shift each dungeon's "FirstLayoutIndex" to match the shifted layouts.
                    for (int i=0; i<Project.GetNumDungeons(); i++) {
                        Dungeon d2 = Project.GetIndexedDataType<Dungeon>(i);
                        if (d2.FirstLayoutIndex > deletedFloorIndex)
                            d2.FirstLayoutIndex--;
                    }

                    dungeon.NumFloors = dungeon.NumFloors-1;

                    DungeonChanged();
                }
            };
            tmpAlign = new Gtk.Alignment(0.5f,0,0,0);
            tmpAlign.Add(removeFloorButton);
            tmpBox.PackStart(tmpAlign);

            hbox.PackStart(tmpBox);

            // Middle column (minimap)

            minimap = new Minimap();
            minimap.TileSelectedEvent += (sender) => {
                RoomChanged();
            };

            hbox.PackStart(minimap);

            // Rightmost column

            tmpAlign = new Alignment(0,0,0,0);
            tmpAlign.Add(roomVreContainer);

            tmpBox2 = new HBox();
            tmpBox2.Add(new Gtk.Label("Room "));
            roomSpinButton.ValueChanged += (a,b) => {
                (minimap.Map as Dungeon).SetRoom(minimap.SelectedX, minimap.SelectedY,
                        minimap.Floor, roomSpinButton.ValueAsInt);
                minimap.GenerateImage();
                RoomChanged();
            };
            tmpBox2.Add(roomSpinButton);

            tmpBox = new VBox();
            tmpBox.Add(tmpBox2);
            tmpBox.Add(tmpAlign);

            hbox.PackStart(tmpBox);

            Window w = new Window(null);
            w.Add(frame);
            w.ShowAll();

            Map map = manager.GetActiveMap();
            if (map is Dungeon)
                dungeonSpinButton.Value = map.Index;

            DungeonChanged();
        }
Exemplo n.º 11
0
		protected void OnFullscreenActionActivated (object sender, EventArgs e)
		{
			Button b = (Button)sender;
			Window w = new Window("Content Type Viewer");
			w.DeleteEvent += delegate(object o, DeleteEventArgs args) {
				_window_vbox.Remove(this);
				_parent.Add(this);
				b.ShowAll();
			};
			w.SetSizeRequest(800,600);
			_parent = (VBox)this.Parent;
			_parent.Remove(this);
			_window_vbox = new Gtk.VBox();
			w.Add(_window_vbox);
			_window_vbox.Add(this);
			w.ShowAll();
			w.Show();
			b.HideAll();
		}