source: abuse/trunk/src/view.h @ 659

Last change on this file since 659 was 643, checked in by Sam Hocevar, 11 years ago

imlib: refactor Event and EventHandler?.

  • Property svn:keywords set to Id
File size: 4.2 KB
RevLine 
[56]1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
[494]4 *  Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
[56]5 *
6 *  This software was released into the Public Domain. As with most public
[555]7 *  domain software, no warranty is made or implied by Crack dot Com, by
8 *  Jonathan Clark, or by Sam Hocevar.
[56]9 */
10
[2]11#ifndef _VIEW_HPP_
12#define _VIEW_HPP_
13
[481]14#include "light.h"
15#include "jwindow.h"
[2]16
17
18class object_node;
19class game_object;
20class area_controller;
21
22struct suggest_struct
23{
[16]24  int32_t cx1,cy1,cx2,cy2,shift_down,shift_right,pan_x,pan_y;
25  int32_t new_weapon;
[17]26  uint8_t send_view,send_weapon_change;
[2]27} ;
28
29
30class view;
31
32
33class view
34{
[17]35  uint8_t keymap[512/8];
[2]36  char chat_buf[60];
[124]37  public :
[2]38  int key_down(int key) { return keymap[key/8]&(1<<(key%8)); }
39  void set_key_down(int key, int x) { if (x) keymap[key/8]|=(1<<(key%8)); else keymap[key/8]&=~(1<<(key%8)); }
40  void reset_keymap() { memset(keymap,0,sizeof(keymap)); }
41  void add_chat_key(int key);
42
43  char name[100];
44  struct suggest_struct suggest;
[16]45  int32_t cx1,cy1,cx2,cy2,                    // view area to show
[2]46      shift_down,shift_right;             // shift of view
47
48  int god;                                // :) if you believe in such things
49  int player_number;
[126]50  int _tint, _team;
[124]51
[2]52  int draw_solid;                         // -1 if don't draw solid
53
[16]54  int32_t *weapons;                          // [0..total_weapons-1]
55  int32_t *last_weapons;                     // last history of above array (for updating statbar)
56  int32_t current_weapon;
[2]57
58
59  game_object *focus;                     // object we are focusing on (player)
60  int x_suggestion,                      // input from the player at the current time
61      y_suggestion,
62      b1_suggestion,
63      b2_suggestion,
64      b3_suggestion,
65      b4_suggestion,
66      pointer_x,
67      pointer_y,
68      freeze_time;
69
70
71  short ambient;                        // ambient lighting setting, used by draw
[126]72
[16]73  int32_t pan_x,pan_y,no_xleft,no_xright,no_ytop,no_ybottom,
[2]74       last_x,last_y,last_last_x,last_last_y,view_percent;
75
[16]76  int32_t last_left,last_right,last_up,last_down,   // how many frames ago were these pressed (<=0)
[2]77       last_b1,last_b2,last_b3,last_b4,last_hp,last_ammo,last_type;
[16]78  int32_t secrets,kills,tsecrets,tkills;
[2]79
80  view(game_object *Focus, view *Next, int number);
[126]81  ~view();
82
[2]83  void draw_character_damage();           // draws the characters 'status' on the viewer
84
[16]85  int32_t x_center();                        // center of attention
86  int32_t y_center();
87  int32_t xoff();                            // top left and right corner of the screen
88  int32_t interpolated_xoff();
89  int32_t yoff();
90  int32_t interpolated_yoff();
[2]91  int drawable();                        // network viewables are not drawable
92  int local_player();                    //  just in case I ever need non-viewable local players.
93
[124]94  view *next;                             // next viewable player (singly linked list)
[2]95  void get_input();
[17]96  int process_input(char cmd, uint8_t *&pk);
[2]97
98  void add_ammo   (int weapon_type, int total);
99  int has_weapon  (int weapon_type) { return god || (weapons[weapon_type]!=-1); }
100  void give_weapon(int weapontype);
101  int weapon_total(int weapon_type);
102
103  void note_upkey();
104  void note_downkey();
[643]105  int handle_event(Event &ev);
[2]106  void update_scroll();
107  void draw_hp();
108  void draw_ammo();
109  void draw_logo();
[16]110  void resize_view(int32_t Cx1, int32_t Cy1, int32_t Cx2, int32_t Cy2);
[2]111  void set_input(int cx, int cy, int b1, int b2, int b3, int b4, int px, int py);
112  int view_changed() { return suggest.send_view; }
113  int weapon_changed() { return suggest.send_weapon_change; }
114
115  void next_weapon();
116  void last_weapon();
117
118  void reset_player();
119  int receive_failed() { return focus==NULL; }
[16]120  int32_t get_view_var_value(int num);
121  int32_t set_view_var_value(int num, int32_t x);
[2]122  void configure_for_area(area_controller *a);
123
[126]124  void set_tint(int);
125  int get_tint();
126  void set_team(int);
127  int get_team();
128};
129
[2]130extern view *player_list;
131void set_local_players(int total);
132int total_local_players();
133void recalc_local_view_space();
134
[17]135void process_packet_commands(uint8_t *pk, int size);
[2]136
137object_node *make_player_onodes(int player_num=-1);
138int total_view_vars();
[39]139char const *get_view_var_name(int num);
[555]140uint16_t make_sync();
[2]141
142#endif
143
144
145
146
147
Note: See TracBrowser for help on using the repository browser.