Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

fack.hpp File Reference

#include <SDL.h>
#include <SDL_image.h>
#include <boost/shared_ptr.hpp>
#include <list>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <set>
#include <boost/variant.hpp>
#include <iostream>
#include <sstream>
#include <fstream>
#include <guichan.hpp>
#include <guichan/sdl.hpp>

Go to the source code of this file.

Defines

#define pt   shared_ptr
#define NEW(x)   pt_of(new x)
#define MATCH_IN_ANY_ORDER(i1, v1, i2, v2)   ((i1==v1 && i2 == v2) || (i1==v2 && i2 ==v1))
#define foreach(i, l)   for((i) = (l).begin(); (i) != (l).end(); (i)++)
 macro to iterate through STL containers more concisely.
#define setof(X, L, P, OUT)   OUT.clear(); for(X = L.begin(); X != L.end(); X++) { if(P){ OUT.push_back(*X);}}
#define setof_(M, X, L, P, OUT)   OUT.clear(); for(X = L.begin(); X != L.end(); X++) { if(P){ OUT.push_back(M);}}

Typedefs

typedef seq_list< mood_and_stringspeech_t
typedef seq_list< anim_and_stringspeech2_t
typedef seq_list< pt< script_cmd > > script_cmds_t
typedef seq_list< seq_list<
mood_and_string > > 
dialog_t
typedef map< pt< mood_t >,
anim_right_left
anim_of_mood_t
typedef map< int, SDL_Surface * > surf_of_letter_t

Enumerations

enum  walk_there_or_not { walk_there_to_look_at, do_not_walk_there_to_look_at }
enum  container_type { CONCEPTS, PHYS_OBJECTS, CAN_CONTAIN_ANYTHING }
enum  direction { d_up, d_down, d_left, d_right }
enum  horizontal_dir { hd_right, hd_left }
enum  walking_phase { CONTACT, RECOIL, PASSING, HIGH_POINT }
enum  add_or_remove { ADD, REMOVE }
enum  show_or_hide { SHOW, HIDE }
enum  option_close_containers { close_any_open_container, do_not_close_containers }
enum  special_button_pick_result { SBPR_SAVE_LOAD, SBPR_CYCLE_PLAYER, SBPR_NOTHING, SBPR_STAY_FOLLOW }

Functions

template<class T>
pt< T > pt_of (T *t)
SDL_Rect create_rect (int x1, int y2, int x2, int y2)
template<class T, class I>
bool pt_cast (pt< I > i, pt< T > &i2)
template<class T, class V>
bool var_cast (V i, T &i2)
template<class T>
T::value_type min (const T &l)
template<class T>
T::value_type max (const T &l)
template<class Map>
Map::mapped_type map_get (const Map &m, typename Map::key_type i)
template<class T>
seq_list< T > ulist (T first_el)
template<class T>
pt< vector< typename T::value_type > > vector_of (const T &l)
template<class T>
pt< set< typename T::value_type > > set_of (const T &l)
template<class Set>
bool in (typename Set::key_type i, const Set &s)
 test whether a set<X> or map<X, Y> contains a given X.
template<class L>
bool in_list (typename L::value_type el, const L &l)
 test whether a vector<X> or list<X> contains a given X.
pt< vector2< bool > > walking_map_from_sdl_surface (SDL_Surface *s)
string string_of_int (int i)
void blit_char (const anim_frame_and_pos &src, float scaling, float lighting, cfsurf &screen)
pt< cfsurfsum_each_pixel (const list< surf_and_weight > &surfs, float time, SDL_Rect visible_rect)
pt< layer_litlit_layer_of_unlit_layer (const layer_unlit_after_anim &unlit, const set< pt< light > > &on_lights, float time, SDL_Rect visible_rect)
rgbaf sum_rgbaf (rgbaf r1, rgbaf r2)
rgbaf rgbaf_of_rgbai (Uint8 r, Uint8 g, Uint8 b, Uint8 a)
rgbaf mul_scalar_rgbaf (float scal, rgbaf rg)
rgbaf mul_scalar_rgbaf_noalpha (float scal, rgbaf rg)


Define Documentation

#define foreach i,
 )     for((i) = (l).begin(); (i) != (l).end(); (i)++)
 

macro to iterate through STL containers more concisely.

Definition at line 87 of file fack.hpp.

Referenced by path_finding::best_route(), FACK::circle_of_light(), FACK::contains_not_recursively(), FACK::contains_recursively(), FACK::define_dialog_aux(), text::draw_text_multiline_variable_ht(), draw_verb_dialog(), FACK::FACK(), item_in_room_at_position(), FACK::lit_layer_of_unlit_layer(), max(), min(), anim_frame_and_pos::print_with_transparency(), FACK::recompute_on_lights(), container::remove_item_aux(), container::remove_item_not_recursively(), container::remove_item_rec_aux(), container::render(), render_layers_and_chars_in_correct_order(), FACK::start(), sum_each_pixel(), and FACK::update_light_transitions().

#define MATCH_IN_ANY_ORDER i1,
v1,
i2,
v2   )     ((i1==v1 && i2 == v2) || (i1==v2 && i2 ==v1))
 

Definition at line 63 of file fack.hpp.

Referenced by my_game::execute_action_object_object().

#define NEW  )     pt_of(new x)
 

Definition at line 61 of file fack.hpp.

Referenced by my_game::active_player_changed(), path_finding::best_route(), FACK::circle_of_light(), compute_feet_positions(), FACK::define_dialog_aux(), draw_verb_dialog(), FACK::drop_item(), end_commands(), FACK::exec_next_scr_cmd(), my_game::execute_action_double_none_of_the_above(), my_game::execute_action_object_object(), my_game::execute_action_verb_object(), FACK::FACK(), cfsurf::from_sdl_surface(), anim_frame::from_sdl_surface(), layer_unlit_not_anim::get_cur_frame(), layer_unlit_anim::get_cur_frame(), is_there_only_one_option_overall(), zoomable::item_at_screen_pos(), container::item_at_screen_pos(), FACK::item_in_popup_at_screen_pos(), FACK::lit_layer_of_unlit_layer(), my_game::my_game(), PC::PC(), FACK::stand_up_if_sitting(), FACK::start(), sum_each_pixel(), FACK::the_obj_was_clicked(), and walking_map_from_sdl_surface().

#define pt   shared_ptr
 

Definition at line 60 of file fack.hpp.

#define setof X,
L,
P,
OUT   )     OUT.clear(); for(X = L.begin(); X != L.end(); X++) { if(P){ OUT.push_back(*X);}}
 

For who knows python:

setof(x, l, p, out)

means

out = [x for x in l if p]

Definition at line 99 of file fack.hpp.

Referenced by path_finding::best_route(), and FACK::start().

#define setof_ M,
X,
L,
P,
OUT   )     OUT.clear(); for(X = L.begin(); X != L.end(); X++) { if(P){ OUT.push_back(M);}}
 

For who knows python:

setof_(y, x, l, p, out)

means

out = [y for x in l if p]

Definition at line 110 of file fack.hpp.

Referenced by path_finding::best_route(), FACK::cycle_active_player(), FACK::exec_next_scr_cmd(), FACK::FACK(), FACK::lit_layer_of_unlit_layer(), FACK::start(), and sum_each_pixel().


Typedef Documentation

typedef map< pt<mood_t>, anim_right_left > anim_of_mood_t
 

Definition at line 1944 of file fack.hpp.

typedef seq_list<seq_list<mood_and_string> > dialog_t
 

Definition at line 1924 of file fack.hpp.

typedef seq_list<pt<script_cmd> > script_cmds_t
 

Definition at line 1498 of file fack.hpp.

typedef seq_list<anim_and_string> speech2_t
 

Definition at line 1489 of file fack.hpp.

typedef seq_list<mood_and_string> speech_t
 

Definition at line 1487 of file fack.hpp.

typedef map<int, SDL_Surface*> surf_of_letter_t
 

Definition at line 2244 of file fack.hpp.


Enumeration Type Documentation

enum add_or_remove
 

Enumeration values:
ADD 
REMOVE 

Definition at line 2067 of file fack.hpp.

enum container_type
 

Enumeration values:
CONCEPTS 
PHYS_OBJECTS 
CAN_CONTAIN_ANYTHING 

Definition at line 1021 of file fack.hpp.

enum direction
 

Enumeration values:
d_up 
d_down 
d_left 
d_right 

Definition at line 1605 of file fack.hpp.

enum horizontal_dir
 

Enumeration values:
hd_right 
hd_left 

Definition at line 1608 of file fack.hpp.

enum option_close_containers
 

Enumeration values:
close_any_open_container 
do_not_close_containers 

Definition at line 2177 of file fack.hpp.

enum show_or_hide
 

Enumeration values:
SHOW 
HIDE 

Definition at line 2068 of file fack.hpp.

enum special_button_pick_result
 

Enumeration values:
SBPR_SAVE_LOAD 
SBPR_CYCLE_PLAYER 
SBPR_NOTHING 
SBPR_STAY_FOLLOW 

Definition at line 2302 of file fack.hpp.

enum walk_there_or_not
 

Enumeration values:
walk_there_to_look_at 
do_not_walk_there_to_look_at 

Definition at line 460 of file fack.hpp.

enum walking_phase
 

Enumeration values:
CONTACT 
RECOIL 
PASSING 
HIGH_POINT 

Definition at line 1611 of file fack.hpp.


Function Documentation

void blit_char const anim_frame_and_pos src,
float  scaling,
float  lighting,
cfsurf screen
 

This is a blit procedure tuned for characters. It features: per-pixel alpha-blending, scaling with linear interpolation, uniform lighting, clipping.

Bug:
This procedure has some graphic artifact when the scaling factor is > 1.0f or = 1.0f. Fix this.
Parameters:
src  character animation frame. the source surface.
scaling  scaling factor. Pass 1.0f for no scaling, in which case the procedure is much faster.
lighting  uniform lighting multiplier.
screen  the blit destination surface

Definition at line 80 of file time-critical-procs.cc.

References mul_scalar_rgbaf_noalpha(), and write_pixel_with_src_alpha().

Referenced by anim_frame_and_pos::print_with_transparency().

SDL_Rect create_rect int  x1,
int  y2,
int  x2,
int  y2
 

Definition at line 5113 of file fack.cc.

References int_pair::x, and int_pair::y.

Referenced by draw_verb_dialog(), FACK::find_scrolling_rect(), zoomable::item_at_screen_pos(), my_game::my_game(), and FACK::start().

template<class Set>
bool in typename Set::key_type  i,
const Set &  s
 

test whether a set<X> or map<X, Y> contains a given X.

Definition at line 274 of file fack.hpp.

Referenced by FACK::exec_next_scr_cmd(), my_game::execute_action_verb_object(), FACK::lit_layer_of_unlit_layer(), and FACK::update_light_transitions().

template<class L>
bool in_list typename L::value_type  el,
const L &  l
 

test whether a vector<X> or list<X> contains a given X.

Definition at line 288 of file fack.hpp.

Referenced by FACK::the_obj_was_clicked().

pt<layer_lit> lit_layer_of_unlit_layer const layer_unlit_after_anim unlit,
const set< pt< light > > &  on_lights,
float  time,
SDL_Rect  visible_rect
 

template<class Map>
Map::mapped_type map_get const Map &  m,
typename Map::key_type  i
 

useful if you want to avoid using the operator[] of a map, because it has no const version.

Definition at line 179 of file fack.hpp.

Referenced by FACK::calc_command_bar_ht(), text::draw_text_multiline_variable_ht(), draw_verb_dialog(), end_commands(), FACK::exec_next_scr_cmd(), item_in_room_at_position(), FACK::lit_layer_of_unlit_layer(), my_game::my_game(), text::print_line_of_text(), anim_frame_and_pos::print_with_transparency(), FACK::start(), sum_each_pixel(), text::text_wt_in_pixels(), and FACK::update_AI_state().

template<class T>
T::value_type max const T &  l  ) 
 

Compute the maximum value of a list or vector. The contained type must provide an "operator >".

Definition at line 163 of file fack.hpp.

References foreach.

Referenced by decide_position_for_text(), FACK::FACK(), anim_frame::get_pixel_with_interpolation(), and sum_each_pixel().

template<class T>
T::value_type min const T &  l  ) 
 

Compute the minimum value of a list or vector. The contained type must provide an "operator <".

Definition at line 147 of file fack.hpp.

References foreach.

Referenced by FACK::find_scrolling_rect(), anim_frame::get_pixel_with_interpolation(), and sum_each_pixel().

rgbaf mul_scalar_rgbaf float  scal,
rgbaf  rg
[inline]
 

Definition at line 2679 of file fack.hpp.

References rgbaf::a, rgbaf::b, rgbaf::g, and rgbaf::r.

Referenced by anim_frame::get_pixel_with_interpolation(), and sum_each_pixel().

rgbaf mul_scalar_rgbaf_noalpha float  scal,
rgbaf  rg
[inline]
 

Definition at line 2688 of file fack.hpp.

References rgbaf::a, rgbaf::b, rgbaf::g, and rgbaf::r.

Referenced by blit_char(), and sum_each_pixel().

template<class T, class I>
bool pt_cast pt< I >  i,
pt< T > &  i2
 

Definition at line 120 of file fack.hpp.

Referenced by container::can_contain_this_obj(), FACK::circle_of_light(), FACK::contains_recursively(), draw_verb_dialog(), FACK::drop_item(), end_commands(), FACK::exec_next_scr_cmd(), FACK::execute_commands(), is_there_only_one_option_overall(), FACK::item_in_popup_at_screen_pos(), item_in_room_at_position(), FACK::recompute_on_lights(), container::remove_item_rec_aux(), container::render(), FACK::render_command_bar(), FACK::stand_up_if_sitting(), FACK::start(), FACK::the_obj_was_clicked(), and FACK::update_AI_state().

template<class T>
pt<T> pt_of T *  t  ) 
 

A function that allows to use shared_ptr in a more readable way. Example: instead of

shared_ptr<Class> p; p = shared_ptr<Class>(new Class(4));

you write

shared_ptr<Class> p; p = pt_of(new Class(4));

Definition at line 80 of file fack.hpp.

Referenced by set_of(), and vector_of().

rgbaf rgbaf_of_rgbai Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a
[inline]
 

Definition at line 2670 of file fack.hpp.

Referenced by cfsurf::from_sdl_surface(), and anim_frame::from_sdl_surface().

template<class T>
pt<set<typename T::value_type> > set_of const T &  l  ) 
 

Definition at line 253 of file fack.hpp.

References pt_of().

Referenced by my_game::my_game().

string string_of_int int  i  ) 
 

Definition at line 48 of file fack.cc.

Referenced by my_game::my_game(), and path_finding::string_of_int_pair().

pt<cfsurf> sum_each_pixel const list< surf_and_weight > &  surfs,
float  time,
SDL_Rect  visible_rect
[inline]
 

create a cfsurf whose rgba values are the sum of the corresponding values in the input cfsurf's.

Todo:
: recheck the logic.

Definition at line 181 of file time-critical-procs.cc.

References foreach, map_get(), max(), min(), mul_scalar_rgbaf(), mul_scalar_rgbaf_noalpha(), NEW, surf_and_weight::oscillation_amplitude, pow(), setof_, sum_rgbaf(), and surf_and_weight::surf.

Referenced by FACK::lit_layer_of_unlit_layer().

rgbaf sum_rgbaf rgbaf  r1,
rgbaf  r2
[inline]
 

Definition at line 2661 of file fack.hpp.

References rgbaf::a, rgbaf::b, rgbaf::g, and rgbaf::r.

Referenced by anim_frame::get_pixel_with_interpolation(), and sum_each_pixel().

template<class T>
seq_list<T> ulist first_el  ) 
 

Create a list without specifying the type of the contained element, but only the first element.

Definition at line 223 of file fack.hpp.

Referenced by draw_verb_dialog(), my_game::execute_action_object_object(), is_there_only_one_option_overall(), and my_game::my_game().

template<class T, class V>
bool var_cast i,
T &  i2
 

Definition at line 129 of file fack.hpp.

Referenced by FACK::exec_next_scr_cmd(), zoomable::item_at_screen_pos(), container::item_at_screen_pos(), FACK::render_command_bar(), FACK::start(), and FACK::update_AI_state().

template<class T>
pt<vector<typename T::value_type> > vector_of const T &  l  ) 
 

Create a vector from a list (or anything that has a const_iterator)

Definition at line 235 of file fack.hpp.

References pt_of().

Referenced by animation::animation(), draw_verb_dialog(), FACK::exec_next_scr_cmd(), FACK::execute_commands(), is_there_only_one_option_overall(), and my_game::my_game().

pt<vector2<bool> > walking_map_from_sdl_surface SDL_Surface *  s  ) 
 

Definition at line 1021 of file fack.cc.

References NEW.

Referenced by my_game::my_game().


Generated on Wed May 25 15:36:07 2005 for FACK by  doxygen 1.4.0