#ifndef DIRECT_H
#define DIRECT_H
#include "describe.h"
#include "externs.h"
#include "enum.h"
#include "libgui.h"
#include "ray.h"
#include "state.h"
class range_view_annotator : public crawl_exit_hook
{
public:
range_view_annotator(int range);
virtual ~range_view_annotator();
virtual void restore_state();
private:
bool do_anything;
};
class crawl_view_buffer
{
public:
crawl_view_buffer();
~crawl_view_buffer();
void size(const coord_def &size);
operator screen_buffer_t * () { return (buffer); }
void draw();
private:
screen_buffer_t *buffer;
};
struct crawl_view_geometry
{
public:
coord_def termp; coord_def termsz; coord_def viewp; coord_def viewsz; coord_def hudp; coord_def hudsz; coord_def msgp; coord_def msgsz; coord_def mlistp; coord_def mlistsz;
crawl_view_buffer vbuf;
coord_def vgrdc;
coord_def viewhalfsz;
coord_def glos1, glos2; coord_def vlos1, vlos2;
coord_def mousep;
private:
coord_def last_player_pos;
public:
crawl_view_geometry();
void init_geometry();
void init_view();
void set_player_at(const coord_def &c, bool force_centre = false);
void shift_player_to(const coord_def &c);
coord_def view_centre() const
{
return viewp + viewhalfsz;
}
coord_def glosc() const
{
return (glos1 + glos2) / 2;
}
bool in_grid_los(const coord_def &c) const
{
return (c.x >= glos1.x && c.x <= glos2.x
&& c.y >= glos1.y && c.y <= glos2.y);
}
bool in_view_los(const coord_def &c) const
{
return (c.x >= vlos1.x && c.x <= vlos2.x
&& c.y >= vlos1.y && c.y <= vlos2.y);
}
bool in_view_viewport(const coord_def &c) const
{
return (c.x >= viewp.x && c.y >= viewp.y
&& c.x < viewp.x + viewsz.x
&& c.y < viewp.y + viewsz.y);
}
bool in_grid_viewport(const coord_def &c) const
{
return in_view_viewport(c - vgrdc + view_centre());
}
};
extern crawl_view_geometry crawl_view;
class targetting_behaviour
{
public:
targetting_behaviour(bool just_looking = false);
virtual ~targetting_behaviour();
virtual int get_key();
virtual command_type get_command(int key = -1);
virtual bool should_redraw();
virtual void mark_ammo_nonchosen();
public:
bool just_looking;
bool compass;
};
struct dist
{
bool isValid; bool isTarget; bool isMe; bool isEndpoint; bool isCancel; bool choseRay; coord_def target; coord_def delta; ray_def ray;
int prev_target; };
void direction( dist &moves, targetting_type restricts = DIR_NONE,
targ_mode_type mode = TARG_ANY, int range = -1,
bool just_looking = false, bool needs_path = true,
bool may_target_monster = true, bool may_target_self = false,
const char *prompt = NULL, targetting_behaviour *mod = NULL,
bool cancel_at_self = false );
bool in_los_bounds(const coord_def& p);
bool in_viewport_bounds(int x, int y);
inline bool in_viewport_bounds(const coord_def& pos) {
return in_viewport_bounds(pos.x, pos.y);
}
bool in_los(int x, int y);
bool in_los(const coord_def &pos);
bool in_vlos(int x, int y);
bool in_vlos(const coord_def &pos);
std::string thing_do_grammar(description_level_type dtype,
bool add_stop,
bool force_article,
std::string desc);
std::string get_terse_square_desc(const coord_def &gc);
void terse_describe_square(const coord_def &c, bool in_range = true);
void full_describe_square(const coord_def &c);
void get_square_desc(const coord_def &c, describe_info &inf,
bool examine_mons = false);
void describe_floor();
std::string get_monster_equipment_desc(const monsters *mon,
bool full_desc = true,
description_level_type mondtype = DESC_CAP_A,
bool print_attitude = false);
int dos_direction_unmunge(int doskey);
std::string feature_description(const coord_def& where, bool bloody = false,
description_level_type dtype = DESC_CAP_A,
bool add_stop = true, bool base_desc = false);
std::string raw_feature_description(dungeon_feature_type grid,
trap_type tr = NUM_TRAPS,
bool base_desc = false);
std::string feature_description(dungeon_feature_type grid,
trap_type trap = NUM_TRAPS, bool bloody = false,
description_level_type dtype = DESC_CAP_A,
bool add_stop = true, bool base_desc = false);
void set_feature_desc_short(dungeon_feature_type grid,
const std::string &desc);
void set_feature_desc_short(const std::string &base_name,
const std::string &desc);
void setup_feature_descs_short();
std::vector<dungeon_feature_type> features_by_desc(const base_pattern &pattern);
void full_describe_view(void);
inline int view2gridX(int vx)
{
return (crawl_view.vgrdc.x + vx - crawl_view.view_centre().x);
}
inline int view2gridY(int vy)
{
return (crawl_view.vgrdc.y + vy - crawl_view.view_centre().y);
}
inline coord_def view2grid(const coord_def &pos)
{
return pos - crawl_view.view_centre() + crawl_view.vgrdc;
}
inline int grid2viewX(int gx)
{
return (gx - crawl_view.vgrdc.x + crawl_view.view_centre().x);
}
inline int grid2viewY(int gy)
{
return (gy - crawl_view.vgrdc.y + crawl_view.view_centre().y);
}
inline coord_def grid2view(const coord_def &pos)
{
return (pos - crawl_view.vgrdc + crawl_view.view_centre());
}
inline coord_def view2show(const coord_def &pos)
{
return (pos - crawl_view.vlos1);
}
inline coord_def show2view(const coord_def &pos)
{
return (pos + crawl_view.vlos1);
}
inline coord_def grid2show(const coord_def &pos)
{
return (view2show(grid2view(pos)));
}
inline coord_def show2grid(const coord_def &pos)
{
return (view2grid(show2view(pos)));
}
extern const struct coord_def Compass[8];
#endif