Renamed some enum types and members for generalization.

This commit is contained in:
Ignacio R. Morelle 2009-09-21 19:59:01 +00:00
parent fe197f92c0
commit 3f6f4d9ddd
3 changed files with 40 additions and 40 deletions

View File

@ -100,8 +100,8 @@ part::part(const vconfig &part_cfg)
, show_title_()
, text_()
, text_title_()
, text_block_loc_(part::BOTTOM)
, title_alignment_(part::LEFT)
, text_block_loc_(part::BLOCK_BOTTOM)
, title_alignment_(part::TEXT_LEFT)
, music_()
, sound_()
, floating_images_()
@ -109,30 +109,30 @@ part::part(const vconfig &part_cfg)
resolve_wml(part_cfg);
}
part::TEXT_BLOCK_LOCATION part::string_tblock_loc(const std::string& s)
part::BLOCK_LOCATION part::string_tblock_loc(const std::string& s)
{
if(s.empty() != true) {
if(s == "top") {
return part::TOP;
return part::BLOCK_TOP;
}
else if("middle") {
return part::MIDDLE;
return part::BLOCK_MIDDLE;
}
}
return part::BOTTOM;
return part::BLOCK_BOTTOM;
}
part::TITLE_ALIGNMENT part::string_title_align(const std::string& s)
part::TEXT_ALIGNMENT part::string_title_align(const std::string& s)
{
if(s.empty() != true) {
if(s == "right") {
return part::RIGHT;
return part::TEXT_RIGHT;
}
else if(s == "center") {
return part::CENTERED;
return part::TEXT_CENTERED;
}
}
return part::LEFT;
return part::TEXT_LEFT;
}
void part::resolve_wml(const vconfig &cfg)

View File

@ -120,24 +120,24 @@ class part
{
public:
/**
* Where the text block should be placed.
* Currently used to indicate where the text block should be placed.
* Note that it will always take as much space as it is
* possible horizontally.
*/
enum TEXT_BLOCK_LOCATION {
TOP, /**< Top of the screen. */
MIDDLE, /**< Center of the screen. */
BOTTOM /**< Bottom of the screen. This is the default. */
enum BLOCK_LOCATION {
BLOCK_TOP, /**< Top of the screen. */
BLOCK_MIDDLE, /**< Center of the screen. */
BLOCK_BOTTOM /**< Bottom of the screen. This is the default. */
};
/**
* Where the page title should be placed.
* Currently used to indicate where the page title should be placed.
* It always takes as little space (horizontally) as possible,
* and it is always placed at the top of the screen.
*/
enum TITLE_ALIGNMENT {
LEFT, /**< Top-left corner. */
CENTERED, /**< Center on the topmost edge of the screen. */
RIGHT /**< Top-right corner. */
enum TEXT_ALIGNMENT {
TEXT_LEFT, /**< Top-left corner. */
TEXT_CENTERED, /**< Center on the topmost edge of the screen. */
TEXT_RIGHT /**< Top-right corner. */
};
/**
* Used to signal user actions.
@ -200,12 +200,12 @@ public:
}
/** Retrieves the area of the screen on which the story text is displayed. */
TEXT_BLOCK_LOCATION text_block_location() const {
BLOCK_LOCATION story_text_location() const {
return text_block_loc_;
}
/** Retrieves the alignment of the title text against the screen. */
TITLE_ALIGNMENT title_block_alignment() const {
TEXT_ALIGNMENT title_text_alignment() const {
return title_alignment_;
}
@ -218,8 +218,8 @@ private:
/** Takes care of initializing and branching properties. */
void resolve_wml(const vconfig &cfg);
static TEXT_BLOCK_LOCATION string_tblock_loc(const std::string& s);
static TITLE_ALIGNMENT string_title_align(const std::string& s);
static BLOCK_LOCATION string_tblock_loc(const std::string& s);
static TEXT_ALIGNMENT string_title_align(const std::string& s);
bool scale_background_;
std::string background_file_;
@ -227,8 +227,8 @@ private:
bool show_title_;
std::string text_;
std::string text_title_;
TEXT_BLOCK_LOCATION text_block_loc_;
TITLE_ALIGNMENT title_alignment_;
BLOCK_LOCATION text_block_loc_;
TEXT_ALIGNMENT title_alignment_;
std::string music_;
std::string sound_;

View File

@ -153,17 +153,17 @@ void part_ui::prepare_geometry()
text_x_ = 200;
buttons_x_ = video_.getx() - 200 - 40;
switch(p_.text_block_location())
switch(p_.story_text_location())
{
case part::TOP:
case part::BLOCK_TOP:
text_y_ = 0;
buttons_y_ = 40;
break;
case part::MIDDLE:
case part::BLOCK_MIDDLE:
text_y_ = video_.gety() / 3;
buttons_y_ = video_.gety() / 2 + 15;
break;
default: // part::BOTTOM
default: // part::BLOCK_BOTTOM
text_y_ = video_.gety() - 200;
buttons_y_ = video_.gety() - 40;
break;
@ -289,11 +289,11 @@ void part_ui::render_title_box()
const int titlebox_w = txtsurf->w;
const int titlebox_h = txtsurf->h;
switch(p_.title_block_alignment()) {
case part::CENTERED:
switch(p_.title_text_alignment()) {
case part::TEXT_CENTERED:
titlebox_x = base_rect_.w / 2 - titlebox_w / 2 - titlebox_padding;
break;
case part::RIGHT:
case part::TEXT_RIGHT:
titlebox_x = base_rect_.w - titlebox_padding - titlebox_w;
break;
default:
@ -326,17 +326,17 @@ void part_ui::render_story_box_borders(SDL_Rect& /*update_area*/)
#else
void part_ui::render_story_box_borders(SDL_Rect& update_area)
{
const part::TEXT_BLOCK_LOCATION tbl = p_.text_block_location();
const part::BLOCK_LOCATION tbl = p_.story_text_location();
if(has_background_) {
surface border_top = NULL;
surface border_bottom = NULL;
if(tbl == part::BOTTOM || tbl == part::MIDDLE) {
if(tbl == part::BLOCK_BOTTOM || tbl == part::BLOCK_MIDDLE) {
border_top = image::get_image(storybox_top_border_path);
}
if(tbl == part::TOP || tbl == part::MIDDLE) {
if(tbl == part::BLOCK_TOP || tbl == part::BLOCK_MIDDLE) {
border_bottom = image::get_image(storybox_bottom_border_path);
}
@ -380,7 +380,7 @@ void part_ui::render_story_box()
return;
}
const part::TEXT_BLOCK_LOCATION tbl = p_.text_block_location();
const part::BLOCK_LOCATION tbl = p_.story_text_location();
const int max_width = buttons_x_ - storybox_padding - text_x_;
const int max_height = screen_area().h - storybox_padding;
@ -405,7 +405,7 @@ void part_ui::render_story_box()
}
int fix_text_y = text_y_;
if(fix_text_y + storybox_padding + txtsurf->h > screen_area().h && tbl != part::TOP) {
if(fix_text_y + storybox_padding + txtsurf->h > screen_area().h && tbl != part::BLOCK_TOP) {
fix_text_y =
(screen_area().h > txtsurf->h + 1) ?
(std::max(0, screen_area().h - txtsurf->h - (storybox_padding+1))) :
@ -413,10 +413,10 @@ void part_ui::render_story_box()
}
int fix_text_h;
switch(tbl) {
case part::TOP:
case part::BLOCK_TOP:
fix_text_h = std::max(txtsurf->h + 2*storybox_padding, screen_area().h/4);
break;
case part::MIDDLE:
case part::BLOCK_MIDDLE:
fix_text_h = std::max(txtsurf->h + 2*storybox_padding, screen_area().h/3);
break;
default: