Fields of Mistria — Vanilla GML Reference FoM v1.0.8

obj_museum.gml

object_create(
    "obj_museum",
    object_reserve("par_ledger"),
    {
        sprite_index: spr_museum_entryhall_ledger_spring,
        create: function() {
            depth = get_instance_depth(y, -10);

            event_inherit(ObjectEvent.Create);

            self.set_darkness_animation(spr_museum_entryhall_ledger_darkness);
            self.setup_offsets("museum");

            self.menu_inst = undefined;
            self.background = undefined;

            self.bubble_icon_small = spr_ui_bark_icon_archaeology_small;
            self.bubble_icon_big = spr_ui_bark_icon_archaeology;

            function spawn_menu() {
                self.mcp = new MultipleChoicePopup("misc_local/donate", spr_ui_generic_museum_sub_icon);
                self.menu_inst = undefined;

                //
                if self.background == undefined {
                    self.background = self.mcp.popup.background;
                    self.mcp.popup.background = undefined;

                    self.background.background.set_think_callback(function() {
                        if self.mcp.popup.close_requested && self.menu_inst == undefined {
                            ANCHOR.free_node(self.background.background);
                            self.background = undefined;
                        } else {
                            ANCHOR.open_menus.for_each(function(menu) {
                                if menu.background != undefined && !menu.close_requested {
                                    menu.background.out_now();
                                    self.background.background.set_layer(menu.background.background.layer);
                                }
                            });
                        }
                    }, undefined, true);
                }

                self.mcp.option("misc_local/donate", function() {
                    self.menu_inst = spawn_museum_donation_menu();

                    self.menu_inst.on_free = function() {
                        self.menu_inst.left.drain().for_each(function(item) {
                            drop_item(item, obj_ari.x, obj_ari.y);
                        });

                        await_popup(self.spawn_menu);
                    }
                });
                self.mcp.buttons.last().add_width(40);

                self.mcp.option("misc_local/view_wings", function() {
                    self.menu_inst = ANCHOR.spawn_menu(Menu.Museum);

                    self.menu_inst.on_free = function() {
                        self.spawn_menu();
                    }
                })
                self.mcp.buttons.last().add_width(40);
            }

            self.register_interaction(
                InputId.Interact,
                "misc_local/interact",
                function() {
                    self.spawn_menu();
                },
            );
        },
    }
);