Advertisement
Guest User

Untitled

a guest
Jul 25th, 2014
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.25 KB | None | 0 0
  1. Python:
  2.     def add_remove_objects(self, chunk, object_type, remove, chunk_coords):
  3.         update_list = chunk.tiles
  4.         ref_dict = self.reference_dicts["tiles"]
  5.         field_to_update = ui.ids.tile_play_field
  6.  
  7.         if object_type == "ground_object":
  8.             update_list = chunk.ground_objects
  9.             ref_dict = self.reference_dicts["ground_objects"]
  10.             field_to_update = ui.ids.ground_object_play_field
  11.             #Once ground objects have been added delete the line below.
  12.             return
  13.         if object_type == "decorations":
  14.             update_list = chunk.decorations
  15.             ref_dict = self.reference_dicts["decorations"]
  16.             field_to_update = ui.ids.ground_object_play_field
  17.             #Once room decorations have been added delete the line below.
  18.             return
  19.  
  20.         tile_size = (field_to_update.size[0] / 21,
  21.                      field_to_update.size[1] / 21)
  22.         for thing_x in range(len(update_list)):
  23.             for thing_y in range(len(update_list[thing_x])):
  24.                 if update_list[thing_x][thing_y] is not None:
  25.                     thing = GameImage(source=ref_dict
  26.                                       [str(update_list[thing_x]
  27.                                                       [thing_y])].source)
  28.                     if chunk_coords:
  29.                         thing.x = NumericProperty(thing_x +
  30.                                                   (chunk_coords[0] * 3))
  31.                         thing.y = NumericProperty(thing_y +
  32.                                                   (chunk_coords[1] * 3))
  33.                         thing.pos = ((thing.x - camera.map_x) * tile_size,
  34.                                      (thing.y - camera.map_y) * tile_size)
  35.                         thing.height, thing.width = tile_size
  36.  
  37.                     if remove is True:
  38.                         field_to_update.remove_widget(thing)
  39.                     else:
  40.                         field_to_update.add_widget(thing)
  41.  
  42. KV:
  43. #:import camera main.Camera
  44. #:set view_port 21
  45.  
  46. <CategoryButton@Button>:
  47.     size_hint_x: .5
  48.     width: self.height
  49.  
  50. <GameImage@Image>:
  51.     source: self.source
  52.     allow_stretch: False
  53.     texture_size: self.size[0], self.size[1]
  54.     size_hint_x: None, None
  55.     size_hint_y: None, None
  56.  
  57. <Root>:
  58.     UI:
  59.         id: ui
  60.         orientation: 'horizontal'
  61.         LeftPanel:
  62.             id: left_panel
  63.             orientation: 'vertical'
  64.             size_hint: .5, 1
  65.  
  66.             MessageBox:
  67.                 canvas.before:
  68.                     Color:
  69.                         rgba: 0, 1, 0, 1
  70.                     Rectangle:
  71.                         pos: self.pos
  72.                         size: self.size
  73.                 id: message_box
  74.                 orientation: 'vertical'
  75.                 size_hint: 1, .25
  76.  
  77.                 MessageLabel:
  78.  
  79.             HudPanel:
  80.                 id: hud_panel
  81.                 orientation: 'horizontal'
  82.                 height: left_panel.height-message_box.height
  83.  
  84.                 HealthColumn:
  85.                     canvas.before:
  86.                         Color:
  87.                             rgba: 1, 0, 0, 1
  88.                         Rectangle:
  89.                             pos: self.pos
  90.                             size: self.size
  91.                     orientation: 'vertical'
  92.                     size_hint: .25, 1
  93.  
  94.                     HealthBar:
  95.  
  96.                     HealthLabel:
  97.  
  98.                 ExpColumn:
  99.                     canvas.before:
  100.                         Color:
  101.                             rgba: 0, 0, 1, 1
  102.                         Rectangle:
  103.                             pos: self.pos
  104.                             size: self.size
  105.                     orientation: 'vertical'
  106.                     size_hint: .25, 1
  107.  
  108.                     ExpBar:
  109.                         height: hud_panel.height
  110.  
  111.                     ExpLabel:
  112.  
  113.                 SkillColumn:
  114.                     id: skill_column
  115.                     orientation: 'vertical'
  116.                     size_hint: .5, 1
  117.                     padding: 0, self.height*.058
  118.                     spacing: self.height*.058
  119.  
  120.                     CategoryButton:
  121.                         id: corporeal_button
  122.                         height: skill_column.height/5
  123.                         pos_hint: {'x':.5-(self.size_hint_x/2), 'y':.2}
  124.  
  125.                     CategoryButton:
  126.                         id: alchemical_button
  127.                         height: skill_column.height/5
  128.                         pos_hint: {'x':.5-(self.size_hint_x/2), 'y':.4}
  129.  
  130.                     CategoryButton:
  131.                         id: relational_button
  132.                         height: skill_column.height/5
  133.                         pos_hint: {'x':.5-(self.size_hint_x/2), 'y':.6}
  134.  
  135.                     CategoryButton:
  136.                         id: spatial_button
  137.                         height: skill_column.height/5
  138.                         pos_hint: {'x':.5-(self.size_hint_x/2), 'y':.8}
  139.  
  140.                     CategoryButton:
  141.                         id: metaphysical_button
  142.                         height: skill_column.height/5
  143.                         pos_hint: {'x':.5-(self.size_hint_x/2), 'y':1}
  144.  
  145.         PlayField:
  146.             canvas.before:
  147.                 Color:
  148.                     rgba: 1, 1, 0, 1
  149.                 Rectangle:
  150.                     id: top_border
  151.                     pos: self.pos
  152.                     size: (self.width, (self.height % view_port)/2)
  153.                 Rectangle:
  154.                     id: left_border
  155.                     pos: self.pos
  156.                     size: ((self.width % view_port)/2, self.height)
  157.                 Rectangle:
  158.                     id: right_border
  159.                     pos: (self.x, self.height-((self.height % view_port)/2))
  160.                     size: (self.width, (self.height % view_port)/2)
  161.                 Rectangle:
  162.                     id: bottom_border
  163.                     pos: (self.x+self.width-((self.height % view_port)/2), self.y)
  164.                     size: ((self.width % view_port)/2, self.height)
  165.             id: play_field
  166.             pos: (ui.width-(self.width/2), ui.y)
  167.             size: (ui.height, ui.height)
  168.             size_hint: (None, None)
  169.             border_thickness: (self.width % view_port)/2
  170.             child_size: (self.size[0]-(self.border_thickness * 2), self.size[1]-(self.border_thickness * 2))
  171.             child_pos: (self.pos[0] + self.border_thickness, self.pos[1] + self.border_thickness)
  172.  
  173.             TilePlayField:
  174.                 id: tile_play_field
  175.                 pos: (play_field.child_pos[0], play_field.child_pos[1])
  176.                 size: (play_field.child_size[0], play_field.child_size[1])
  177.                 size_hint_x: None, None
  178.                 size_hint_y: None, None
  179.  
  180.             GroundObjectPlayField:
  181.                 id: ground_object_play_field
  182.                 pos: (play_field.child_pos[0], play_field.child_pos[1])
  183.                 size: (play_field.child_size[0], play_field.child_size[1])
  184.                 size_hint_x: None, None
  185.                 size_hint_y: None, None
  186.  
  187.             ObjectPlayField:
  188.                 id: object_play_field
  189.                 pos: (play_field.child_pos[0], play_field.child_pos[1])
  190.                 size: (play_field.child_size[0], play_field.child_size[1])
  191.                 size_hint_x: None, None
  192.                 size_hint_y: None, None
  193.  
  194.         RightPanel:
  195.             canvas.before:
  196.                 Color:
  197.                     rgba: 0, 1, 0, 1
  198.                 Rectangle:
  199.                     pos: self.pos
  200.                     size: self.size
  201.             id: right_Panel
  202.             orientation: 'vertical'
  203.             size_hint: .5, 1
  204.  
  205.             StatusPanel:
  206.                 canvas.before:
  207.                     Color:
  208.                         rgba: 1, 0, 0, 1
  209.                     Rectangle:
  210.                         pos: self.pos
  211.                         size: self.size
  212.                 id: status_panel
  213.                 orientation: 'vertical'
  214.                 size_hint: 1, .75
  215.  
  216.                 PledgePanel:
  217.                     id: pledge_panel
  218.                     size_hint: 1, .2
  219.  
  220.                     PledgeLabel:
  221.                         id: pledge_label
  222.                         height: 1
  223.  
  224.                     PledgeButton:
  225.  
  226.                 StatusBox:
  227.                     size_hint: 1, .55
  228.                     id: status_box
  229.                     orientation: 'horizontal'
  230.  
  231.                     BuffColumn:
  232.                         canvas.before:
  233.                             Color:
  234.                                 rgba: 0, 0, 1, 1
  235.                             Rectangle:
  236.                                 pos: self.pos
  237.                                 size: self.size
  238.                         orientation: 'vertical'
  239.                         size_hint: .5, 1
  240.  
  241.                         BuffLabel:
  242.  
  243.                     DebuffColumn:
  244.                         canvas.before:
  245.                             Color:
  246.                                 rgba: 1, 1, 0, 1
  247.                             Rectangle:
  248.                                 pos: self.pos
  249.                                 size: self.size
  250.                         orientation:'vertical'
  251.                         size_hint: .5, 1
  252.  
  253.                         DebuffLabel:
  254.  
  255.             MiniMap:
  256.                 size_hint: 1, .25
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement