func makeFurniturePanel(room *roomDef, viewer *RoomViewer) *FurniturePanel { var fp FurniturePanel fp.Room = room fp.RoomViewer = viewer fp.key_map = base.GetDefaultKeyMap() if room.Name == "" { room.Name = "name" } fp.name = gui.MakeTextEditLine("standard", room.Name, 300, 1, 1, 1, 1) if room.Floor.Path == "" { room.Floor.Path = base.Path(datadir) } fp.floor_path = gui.MakeFileWidget(room.Floor.Path.String(), imagePathFilter) if room.Wall.Path == "" { room.Wall.Path = base.Path(datadir) } fp.wall_path = gui.MakeFileWidget(room.Wall.Path.String(), imagePathFilter) var args []string algorithm.Map2(tags.RoomSizes, &args, func(a RoomSize) string { return a.String() }) fp.room_size = gui.MakeComboTextBox(args, 300) for i := range tags.RoomSizes { if tags.RoomSizes[i].String() == room.Size.String() { fp.room_size.SetSelectedIndex(i) break } } fp.VerticalTable = gui.MakeVerticalTable() fp.VerticalTable.Params().Spacing = 3 fp.VerticalTable.Params().Background.R = 0.3 fp.VerticalTable.Params().Background.B = 1 fp.VerticalTable.AddChild(fp.name) fp.VerticalTable.AddChild(fp.floor_path) fp.VerticalTable.AddChild(fp.wall_path) fp.VerticalTable.AddChild(fp.room_size) furn_table := gui.MakeVerticalTable() fnames := GetAllFurnitureNames() for i := range fnames { name := fnames[i] furn_table.AddChild(gui.MakeButton("standard", name, 300, 1, 1, 1, 1, func(t int64) { f := MakeFurniture(name) if f == nil { return } fp.furniture = f fp.furniture.temporary = true fp.Room.Furniture = append(fp.Room.Furniture, fp.furniture) dx, dy := fp.furniture.Dims() fp.drag_anchor.x = float32(dx) / 2 fp.drag_anchor.y = float32(dy) / 2 })) } fp.VerticalTable.AddChild(gui.MakeScrollFrame(furn_table, 300, 600)) return &fp }
func (w *WallPanel) Respond(ui *gui.Gui, group gui.EventGroup) bool { if w.VerticalTable.Respond(ui, group) { return true } if found, event := group.FindEvent(gin.DeleteOrBackspace); found && event.Type == gin.Press { algorithm.Choose(&w.room.WallTextures, func(wt *WallTexture) bool { return wt != w.wall_texture }) w.wall_texture = nil w.prev_wall_texture = nil return true } if found, event := group.FindEvent(gin.Escape); found && event.Type == gin.Press { w.onEscape() return true } if found, event := group.FindEvent(base.GetDefaultKeyMap()["flip"].Id()); found && event.Type == gin.Press { if w.wall_texture != nil { w.wall_texture.Flip = !w.wall_texture.Flip } return true } if found, event := group.FindEvent(gin.MouseWheelVertical); found { if w.wall_texture != nil && gin.In().GetKey(gin.Space).CurPressAmt() == 0 { w.wall_texture.Rot += float32(event.Key.CurPressAmt() / 100) } } if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press { if w.wall_texture != nil { w.wall_texture.temporary = false w.wall_texture = nil } else if w.wall_texture == nil { w.wall_texture = w.textureNear(event.Key.Cursor().Point()) if w.wall_texture != nil { w.prev_wall_texture = new(WallTexture) *w.prev_wall_texture = *w.wall_texture w.wall_texture.temporary = true wx, wy := w.viewer.BoardToWindowf(w.wall_texture.X, w.wall_texture.Y) px, py := event.Key.Cursor().Point() w.drag_anchor.X = float32(px) - wx w.drag_anchor.Y = float32(py) - wy } } return true } return false }