Ejemplo n.º 1
0
        public override void Clicked()
        {
            Treasure.Project = Project;
            Chest.Project = Project;

            Gtk.Window win = new Window(WindowType.Toplevel);
            Alignment warningsContainer = new Alignment(0.1f,0.1f,0f,0f);

            VBox vbox = new VBox();

            var chestGui = new ChestEditorGui(manager);
            chestGui.SetRoom(manager.GetActiveRoom().Index);
            chestGui.Destroyed += (sender2, e2) => win.Destroy();

            Frame chestFrame = new Frame();
            chestFrame.Label = "Chest Data";
            chestFrame.Add(chestGui);

            var treasureGui = new TreasureEditorGui(manager);
            Frame treasureFrame = new Frame();
            treasureFrame.Label = "Treasure Data";
            treasureFrame.Add(treasureGui);

            System.Action UpdateWarnings = () => {
                VBox warningBox = new VBox();
                warningBox.Spacing = 4;

                System.Action<string> AddWarning = (s) => {
                    Image img = new Image(Stock.DialogWarning, IconSize.Button);
                    HBox hb = new HBox();
                    hb.Spacing = 10;
                    hb.Add(img);
                    Gtk.Label l = new Gtk.Label(s);
                    l.LineWrap = true;
                    hb.Add(l);
                    Alignment a = new  Alignment(0,0,0,0);
                    a.Add(hb);
                    warningBox.Add(a);
                };

                foreach (var c in warningsContainer.Children)
                    warningsContainer.Remove(c);

                int index = chestGui.GetTreasureIndex();
                if (index < 0)
                    return;

                if (!Treasure.IndexExists(index)) {
                    AddWarning("Treasure " + Wla.ToWord(index) + " does not exist.");
                }
                else {
                    if (index != treasureGui.Index)
                        AddWarning("Your treasure index is different\nfrom the chest you're editing.");

                    int spawnMode = (Treasure.GetTreasureByte(index, 0) >> 4)&7;

                    if (spawnMode != 3) {
                        AddWarning("Treasure " + Wla.ToWord(index) + " doesn't have spawn\nmode $3 (needed for chests).");
                    }

                    int yx = Chest.GetChestByte(chestGui.RoomIndex, 0);
                    int x=yx&0xf;
                    int y=yx>>4;
                    Room r = Project.GetIndexedDataType<Room>(chestGui.RoomIndex);
                    if (x >= r.Width || y >= r.Height || r.GetTile(x,y) != 0xf1) {
                        AddWarning("There is no chest at coordinates (" + x + "," + y + ").");
                    }
                }

                warningsContainer.Add(warningBox);

                win.ShowAll();
            };

            chestGui.SetTreasureEditor(treasureGui);
            chestGui.ChestChangedEvent += () => {
                UpdateWarnings();
            };
            treasureGui.TreasureChangedEvent += () => {
                UpdateWarnings();
            };

            HBox hbox = new Gtk.HBox();
            hbox.Spacing = 6;
            hbox.Add(chestFrame);
            hbox.Add(treasureFrame);

            Button okButton = new Gtk.Button();
            okButton.UseStock = true;
            okButton.Label = "gtk-ok";
            okButton.Clicked += (a,b) => {
                win.Destroy();
            };

            Alignment buttonAlign = new Alignment(0.5f,0.5f,0f,0f);
            buttonAlign.Add(okButton);

            vbox.Add(hbox);
            vbox.Add(warningsContainer);
            vbox.Add(buttonAlign);

            win.Add(vbox);

            UpdateWarnings();
            win.ShowAll();
        }
Ejemplo n.º 2
0
 public void ReleaseInnerWidget()
 {
     alignment.Remove(alignment.Child);
 }
Ejemplo n.º 3
0
        public override void Clicked()
        {
            Window w = new Window("Maple Appearance Locations");

            var minimapContainer = new Alignment(1.0f,1.0f,1.0f,1.0f);

            ComboBox comboBox = new ComboBox(
                    new string[] {
                    "Present (Ricky)",
                    "Present (Dimitri)",
                    "Present (Moosh)",
                    "Past"
                    });

            comboBox.Changed += (a,b) => {
                int i = comboBox.Active;
                Data data;
                Map map;

                if (i == 3) {
                    data = Project.GetData("maplePastLocations");
                    map = Project.GetIndexedDataType<WorldMap>(1);
                }
                else {
                    data = Project.GetData(Project.GetData("maplePresentLocationsTable", i*2).GetValue(0));
                    map = Project.GetIndexedDataType<WorldMap>(0);
                }

                var minimap = new MyMinimap(data);
                minimap.Width = map.MapWidth;
                minimap.Height = map.MapHeight;

                minimap.SetMap(map);
                minimap.Selectable = false;

                minimapContainer.Remove(minimapContainer.Child);
                minimapContainer.Add(minimap);
                minimapContainer.ShowAll();
            };
            if (manager.GetActiveMap().Group == 1)
                comboBox.Active = 3;
            else
                comboBox.Active = 0;

            VBox vbox = new VBox();
            vbox.Add(comboBox);
            vbox.Add(minimapContainer);

            w.Add(vbox);
            w.ShowAll();
        }