controller.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. require "level.rb"
  2. class Controller
  3. attr_reader :tilemap_paint_tool, :tilemap_select_tool, :zoom_tool, :objmap_select_tool, :recent_files
  4. def initialize()
  5. @tilemap_paint_tool = TileMapPaintTool.new()
  6. @tilemap_select_tool = TileMapSelectTool.new()
  7. @zoom_tool = ZoomTool.new()
  8. @objmap_select_tool = ObjMapSelectTool.new()
  9. end
  10. def set_tilemap_paint_tool()
  11. $gui.workspace.set_tool(@tilemap_paint_tool.to_tool())
  12. $gui.set_tool_icon(:tilemap_paint)
  13. end
  14. def set_tilemap_select_tool()
  15. $gui.workspace.set_tool(@tilemap_select_tool.to_tool())
  16. $gui.set_tool_icon(:tilemap_select)
  17. end
  18. def set_zoom_tool()
  19. $gui.workspace.set_tool(@zoom_tool.to_tool())
  20. $gui.set_tool_icon(:zoom)
  21. end
  22. def set_objmap_select_tool()
  23. $gui.workspace.set_tool(@objmap_select_tool.to_tool())
  24. $gui.set_tool_icon(:object_select)
  25. end
  26. def load_level(filename)
  27. level = Level.new_from_file(filename)
  28. level.activate($gui.workspace)
  29. end
  30. def save_level(filename)
  31. $gui.workspace.get_map().get_metadata().save(filename)
  32. end
  33. end
  34. # EOF #