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

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

style: remove trailing spaces, fix copyright statements.

  • Property svn:keywords set to Id
File size: 4.2 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *  Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
5 *
6 *  This software was released into the Public Domain. As with most public
7 *  domain software, no warranty is made or implied by Crack dot Com or
8 *  Jonathan Clark.
9 */
10
11#ifndef _VIEW_HPP_
12#define _VIEW_HPP_
13
14#include "light.h"
15#include "jwindow.h"
16
17
18class object_node;
19class game_object;
20class area_controller;
21
22struct suggest_struct
23{
24  int32_t cx1,cy1,cx2,cy2,shift_down,shift_right,pan_x,pan_y;
25  int32_t new_weapon;
26  uint8_t send_view,send_weapon_change;
27} ;
28
29
30class view;
31
32
33class view
34{
35  uint8_t keymap[512/8];
36  char chat_buf[60];
37  public :
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;
45  int32_t cx1,cy1,cx2,cy2,                    // view area to show
46      shift_down,shift_right;             // shift of view
47
48  int god;                                // :) if you believe in such things
49  int player_number;
50  int _tint, _team;
51
52  int draw_solid;                         // -1 if don't draw solid
53
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;
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
72
73  int32_t pan_x,pan_y,no_xleft,no_xright,no_ytop,no_ybottom,
74       last_x,last_y,last_last_x,last_last_y,view_percent;
75
76  int32_t last_left,last_right,last_up,last_down,   // how many frames ago were these pressed (<=0)
77       last_b1,last_b2,last_b3,last_b4,last_hp,last_ammo,last_type;
78  int32_t secrets,kills,tsecrets,tkills;
79
80  view(game_object *Focus, view *Next, int number);
81  ~view();
82
83  void draw_character_damage();           // draws the characters 'status' on the viewer
84
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();
91  int drawable();                        // network viewables are not drawable
92  int local_player();                    //  just in case I ever need non-viewable local players.
93
94  view *next;                             // next viewable player (singly linked list)
95  void get_input();
96  int process_input(char cmd, uint8_t *&pk);
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();
105  int handle_event(event &ev);
106  void update_scroll();
107  void draw_hp();
108  void draw_ammo();
109  void draw_logo();
110  void resize_view(int32_t Cx1, int32_t Cy1, int32_t Cx2, int32_t Cy2);
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; }
120  int32_t get_view_var_value(int num);
121  int32_t set_view_var_value(int num, int32_t x);
122  void configure_for_area(area_controller *a);
123
124  void set_tint(int);
125  int get_tint();
126  void set_team(int);
127  int get_team();
128};
129
130extern view *player_list;
131void set_local_players(int total);
132int total_local_players();
133void recalc_local_view_space();
134
135void process_packet_commands(uint8_t *pk, int size);
136
137object_node *make_player_onodes(int player_num=-1);
138int total_view_vars();
139char const *get_view_var_name(int num);
140ushort make_sync();
141
142#endif
143
144
145
146
147
Note: See TracBrowser for help on using the repository browser.