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