/tools/client.py

https://bitbucket.org/zielmicha/colobot-py
Python | 51 lines | 24 code | 9 blank | 18 comment | 1 complexity | 1b41a7f2dabb184d31b4bfed1d758e6c MD5 | raw file
  1. #!/usr/bin/python
  2. # Copyright (C) 2012, Michal Zielinski <michal@zielinscy.org.pl>
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. import sys, os
  17. sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'src'))
  18. import colobot
  19. colobot.setup_path()
  20. import colobot.client
  21. import colobot.client.ui
  22. import getpass
  23. import logging
  24. logging.basicConfig(level=logging.DEBUG)
  25. client = colobot.client.Client(sys.argv[1])
  26. if not client.authenticate_with_session():
  27. login = raw_input('Username: ')
  28. password = getpass.getpass()
  29. client.authenticate_and_save(login, password)
  30. def open_window(name):
  31. global win
  32. win = colobot.client.ui.UIWindow(client, name)
  33. win.setup()
  34. win.loop()
  35. client.create_game('game')
  36. client.load_scene('game', 'scene103.txt')
  37. #client.load_terrain('game', 'relief15.png')
  38. #client.rpc.call.create_static_object('game', 'wheeled-transporter.model')
  39. #client.rpc.call.create_static_object('game', 'wheeled-transporter.model')
  40. open_window('game')
  41. from IPython import embed
  42. embed()