Remove the global TextStyle; this should fix some of the textual glitches

This commit is contained in:
2014-04-21 01:49:07 -04:00
parent f9a21dd068
commit 002ee640da
23 changed files with 411 additions and 461 deletions

View File

@@ -540,6 +540,8 @@
91E5C7BA0F9F619D00C21460 /* talking.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91E5C7B70F9F619D00C21460 /* talking.cpp */; }; 91E5C7BA0F9F619D00C21460 /* talking.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91E5C7B70F9F619D00C21460 /* talking.cpp */; };
91EC483B18FBAD8000BB1E86 /* prefs.mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 91EC481018FBABB100BB1E86 /* prefs.mac.mm */; }; 91EC483B18FBAD8000BB1E86 /* prefs.mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 91EC481018FBABB100BB1E86 /* prefs.mac.mm */; };
91EC485518FC6C4400BB1E86 /* pc-info.xml in Copy Dialog Definitions */ = {isa = PBXBuildFile; fileRef = 9107074B18F0FE3F00F7BD7F /* pc-info.xml */; }; 91EC485518FC6C4400BB1E86 /* pc-info.xml in Copy Dialog Definitions */ = {isa = PBXBuildFile; fileRef = 9107074B18F0FE3F00F7BD7F /* pc-info.xml */; };
91EF052C1904D099001BEF85 /* bold.ttf in Copy Fonts */ = {isa = PBXBuildFile; fileRef = 91EF05291904D082001BEF85 /* bold.ttf */; };
91EF052D1904D099001BEF85 /* plain.ttf in Copy Fonts */ = {isa = PBXBuildFile; fileRef = 91EF052A1904D082001BEF85 /* plain.ttf */; };
91F6F8E318F87F3700E3EA15 /* sfml-audio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 91F6F8DD18F87F3700E3EA15 /* sfml-audio.framework */; }; 91F6F8E318F87F3700E3EA15 /* sfml-audio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 91F6F8DD18F87F3700E3EA15 /* sfml-audio.framework */; };
91F6F8E418F87F3700E3EA15 /* sfml-audio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 91F6F8DD18F87F3700E3EA15 /* sfml-audio.framework */; }; 91F6F8E418F87F3700E3EA15 /* sfml-audio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 91F6F8DD18F87F3700E3EA15 /* sfml-audio.framework */; };
91F6F8E518F87F3700E3EA15 /* sfml-audio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 91F6F8DD18F87F3700E3EA15 /* sfml-audio.framework */; }; 91F6F8E518F87F3700E3EA15 /* sfml-audio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 91F6F8DD18F87F3700E3EA15 /* sfml-audio.framework */; };
@@ -791,6 +793,8 @@
files = ( files = (
914701A718F62ABF008A6DC9 /* dungeon.ttf in Copy Fonts */, 914701A718F62ABF008A6DC9 /* dungeon.ttf in Copy Fonts */,
914701A818F62AC0008A6DC9 /* maidenword.ttf in Copy Fonts */, 914701A818F62AC0008A6DC9 /* maidenword.ttf in Copy Fonts */,
91EF052C1904D099001BEF85 /* bold.ttf in Copy Fonts */,
91EF052D1904D099001BEF85 /* plain.ttf in Copy Fonts */,
); );
name = "Copy Fonts"; name = "Copy Fonts";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
@@ -1633,6 +1637,8 @@
91E5C7B70F9F619D00C21460 /* talking.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = talking.cpp; sourceTree = "<group>"; }; 91E5C7B70F9F619D00C21460 /* talking.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = talking.cpp; sourceTree = "<group>"; };
91EC480E18FBAA8700BB1E86 /* prefs.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = prefs.hpp; sourceTree = "<group>"; }; 91EC480E18FBAA8700BB1E86 /* prefs.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = prefs.hpp; sourceTree = "<group>"; };
91EC481018FBABB100BB1E86 /* prefs.mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = prefs.mac.mm; sourceTree = "<group>"; }; 91EC481018FBABB100BB1E86 /* prefs.mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = prefs.mac.mm; sourceTree = "<group>"; };
91EF05291904D082001BEF85 /* bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = bold.ttf; sourceTree = "<group>"; };
91EF052A1904D082001BEF85 /* plain.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = plain.ttf; sourceTree = "<group>"; };
91F6F8DD18F87F3700E3EA15 /* sfml-audio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "sfml-audio.framework"; path = "/Library/Frameworks/sfml-audio.framework"; sourceTree = "<absolute>"; }; 91F6F8DD18F87F3700E3EA15 /* sfml-audio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "sfml-audio.framework"; path = "/Library/Frameworks/sfml-audio.framework"; sourceTree = "<absolute>"; };
91F6F8DE18F87F3700E3EA15 /* sfml-graphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "sfml-graphics.framework"; path = "/Library/Frameworks/sfml-graphics.framework"; sourceTree = "<absolute>"; }; 91F6F8DE18F87F3700E3EA15 /* sfml-graphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "sfml-graphics.framework"; path = "/Library/Frameworks/sfml-graphics.framework"; sourceTree = "<absolute>"; };
91F6F8E018F87F3700E3EA15 /* sfml-system.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "sfml-system.framework"; path = "/Library/Frameworks/sfml-system.framework"; sourceTree = "<absolute>"; }; 91F6F8E018F87F3700E3EA15 /* sfml-system.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "sfml-system.framework"; path = "/Library/Frameworks/sfml-system.framework"; sourceTree = "<absolute>"; };
@@ -2133,8 +2139,10 @@
914701A318F629D4008A6DC9 /* fonts */ = { 914701A318F629D4008A6DC9 /* fonts */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
91EF05291904D082001BEF85 /* bold.ttf */,
914701A418F629D4008A6DC9 /* dungeon.ttf */, 914701A418F629D4008A6DC9 /* dungeon.ttf */,
914701A518F629D4008A6DC9 /* maidenword.ttf */, 914701A518F629D4008A6DC9 /* maidenword.ttf */,
91EF052A1904D082001BEF85 /* plain.ttf */,
); );
path = fonts; path = fonts;
sourceTree = "<group>"; sourceTree = "<group>";

View File

@@ -326,18 +326,19 @@ void draw_startup_stats()
short i; short i;
char str[256]; char str[256];
TEXT.font = "Dungeon"; TextStyle style;
TEXT.style = sf::Text::Regular; style.font = FONT_DUNGEON;
TEXT.pointSize = 24; style.pointSize = 24;
to_rect = startup_top; to_rect = startup_top;
to_rect.offset(20 - 18, 35); to_rect.offset(20 - 18, 35);
TEXT.colour = sf::Color::White; style.colour = sf::Color::White;
style.lineHeight = 18;
if(!party_in_memory) { if(!party_in_memory) {
TEXT.pointSize = 20; style.pointSize = 20;
to_rect.offset(175,40); to_rect.offset(175,40);
win_draw_string(mainPtr,to_rect,"No Party in Memory",0,18,ul); win_draw_string(mainPtr,to_rect,"No Party in Memory",0,style,ul);
} else { } else {
frame_rect = startup_top; frame_rect = startup_top;
frame_rect.inset(50,50); frame_rect.inset(50,50);
@@ -347,10 +348,9 @@ void draw_startup_stats()
::frame_rect(mainPtr, frame_rect, sf::Color::White); ::frame_rect(mainPtr, frame_rect, sf::Color::White);
to_rect.offset(203,37); to_rect.offset(203,37);
win_draw_string(mainPtr,to_rect,"Your party:",0,18,ul); win_draw_string(mainPtr,to_rect,"Your party:",0,style,ul);
TEXT.pointSize = 12; style.pointSize = 12;
TEXT.style = sf::Text::Bold; style.font = FONT_BOLD;
TEXT.font = "Geneva";
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
pc_rect = startup_top; pc_rect = startup_top;
pc_rect.right = pc_rect.left + 300; pc_rect.right = pc_rect.left + 300;
@@ -363,13 +363,13 @@ void draw_startup_stats()
to_rect.offset(pc_rect.left,pc_rect.top); to_rect.offset(pc_rect.left,pc_rect.top);
rect_draw_some_item(pc_gworld,from_rect,to_rect,ul,sf::BlendAlpha); rect_draw_some_item(pc_gworld,from_rect,to_rect,ul,sf::BlendAlpha);
TEXT.pointSize = 14; style.pointSize = 14;
pc_rect.offset(35,0); pc_rect.offset(35,0);
win_draw_string(mainPtr,pc_rect,univ.party[i].name,0,18,ul); win_draw_string(mainPtr,pc_rect,univ.party[i].name,0,style,ul);
to_rect.offset(pc_rect.left + 8,pc_rect.top + 8); to_rect.offset(pc_rect.left + 8,pc_rect.top + 8);
} }
TEXT.pointSize = 12; style.pointSize = 12;
pc_rect.offset(12,16); pc_rect.offset(12,16);
switch (univ.party[i].main_status) { switch (univ.party[i].main_status) {
case MAIN_STATUS_ALIVE: case MAIN_STATUS_ALIVE:
@@ -396,23 +396,23 @@ void draw_startup_stats()
case RACE_BIRD: sprintf((char *) str,"Level %d Bird",univ.party[i].level); break; case RACE_BIRD: sprintf((char *) str,"Level %d Bird",univ.party[i].level); break;
default: sprintf((char *) str,"Level %d *ERROR INVALID RACE*",univ.party[i].level); break; default: sprintf((char *) str,"Level %d *ERROR INVALID RACE*",univ.party[i].level); break;
} }
win_draw_string(mainPtr,pc_rect,str,0,18,ul); win_draw_string(mainPtr,pc_rect,str,0,style,ul);
pc_rect.offset(0,13); pc_rect.offset(0,13);
sprintf((char *) str,"Health %d, Spell pts. %d", sprintf((char *) str,"Health %d, Spell pts. %d",
univ.party[i].max_health,univ.party[i].max_sp); univ.party[i].max_health,univ.party[i].max_sp);
win_draw_string(mainPtr,pc_rect,str,0,18,ul); win_draw_string(mainPtr,pc_rect,str,0,style,ul);
break; break;
case MAIN_STATUS_DEAD: case MAIN_STATUS_DEAD:
win_draw_string(mainPtr,pc_rect,"Dead",0,18,ul); win_draw_string(mainPtr,pc_rect,"Dead",0,style,ul);
break; break;
case MAIN_STATUS_DUST: case MAIN_STATUS_DUST:
win_draw_string(mainPtr,pc_rect,"Dust",0,18,ul); win_draw_string(mainPtr,pc_rect,"Dust",0,style,ul);
break; break;
case MAIN_STATUS_STONE: case MAIN_STATUS_STONE:
win_draw_string(mainPtr,pc_rect,"Stone",0,18,ul); win_draw_string(mainPtr,pc_rect,"Stone",0,style,ul);
break; break;
case MAIN_STATUS_FLED: case MAIN_STATUS_FLED:
win_draw_string(mainPtr,pc_rect,"Fled",0,18,ul); win_draw_string(mainPtr,pc_rect,"Fled",0,style,ul);
break; break;
default: //absent, and all variations thereof; do nothing default: //absent, and all variations thereof; do nothing
break; break;
@@ -420,17 +420,14 @@ void draw_startup_stats()
} }
} }
TEXT.font = "Geneva"; style.font = FONT_BOLD;
TEXT.pointSize = 10; style.pointSize = 10;
TEXT.style = sf::Text::Bold;
pc_rect = startup_from[0]; pc_rect = startup_from[0];
pc_rect.offset(5,5); pc_rect.offset(5,5);
pc_rect.top = pc_rect.bottom - 25; pc_rect.top = pc_rect.bottom - 25;
pc_rect.left = pc_rect.right - 300; pc_rect.left = pc_rect.right - 300;
// TODO: Should replace this with a more appropriate copyright string // TODO: Should replace this with a more appropriate copyright string
win_draw_string(mainPtr,pc_rect,"Copyright 1997, All Rights Reserved, v1.0.2",0,18,ul); win_draw_string(mainPtr,pc_rect,"Copyright 1997, All Rights Reserved, v1.0.2",0,style,ul);
TEXT.colour = sf::Color::Black;
} }
@@ -452,9 +449,9 @@ void draw_start_button(short which_position,short which_button)
to_rect.bottom = to_rect.top + 40; to_rect.bottom = to_rect.top + 40;
rect_draw_some_item(startup_gworld,from_rect,to_rect,ul); rect_draw_some_item(startup_gworld,from_rect,to_rect,ul);
TEXT.font = "Dungeon"; TextStyle style;
TEXT.style = sf::Text::Regular; style.font = FONT_DUNGEON;
TEXT.pointSize = 24; style.pointSize = 24;
to_rect = startup_button[which_position]; to_rect = startup_button[which_position];
//to_rect.left += 80; //to_rect.left += 80;
to_rect.offset(10, 10); to_rect.offset(10, 10);
@@ -462,15 +459,11 @@ void draw_start_button(short which_position,short which_button)
which_button = 4; which_button = 4;
// In the 0..65535 range, this was 14472 + (12288 * which_button) // In the 0..65535 range, this was 14472 + (12288 * which_button)
base_color.b += (48 * which_button); base_color.b += (48 * which_button);
TEXT.colour = base_color; style.colour = base_color;
style.lineHeight = 18;
if (which_position == 3) if (which_position == 3)
to_rect.offset(-7,0); to_rect.offset(-7,0);
win_draw_string(mainPtr,to_rect,button_labels[which_position],1,18,ul); win_draw_string(mainPtr,to_rect,button_labels[which_position],1,style,ul);
TEXT.colour = sf::Color::Black;
TEXT.font = "Geneva";
TEXT.style = sf::Text::Bold;
TEXT.pointSize = 10;
} }
void main_button_click(short mode,RECT button_rect) void main_button_click(short mode,RECT button_rect)
@@ -574,39 +567,6 @@ void load_main_screen()
loadImageToRenderTexture(text_bar_gworld, "textbar"); loadImageToRenderTexture(text_bar_gworld, "textbar");
orig_text_bar_gworld.loadFromImage(*ResMgr::get<ImageRsrc>("textbar")); orig_text_bar_gworld.loadFromImage(*ResMgr::get<ImageRsrc>("textbar"));
buttons_gworld.loadFromImage(*ResMgr::get<ImageRsrc>("buttons")); buttons_gworld.loadFromImage(*ResMgr::get<ImageRsrc>("buttons"));
// set_gworld_fonts(geneva_font_num);
}
void set_gworld_fonts(short font_num)
{
// TODO: This doesn't even make sense since fonts aren't set for each surface in SFML
#if 0
GrafPtr old_port;
GetPort(&old_port);
SetPort(GetWindowPort(mainPtr));
TextFont(font_num);
TextFace(bold);
TextSize(10);
SetPort(pc_stats_gworld);
TextFont(font_num);
TextFace(bold);
TextSize(10);
SetPort(item_stats_gworld);
TextFont(font_num);
TextFace(bold);
TextSize(10);
SetPort(text_area_gworld);
TextFont(font_num);
TextFace(bold);
TextSize(10);
SetPort(text_bar_gworld);
TextFont(font_num);
TextFace(bold);
TextSize(10);
SetPort(old_port);
#endif
} }
void redraw_screen(int refresh) { void redraw_screen(int refresh) {
@@ -782,35 +742,36 @@ void draw_text_bar(short mode)
void put_text_bar(char *str) { void put_text_bar(char *str) {
text_bar_gworld.setActive(); text_bar_gworld.setActive();
rect_draw_some_item(orig_text_bar_gworld, win_from_rects[4], text_bar_gworld, win_from_rects[4]); rect_draw_some_item(orig_text_bar_gworld, win_from_rects[4], text_bar_gworld, win_from_rects[4]);
TEXT.colour = sf::Color::White; TextStyle style;
TEXT.font = "Silom"; style.colour = sf::Color::White;
TEXT.pointSize = 12; style.font = FONT_BOLD;
style.pointSize = 12;
style.lineHeight = 12;
RECT to_rect = RECT(text_bar_gworld); RECT to_rect = RECT(text_bar_gworld);
// TODO: The 12 is the line height; not sure what it should be, so I just picked something // TODO: Not sure what the line height should be, so I just picked something
win_draw_string(text_bar_gworld, to_rect, str, 2, 12); win_draw_string(text_bar_gworld, to_rect, str, 2, style);
if (monsters_going == false) { if (monsters_going == false) {
to_rect.left = 205; to_rect.left = 205;
to_rect.top = 14; to_rect.top = 14;
if (PSD[SDF_PARTY_STEALTHY] > 0) { if (PSD[SDF_PARTY_STEALTHY] > 0) {
win_draw_string(text_bar_gworld, to_rect, "Stealth", 2, 12); win_draw_string(text_bar_gworld, to_rect, "Stealth", 2, style);
to_rect.left -= 60; to_rect.left -= 60;
} }
if (PSD[SDF_PARTY_FLIGHT] > 0) { if (PSD[SDF_PARTY_FLIGHT] > 0) {
win_draw_string(text_bar_gworld, to_rect, "Flying", 2, 12); win_draw_string(text_bar_gworld, to_rect, "Flying", 2, style);
to_rect.left -= 60; to_rect.left -= 60;
} }
if (PSD[SDF_PARTY_DETECT_LIFE] > 0) { if (PSD[SDF_PARTY_DETECT_LIFE] > 0) {
win_draw_string(text_bar_gworld, to_rect, "Detect Life", 2, 12); win_draw_string(text_bar_gworld, to_rect, "Detect Life", 2, style);
to_rect.left -= 60; to_rect.left -= 60;
} }
if (PSD[SDF_PARTY_FIREWALK] > 0) { if (PSD[SDF_PARTY_FIREWALK] > 0) {
win_draw_string(text_bar_gworld, to_rect, "Firewalk", 2, 12); win_draw_string(text_bar_gworld, to_rect, "Firewalk", 2, style);
to_rect.left -= 60; to_rect.left -= 60;
} }
} }
TEXT.colour = sf::Color::Black;
text_bar_gworld.display(); text_bar_gworld.display();
} }
@@ -1578,8 +1539,8 @@ void boom_space(location where,short mode,short type,short damage,short sound)
if ((dest_rect.right - dest_rect.left >= 28) && (dest_rect.bottom - dest_rect.top >= 36)) { if ((dest_rect.right - dest_rect.left >= 28) && (dest_rect.bottom - dest_rect.top >= 36)) {
sprintf((char *) dam_str,"%d",damage); sprintf((char *) dam_str,"%d",damage);
TEXT.pointSize = 10; TextStyle style;
TEXT.style = sf::Text::Bold; style.lineHeight = 10;
//text_rect = coord_to_rect(where_draw.x,where_draw.y); //text_rect = coord_to_rect(where_draw.x,where_draw.y);
//OffsetRect(&text_rect,x_adj,y_adj); //OffsetRect(&text_rect,x_adj,y_adj);
text_rect = dest_rect; text_rect = dest_rect;
@@ -1587,8 +1548,7 @@ void boom_space(location where,short mode,short type,short damage,short sound)
if ((damage < 10) && (dest_rect.right - dest_rect.left > 19)) if ((damage < 10) && (dest_rect.right - dest_rect.left > 19))
text_rect.left += 10; text_rect.left += 10;
text_rect.offset(-4,-5); text_rect.offset(-4,-5);
win_draw_string(mainPtr,text_rect,dam_str,1,10,ul); win_draw_string(mainPtr,text_rect,dam_str,1,style,ul);
TEXT.style = sf::Text::Regular;
} }
play_sound((skip_boom_delay?-1:1)*sound_to_play[sound]); play_sound((skip_boom_delay?-1:1)*sound_to_play[sound]);
mainPtr.display(); mainPtr.display();
@@ -1767,12 +1727,13 @@ void draw_targeting_line(location where_curs)
// Now place number of shots left, if drawing center of target // Now place number of shots left, if drawing center of target
if ((overall_mode == MODE_FANCY_TARGET) && (store_loc.x - which_space.x + 4 == 4) if ((overall_mode == MODE_FANCY_TARGET) && (store_loc.x - which_space.x + 4 == 4)
&& (store_loc.y - which_space.y + 4 == 4)) { && (store_loc.y - which_space.y + 4 == 4)) {
TEXT.colour = sf::Color::White; TextStyle style;
style.colour = sf::Color::White;
style.lineHeight = 12;
const char chr[2] = {static_cast<char>(num_targets_left + '0')}; const char chr[2] = {static_cast<char>(num_targets_left + '0')};
int x = ((target_rect.left + target_rect.right) / 2) - 3; int x = ((target_rect.left + target_rect.right) / 2) - 3;
int y = (target_rect.top + target_rect.bottom) / 2; int y = (target_rect.top + target_rect.bottom) / 2;
win_draw_string(mainPtr, RECT(y, x, y + 12, x + 12), chr, 1, 12); win_draw_string(mainPtr, RECT(y, x, y + 12, x + 12), chr, 1, style);
TEXT.colour = sf::Color::Black;
} }
} }

View File

@@ -28,7 +28,6 @@ void arrow_button_click(RECT button_rect);
void end_startup(); void end_startup();
void Set_up_win (); void Set_up_win ();
void load_main_screen(); void load_main_screen();
void set_gworld_fonts(short font_num);
void redraw_screen(int refresh); void redraw_screen(int refresh);
void put_background(); void put_background();
void draw_buttons(short mode); void draw_buttons(short mode);

View File

@@ -603,10 +603,9 @@ void do_explosion_anim(short sound_num,short special_draw)
temp_rect = RECT(terrain_screen_gworld); temp_rect = RECT(terrain_screen_gworld);
active_area_rect = temp_rect; active_area_rect = temp_rect;
active_area_rect.inset(13,13); active_area_rect.inset(13,13);
// TODO: Deglobalize this TextStyle style;
TEXT.font = "Geneva"; style.font = FONT_BOLD;
TEXT.style = sf::Text::Bold; style.pointSize = 10;
TEXT.pointSize = 10;
temp_gworld.create(temp_rect.width(), temp_rect.height()); temp_gworld.create(temp_rect.width(), temp_rect.height());
temp_gworld.setActive(); temp_gworld.setActive();
clip_rect(temp_gworld, active_area_rect); clip_rect(temp_gworld, active_area_rect);
@@ -667,9 +666,10 @@ void do_explosion_anim(short sound_num,short special_draw)
if (store_booms[i].val_to_place < 10) if (store_booms[i].val_to_place < 10)
text_rect.left += 8; text_rect.left += 8;
sprintf(str,"%d",store_booms[i].val_to_place); sprintf(str,"%d",store_booms[i].val_to_place);
TEXT.colour = sf::Color::White; style.colour = sf::Color::White;
win_draw_string(temp_gworld,text_rect,str,1,12); style.lineHeight = 12;
TEXT.colour = sf::Color::Black; win_draw_string(temp_gworld,text_rect,str,1,style);
style.colour = sf::Color::Black;
mainPtr.setActive(); mainPtr.setActive();
} }
} }
@@ -766,9 +766,9 @@ void draw_shop_graphics(bool pressed,RECT clip_area_rect)
} }
talk_gworld.setActive(); talk_gworld.setActive();
TEXT.font = "Dungeon"; TextStyle style;
TEXT.pointSize = 18; style.font = FONT_DUNGEON;
TEXT.style = sf::Text::Regular; style.pointSize = 18;
talk_gworld.setActive(); talk_gworld.setActive();
if (pressed) { if (pressed) {
@@ -792,19 +792,19 @@ void draw_shop_graphics(bool pressed,RECT clip_area_rect)
// Place name of store and shopper name // Place name of store and shopper name
TEXT.colour = c[3]; style.colour = c[3];
style.lineHeight = 18;
dest_rect = title_rect; dest_rect = title_rect;
dest_rect.offset(1,1); dest_rect.offset(1,1);
win_draw_string(talk_gworld,dest_rect,store_store_name,2,18); win_draw_string(talk_gworld,dest_rect,store_store_name,2,style);
dest_rect.offset(-1,-1); dest_rect.offset(-1,-1);
TEXT.colour = c[4]; style.colour = c[4];
win_draw_string(talk_gworld,dest_rect,store_store_name,2,18); win_draw_string(talk_gworld,dest_rect,store_store_name,2,style);
TEXT.font = "Geneva"; style.font = FONT_BOLD;
TEXT.pointSize = 12;; style.pointSize = 12;
TEXT.style = sf::Text::Bold;
TEXT.colour = c[3]; style.colour = c[3];
switch (store_shop_type) { switch (store_shop_type) {
case 3: sprintf(cur_name,"Healing for %s.",univ.party[current_pc].name.c_str()); break; case 3: sprintf(cur_name,"Healing for %s.",univ.party[current_pc].name.c_str()); break;
case 10: sprintf(cur_name,"Mage Spells for %s.",univ.party[current_pc].name.c_str());break; case 10: sprintf(cur_name,"Mage Spells for %s.",univ.party[current_pc].name.c_str());break;
@@ -813,10 +813,9 @@ void draw_shop_graphics(bool pressed,RECT clip_area_rect)
case 4: sprintf(cur_name,"Buying Food.");break; case 4: sprintf(cur_name,"Buying Food.");break;
default:sprintf(cur_name,"Shopping for %s.",univ.party[current_pc].name.c_str()); break; default:sprintf(cur_name,"Shopping for %s.",univ.party[current_pc].name.c_str()); break;
} }
win_draw_string(talk_gworld,shopper_name,cur_name,2,18); win_draw_string(talk_gworld,shopper_name,cur_name,2,style);
// Place help and done buttons // Place help and done buttons
TEXT.colour = sf::Color::Black;
// TODO: Reimplement these with a cButton // TODO: Reimplement these with a cButton
#if 0 #if 0
help_from = RECT(dlg_buttons_gworld[3][0]); // help help_from = RECT(dlg_buttons_gworld[3][0]); // help
@@ -830,8 +829,8 @@ void draw_shop_graphics(bool pressed,RECT clip_area_rect)
#endif #endif
if (pressed) if (pressed)
TEXT.colour = c[4]; style.colour = c[4];
else TEXT.colour = sf::Color::Black; else style.colour = sf::Color::Black;
// Place all the items // Place all the items
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
@@ -901,29 +900,28 @@ void draw_shop_graphics(bool pressed,RECT clip_area_rect)
// Now draw item shopping_rects[i][7] // Now draw item shopping_rects[i][7]
// 0 - whole area, 1 - active area 2 - graphic 3 - item name // 0 - whole area, 1 - active area 2 - graphic 3 - item name
// 4 - item cost 5 - item extra str 6 - item help button // 4 - item cost 5 - item extra str 6 - item help button
TEXT.pointSize = 12; style.pointSize = 12;
win_draw_string(talk_gworld,shopping_rects[i][3],cur_name,0,12); style.lineHeight = 12;
win_draw_string(talk_gworld,shopping_rects[i][3],cur_name,0,style);
sprintf(cur_name,"Cost: %d",cur_cost); sprintf(cur_name,"Cost: %d",cur_cost);
win_draw_string(talk_gworld,shopping_rects[i][4],cur_name,0,12); win_draw_string(talk_gworld,shopping_rects[i][4],cur_name,0,style);
TEXT.pointSize = 10; style.pointSize = 10;
win_draw_string(talk_gworld,shopping_rects[i][5],cur_info_str,0,12); win_draw_string(talk_gworld,shopping_rects[i][5],cur_info_str,0,style);
if ((store_shop_type != 3) && (store_shop_type != 4)) if ((store_shop_type != 3) && (store_shop_type != 4))
rect_draw_some_item(invenbtn_gworld,item_info_from,talk_gworld,shopping_rects[i][6],pressed ? sf::BlendNone : sf::BlendAlpha); rect_draw_some_item(invenbtn_gworld,item_info_from,talk_gworld,shopping_rects[i][6],pressed ? sf::BlendNone : sf::BlendAlpha);
} }
// Finally, cost info and help strs // Finally, cost info and help strs
TEXT.pointSize = 12;
sprintf(cur_name,"Prices here are %s.",cost_strs[store_cost_mult]); sprintf(cur_name,"Prices here are %s.",cost_strs[store_cost_mult]);
TEXT.pointSize = 10; style.pointSize = 10;
win_draw_string(talk_gworld,bottom_help_rects[0],cur_name,0,12); style.lineHeight = 12;
win_draw_string(talk_gworld,bottom_help_rects[1],"Click on item name (or type 'a'-'h') to buy.",0,12); win_draw_string(talk_gworld,bottom_help_rects[0],cur_name,0,style);
win_draw_string(talk_gworld,bottom_help_rects[2],"Hit done button (or Esc.) to quit.",0,12); win_draw_string(talk_gworld,bottom_help_rects[1],"Click on item name (or type 'a'-'h') to buy.",0,style);
win_draw_string(talk_gworld,bottom_help_rects[2],"Hit done button (or Esc.) to quit.",0,style);
if ((store_shop_type != 3) && (store_shop_type != 4)) if ((store_shop_type != 3) && (store_shop_type != 4))
win_draw_string(talk_gworld,bottom_help_rects[3],"'I' button brings up description.",0,12); win_draw_string(talk_gworld,bottom_help_rects[3],"'I' button brings up description.",0,style);
TEXT.colour = sf::Color::Black;
undo_clip(talk_gworld); undo_clip(talk_gworld);
talk_gworld.display(); talk_gworld.display();
@@ -1091,9 +1089,9 @@ void place_talk_str(std::string str_to_place,std::string str_to_place2,short col
talk_gworld.setActive(); talk_gworld.setActive();
TEXT.font = "Dungeon"; TextStyle style;
TEXT.pointSize = 18; style.font = FONT_DUNGEON;
TEXT.style = sf::Text::Regular; style.pointSize = 18;
if (c_rect.right > 0) { if (c_rect.right > 0) {
mainPtr.setActive(); mainPtr.setActive();
@@ -1139,22 +1137,23 @@ void place_talk_str(std::string str_to_place,std::string str_to_place2,short col
talk_gworld.setActive(); talk_gworld.setActive();
} }
// Place name oftalkee // Place name oftalkee
TEXT.colour = c[3]; style.colour = c[3];
style.lineHeight = 18;
dest_rect = title_rect; dest_rect = title_rect;
dest_rect.offset(1,1); dest_rect.offset(1,1);
win_draw_string(talk_gworld,dest_rect,title_string,2,18); win_draw_string(talk_gworld,dest_rect,title_string,2,style);
dest_rect.offset(-1,-1); dest_rect.offset(-1,-1);
TEXT.colour = c[4]; style.colour = c[4];
win_draw_string(talk_gworld,dest_rect,title_string,2,18); win_draw_string(talk_gworld,dest_rect,title_string,2,style);
// Place buttons at bottom. // Place buttons at bottom.
if (color == 0) if (color == 0)
TEXT.colour = c[5]; style.colour = c[5];
else TEXT.colour = c[6]; else style.colour = c[6];
for (i = 0; i < 9; i++) for (i = 0; i < 9; i++)
if ((talk_end_forced == false) || (i == 6) || (i == 5)) { if ((talk_end_forced == false) || (i == 6) || (i == 5)) {
preset_words[i].word_rect.offset(0,8); preset_words[i].word_rect.offset(0,8);
win_draw_string(talk_gworld,preset_words[i].word_rect,preset_words[i].word,2,18); win_draw_string(talk_gworld,preset_words[i].word_rect,preset_words[i].word,2,style);
preset_words[i].word_rect.offset(0,-8); preset_words[i].word_rect.offset(0,-8);
} }
// Place bulk of what said. Save words. // Place bulk of what said. Save words.
@@ -1179,11 +1178,12 @@ void place_talk_str(std::string str_to_place,std::string str_to_place2,short col
current_rect = 0; current_rect = 0;
if (color == 0) if (color == 0)
TEXT.colour = c[2]; style.colour = c[2];
else TEXT.colour = c[1]; else style.colour = c[1];
TEXT.applyTo(str_to_draw); style.lineHeight = line_height;
style.applyTo(str_to_draw);
// TODO: The entire text flashes when clicking anything // TODO: The entire text flashes when clicking anything
win_draw_string(talk_gworld, dest_rect, str, 0, line_height); win_draw_string(talk_gworld, dest_rect, str, 0, style);
for (i = 0;i < str_len;i++) { for (i = 0;i < str_len;i++) {
if (((str[i] != 39) && ((str[i] < 65) || (str[i] > 122)) && ((str[i] < 48) || (str[i] > 57))) && (color == 0)) { // New word, so set up a rect if (((str[i] != 39) && ((str[i] < 65) || (str[i] > 122)) && ((str[i] < 48) || (str[i] > 57))) && (color == 0)) { // New word, so set up a rect
if (((i - store_last_word_break >= 4) || (i >= str_len - 1)) if (((i - store_last_word_break >= 4) || (i >= str_len - 1))
@@ -1254,7 +1254,7 @@ void place_talk_str(std::string str_to_place,std::string str_to_place2,short col
str_to_draw.setString(str); str_to_draw.setString(str);
last_line_break = store_last_word_break = last_word_break = last_stored_word_break = 0; last_line_break = store_last_word_break = last_word_break = last_stored_word_break = 0;
win_draw_string(talk_gworld, dest_rect, str, 0, line_height); win_draw_string(talk_gworld, dest_rect, str, 0, style);
for (i = 0;i < str_len;i++) { for (i = 0;i < str_len;i++) {
if (((str[i] != 39) && ((str[i] < 65) || (str[i] > 122)) && ((str[i] < 48) || (str[i] > 57))) && (color == 0)) { // New word, so set up a rect if (((str[i] != 39) && ((str[i] < 65) || (str[i] > 122)) && ((str[i] < 48) || (str[i] > 57))) && (color == 0)) { // New word, so set up a rect
if (((i - store_last_word_break >= 4) || (i >= str_len - 1)) if (((i - store_last_word_break >= 4) || (i >= str_len - 1))
@@ -1312,7 +1312,6 @@ void place_talk_str(std::string str_to_place,std::string str_to_place2,short col
} }
} }
TEXT.colour = sf::Color::Black;
RECT oldRect(talk_gworld); RECT oldRect(talk_gworld);
undo_clip(talk_gworld); undo_clip(talk_gworld);
talk_gworld.display(); talk_gworld.display();

View File

@@ -142,49 +142,49 @@ void put_pc_screen()
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
tileImage(pc_stats_gworld, small_erase_rects[i],bg_gworld,bg[7]); tileImage(pc_stats_gworld, small_erase_rects[i],bg_gworld,bg[7]);
TEXT.font = "Silom"; TextStyle style;
TEXT.pointSize = 12; style.font = FONT_BOLD;
TEXT.colour = sf::Color::White; style.pointSize = 12;
TEXT.style = sf::Text::Regular; style.colour = sf::Color::White;
style.lineHeight = 10;
// Put food, gold, day // Put food, gold, day
sprintf((char *) to_draw, "%d", (short) univ.party.gold); sprintf((char *) to_draw, "%d", (short) univ.party.gold);
win_draw_string( pc_stats_gworld,small_erase_rects[1],to_draw,0,10); win_draw_string( pc_stats_gworld,small_erase_rects[1],to_draw,0,style);
sprintf((char *) to_draw, "%d", (short) univ.party.food); sprintf((char *) to_draw, "%d", (short) univ.party.food);
win_draw_string( pc_stats_gworld,small_erase_rects[0],to_draw,0,10); win_draw_string( pc_stats_gworld,small_erase_rects[0],to_draw,0,style);
i = calc_day(); i = calc_day();
sprintf((char *) to_draw, "%d", i); sprintf((char *) to_draw, "%d", i);
win_draw_string( pc_stats_gworld,small_erase_rects[2],to_draw,0,10); win_draw_string( pc_stats_gworld,small_erase_rects[2],to_draw,0,style);
TEXT.colour = sf::Color::Black; style.colour = sf::Color::Black;
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
if (univ.party[i].main_status != 0) { if (univ.party[i].main_status != 0) {
for (j = 0; j < 5; j++) for (j = 0; j < 5; j++)
pc_area_button_active[i][j] = 1; pc_area_button_active[i][j] = 1;
if (i == current_pc) { if (i == current_pc) {
TEXT.style = sf::Text::Italic; style.italic = true;
TEXT.colour = sf::Color::Blue; style.colour = sf::Color::Blue;
} }
sprintf((char *) to_draw, "%d. %-20s ", i + 1, (char *) univ.party[i].name.c_str()); sprintf((char *) to_draw, "%d. %-20s ", i + 1, (char *) univ.party[i].name.c_str());
win_draw_string( pc_stats_gworld,pc_buttons[i][0],to_draw,0,10); win_draw_string(pc_stats_gworld,pc_buttons[i][0],to_draw,0,style);
TEXT.style = sf::Text::Regular; style.italic = false;
TEXT.colour = sf::Color::Black; style.colour = sf::Color::Black;
to_draw_rect = pc_buttons[i][1]; to_draw_rect = pc_buttons[i][1];
to_draw_rect.right += 20; to_draw_rect.right += 20;
switch (univ.party[i].main_status) { switch (univ.party[i].main_status) {
case 1: case 1:
if (univ.party[i].cur_health == univ.party[i].max_health) if (univ.party[i].cur_health == univ.party[i].max_health)
TEXT.colour = sf::Color::Green; style.colour = sf::Color::Green;
else TEXT.colour = sf::Color::Red; else style.colour = sf::Color::Red;
sprintf((char *) to_draw, "%-3d ",univ.party[i].cur_health); sprintf((char *) to_draw, "%-3d ",univ.party[i].cur_health);
win_draw_string( pc_stats_gworld,pc_buttons[i][1],to_draw,0,10); win_draw_string( pc_stats_gworld,pc_buttons[i][1],to_draw,0,style);
if (univ.party[i].cur_sp == univ.party[i].max_sp) if (univ.party[i].cur_sp == univ.party[i].max_sp)
TEXT.colour = sf::Color::Blue; style.colour = sf::Color::Blue;
else TEXT.colour = sf::Color::Magenta; else style.colour = sf::Color::Magenta;
sprintf((char *) to_draw, "%-3d ",univ.party[i].cur_sp); sprintf((char *) to_draw, "%-3d ",univ.party[i].cur_sp);
win_draw_string( pc_stats_gworld,pc_buttons[i][2],to_draw,0,10); win_draw_string( pc_stats_gworld,pc_buttons[i][2],to_draw,0,style);
TEXT.colour = sf::Color::Black;
draw_pc_effects(i); draw_pc_effects(i);
break; break;
case 2: case 2:
@@ -210,7 +210,8 @@ void put_pc_screen()
break; break;
} }
if (univ.party[i].main_status != 1) if (univ.party[i].main_status != 1)
win_draw_string( pc_stats_gworld,to_draw_rect,to_draw,0,10); win_draw_string( pc_stats_gworld,to_draw_rect,to_draw,0,style);
style.colour = sf::Color::Black;
// Now put trade and info buttons // Now put trade and info buttons
//rect_draw_some_item(mixed_gworld,info_from,pc_stats_gworld,pc_buttons[i][3],1,0); //rect_draw_some_item(mixed_gworld,info_from,pc_stats_gworld,pc_buttons[i][3],1,0);
@@ -276,18 +277,19 @@ void put_item_screen(short screen_num,short suppress_buttons)
for (j = 0; j < 6; j++) for (j = 0; j < 6; j++)
item_area_button_active[i][j] = false; item_area_button_active[i][j] = false;
TextStyle style;
style.lineHeight = 10;
switch (screen_num) { switch (screen_num) {
case 6: // On special items page case 6: // On special items page
TEXT.style = sf::Text::Regular; style.font = FONT_BOLD;
TEXT.font = "Silom"; style.colour = sf::Color::White;
TEXT.colour = sf::Color::White; win_draw_string(item_stats_gworld,upper_frame_rect,"Special items:",0,style);
win_draw_string(item_stats_gworld,upper_frame_rect,"Special items:",0,10); style.colour = sf::Color::Black;
TEXT.colour = sf::Color::Black;
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
i_num = i + item_offset; i_num = i + item_offset;
if (spec_item_array[i_num] >= 0) { if (spec_item_array[i_num] >= 0) {
// 2nd condition above is quite kludgy, in case it gets here with array all 0's // 2nd condition above is quite kludgy, in case it gets here with array all 0's
win_draw_string(item_stats_gworld,item_buttons[i][0],scenario.scen_strs(60 + spec_item_array[i_num] * 2),0,10); win_draw_string(item_stats_gworld,item_buttons[i][0],scenario.scen_strs(60 + spec_item_array[i_num] * 2),0,style);
place_item_button(3,i,4,0); place_item_button(3,i,4,0);
if ((scenario.special_items[spec_item_array[i_num]] % 10 == 1) if ((scenario.special_items[spec_item_array[i_num]] % 10 == 1)
@@ -302,19 +304,19 @@ void put_item_screen(short screen_num,short suppress_buttons)
default: // on an items page default: // on an items page
pc = screen_num; pc = screen_num;
TEXT.colour = sf::Color::White; style.colour = sf::Color::White;
TEXT.style = sf::Text::Regular; style.font = FONT_PLAIN;
sout.str("");; sout.str("");;
sout << univ.party[pc].name << " inventory:", sout << univ.party[pc].name << " inventory:",
win_draw_string(item_stats_gworld,upper_frame_rect,sout.str(),0,10); win_draw_string(item_stats_gworld,upper_frame_rect,sout.str(),0,style);
TEXT.colour = sf::Color::Black; style.colour = sf::Color::Black;
TEXT.font = "Silom"; style.font = FONT_BOLD;
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
i_num = i + item_offset; i_num = i + item_offset;
sout.str(""); sout.str("");
sout << i_num + 1 << '.'; sout << i_num + 1 << '.';
win_draw_string(item_stats_gworld,item_buttons[i][0],sout.str(),0,10); win_draw_string(item_stats_gworld,item_buttons[i][0],sout.str(),0,style);
dest_rect = item_buttons[i][0]; dest_rect = item_buttons[i][0];
dest_rect.left += 36; dest_rect.left += 36;
@@ -323,15 +325,15 @@ void put_item_screen(short screen_num,short suppress_buttons)
} }
else { else {
TEXT.style = sf::Text::Regular; style.font = FONT_PLAIN;
if (univ.party[pc].equip[i_num] == true) { if (univ.party[pc].equip[i_num] == true) {
TEXT.style = sf::Text::Italic; style.italic = true;
if (univ.party[pc].items[i_num].variety < 3) if (univ.party[pc].items[i_num].variety < 3)
TEXT.colour = sf::Color::Magenta; style.colour = sf::Color::Magenta;
else if ((univ.party[pc].items[i_num].variety >= 12) && (univ.party[pc].items[i_num].variety <= 17)) else if ((univ.party[pc].items[i_num].variety >= 12) && (univ.party[pc].items[i_num].variety <= 17))
TEXT.colour = sf::Color::Green; style.colour = sf::Color::Green;
else TEXT.colour = sf::Color::Blue; else style.colour = sf::Color::Blue;
} else TEXT.colour = sf::Color::Black; } else style.colour = sf::Color::Black;
//// ////
sout.str(""); sout.str("");
@@ -344,9 +346,9 @@ void put_item_screen(short screen_num,short suppress_buttons)
sout << '(' << int(univ.party[pc].items[i_num].charges) << ')'; sout << '(' << int(univ.party[pc].items[i_num].charges) << ')';
} }
dest_rect.left -= 2; dest_rect.left -= 2;
win_draw_string(item_stats_gworld,dest_rect,sout.str(),0,10); win_draw_string(item_stats_gworld,dest_rect,sout.str(),0,style);
TEXT.style = sf::Text::Regular; style.italic = false;
TEXT.colour = sf::Color::Black; style.colour = sf::Color::Black;
// this is kludgy, awkwark, and has redundant code. Done this way to // this is kludgy, awkwark, and has redundant code. Done this way to
// make go faster, and I got lazy. // make go faster, and I got lazy.
@@ -453,10 +455,11 @@ void place_buy_button(short position,short pc_num,short item_num)
dest_rect.right = dest_rect.left + 30; dest_rect.right = dest_rect.left + 30;
rect_draw_some_item(invenbtn_gworld, source_rect, item_stats_gworld, dest_rect, sf::BlendAlpha); rect_draw_some_item(invenbtn_gworld, source_rect, item_stats_gworld, dest_rect, sf::BlendAlpha);
sprintf((char *) store_str," %d",val_to_place); sprintf((char *) store_str," %d",val_to_place);
TextStyle style;
if (val_to_place >= 10000) if (val_to_place >= 10000)
TEXT.style = sf::Text::Regular; style.font = FONT_PLAIN;
win_draw_string(item_stats_gworld,item_buttons[position][5],store_str,2,10); style.lineHeight = 10;
TEXT.style = sf::Text::Bold; win_draw_string(item_stats_gworld,item_buttons[position][5],store_str,2,style);
} }
} }
@@ -671,7 +674,8 @@ void draw_pc_effects(short pc)
dest_rect.bottom += pc * 25 + 18; dest_rect.bottom += pc * 25 + 18;
} }
else { else {
name_width = string_length(univ.party[pc].name); TextStyle style;
name_width = string_length(univ.party[pc].name, style);
right_limit = pc_buttons[0][1].left - 5; right_limit = pc_buttons[0][1].left - 5;
//dest_rect.left = pc_buttons[i][1].left - 16; //dest_rect.left = pc_buttons[i][1].left - 16;
dest_rect.left = name_width + 33; dest_rect.left = name_width + 33;
@@ -1300,7 +1304,7 @@ void print_buf ()
location moveTo; location moveTo;
while ((line_to_print!= buf_pointer) && (num_lines_printed < LINES_IN_TEXT_WIN)) { while ((line_to_print!= buf_pointer) && (num_lines_printed < LINES_IN_TEXT_WIN)) {
moveTo = location(4, 1 + 12 * num_lines_printed); moveTo = location(4, 1 + 12 * num_lines_printed);
sf::Text text(text_buffer[line_to_print].line, *ResMgr::get<FontRsrc>("Geneva"), 12); sf::Text text(text_buffer[line_to_print].line, *ResMgr::get<FontRsrc>("plain"), 12);
text.setColor(sf::Color::Black); text.setColor(sf::Color::Black);
text.setPosition(moveTo); text.setPosition(moveTo);
text_area_gworld.draw(text); text_area_gworld.draw(text);

View File

@@ -1548,9 +1548,9 @@ void draw_map(bool need_refresh) {
mini_map.setActive(); mini_map.setActive();
// Now place terrain map gworld // Now place terrain map gworld
TEXT.font = "Silom"; TextStyle style;
TEXT.pointSize = 10;; style.font = FONT_BOLD;
TEXT.style = sf::Text::Regular; style.pointSize = 10;;
the_rect = RECT(mini_map); the_rect = RECT(mini_map);
tileImage(mini_map, the_rect,bg_gworld,bg[4]); tileImage(mini_map, the_rect,bg_gworld,bg[4]);
@@ -1559,10 +1559,10 @@ void draw_map(bool need_refresh) {
theGraphic.setPict(21, PIC_DLOG); theGraphic.setPict(21, PIC_DLOG);
theGraphic.setFormat(TXT_FRAME, false); theGraphic.setFormat(TXT_FRAME, false);
theGraphic.draw(); theGraphic.draw();
TEXT.colour = sf::Color::White; style.colour = sf::Color::White;
win_draw_string(mini_map, map_title_rect,title_string,0,12); style.lineHeight = 12;
win_draw_string(mini_map, map_bar_rect,"(Hit Escape to close.)",0,12); win_draw_string(mini_map, map_title_rect,title_string,0,style);
TEXT.colour = sf::Color::Black; win_draw_string(mini_map, map_bar_rect,"(Hit Escape to close.)",0,style);
/*SetPort( mini_map); /*SetPort( mini_map);
GetDialogItem(mini_map, 1, &the_type, &the_handle, &the_rect); GetDialogItem(mini_map, 1, &the_type, &the_handle, &the_rect);
@@ -1619,8 +1619,6 @@ void draw_map(bool need_refresh) {
} }
} }
TEXT.colour = sf::Color::Black;
mini_map.display(); mini_map.display();
// Now exit gracefully // Now exit gracefully

View File

@@ -55,18 +55,15 @@ void cButton::draw(){
inWindow->setActive(); inWindow->setActive();
if(visible){ if(visible){
TEXT.font = "Geneva"; TextStyle style;
if(foundSilom()) { if(type == BTN_TINY) style.pointSize = 9;
TEXT.style = sf::Text::Regular; else if(type == BTN_PUSH) style.pointSize = 10;
TEXT.font = "Silom"; else style.pointSize = 12;
} else TEXT.style = sf::Text::Bold;
if(type == BTN_TINY) TEXT.pointSize = 9;
else if(type == BTN_PUSH) TEXT.pointSize = 10;
else TEXT.pointSize = 12;
from_rect = btnRects[type][depressed]; from_rect = btnRects[type][depressed];
to_rect = frame; to_rect = frame;
rect_draw_some_item(buttons[btnGW[type]],from_rect,*inWindow,to_rect,sf::BlendAlpha); rect_draw_some_item(buttons[btnGW[type]],from_rect,*inWindow,to_rect,sf::BlendAlpha);
TEXT.colour = sf::Color::Black; style.colour = sf::Color::Black;
style.lineHeight = 8;
int textMode = 1; int textMode = 1;
if(type == BTN_TINY) { if(type == BTN_TINY) {
textMode = 2; textMode = 2;
@@ -74,12 +71,11 @@ void cButton::draw(){
} else if(type == BTN_PUSH) { } else if(type == BTN_PUSH) {
to_rect.top += 34; to_rect.top += 34;
} }
win_draw_string(*inWindow,to_rect,lbl,textMode,8); win_draw_string(*inWindow,to_rect,lbl,textMode,style);
// TODO: Adjust string location as appropriate // TODO: Adjust string location as appropriate
// Tiny button string location should be shifted right 20 pixels (or possibly 18) // Tiny button string location should be shifted right 20 pixels (or possibly 18)
// Push button string should be centred below the button // Push button string should be centred below the button
// Others may need adjustments too, not sure // Others may need adjustments too, not sure
TEXT.colour = sf::Color::Black;
// TODO: How is it supposed to know it's a default button when this fact is stored in the dialog, not the button? // TODO: How is it supposed to know it's a default button when this fact is stored in the dialog, not the button?
if(key.spec && key.k == key_enter) drawFrame(2,frameStyle); // frame default button, to provide a visual cue that it's the default if(key.spec && key.k == key_enter) drawFrame(2,frameStyle); // frame default button, to provide a visual cue that it's the default
}else{ }else{
@@ -192,7 +188,7 @@ void cLed::init(){
cLed::cLed(cDialog* parent) : cLed::cLed(cDialog* parent) :
cButton(parent,CTRL_LED), cButton(parent,CTRL_LED),
state(led_off), state(led_off),
textFont(SILOM), textFont(FONT_BOLD),
textSize(10), textSize(10),
color(parent->defTextClr) { color(parent->defTextClr) {
setBtnType(BTN_LED); setBtnType(BTN_LED);
@@ -247,19 +243,17 @@ void cLed::draw(){
inWindow->setActive(); inWindow->setActive();
if(visible){ if(visible){
TEXT.font = "Geneva"; TextStyle style;
if(foundSilom()) TEXT.style = sf::Text::Regular; style.pointSize = 9;
else TEXT.style = sf::Text::Bold; style.lineHeight = 8;
TEXT.pointSize = 9;
from_rect = ledRects[state][depressed]; from_rect = ledRects[state][depressed];
to_rect = frame; to_rect = frame;
to_rect.right = to_rect.left + 14; to_rect.right = to_rect.left + 14;
rect_draw_some_item(buttons[btnGW[BTN_LED]],from_rect,*inWindow,to_rect); rect_draw_some_item(buttons[btnGW[BTN_LED]],from_rect,*inWindow,to_rect);
TEXT.colour = parent->defTextClr; style.colour = parent->defTextClr;
to_rect.right = frame.right; to_rect.right = frame.right;
to_rect.left = frame.left + 18; // Possibly could be 20 to_rect.left = frame.left + 18; // Possibly could be 20
win_draw_string(*inWindow,to_rect,lbl,2,8); win_draw_string(*inWindow,to_rect,lbl,2,style);
TEXT.colour = sf::Color::Black;
}else{ }else{
tileImage(*inWindow,frame,bg_gworld,bg[parent->bg]); tileImage(*inWindow,frame,bg_gworld,bg[parent->bg]);
} }

View File

@@ -15,6 +15,7 @@
#include <map> #include <map>
#include <vector> #include <vector>
#include "control.h" #include "control.h"
#include "graphtool.h" // for eFont
enum eBtnType { // w x h enum eBtnType { // w x h
BTN_SM = 0, // 23x23 (PICT id 2000 / 2001) BTN_SM = 0, // 23x23 (PICT id 2000 / 2001)
@@ -84,7 +85,7 @@ public:
void draw(); void draw();
private: private:
eLedState state; eLedState state;
eTextFont textFont; eFont textFont;
sf::Color color; sf::Color color;
short textSize; short textSize;
static RECT ledRects[3][2]; static RECT ledRects[3][2];

View File

@@ -264,19 +264,6 @@ bool cControl::triggerFocusHandler(cDialog& me __attribute__((unused)), std::str
return true; return true;
} }
std::string cControl::font_nums[4] = {"Dungeon", "Geneva", "Silom", "MaidenWord"};
void cControl::init(){
// Check if Silom is available
// TODO: Ultimately, I'd like to distribute all needed fonts with the game, rendering this unnecessary
try {
ResMgr::get<FontRsrc>("Silom");
found_silom = true;
} catch(ResMgr::xResMgrErr) {
found_silom = false;
}
}
void cControl::drawFrame(short amt, bool med_or_lt){ void cControl::drawFrame(short amt, bool med_or_lt){
// dk_gray had a 0..65535 component of 12287, and med_gray had a 0..65535 component of 24574 // dk_gray had a 0..65535 component of 12287, and med_gray had a 0..65535 component of 24574
static sf::Color lt_gray = {224,224,224},dk_gray = {48,48,48},med_gray = {96,96,96}; static sf::Color lt_gray = {224,224,224},dk_gray = {48,48,48},med_gray = {96,96,96};
@@ -295,12 +282,6 @@ void cControl::drawFrame(short amt, bool med_or_lt){
undo_clip(*inWindow); undo_clip(*inWindow);
} }
bool cControl::found_silom;
bool cControl::foundSilom(){
return found_silom;
}
cControl::~cControl() {} cControl::~cControl() {}
eControlType cControl::getType(){ eControlType cControl::getType(){

View File

@@ -43,8 +43,6 @@ enum eControlType {
CTRL_SCROLL,// A scrollbar (not implemented yet) CTRL_SCROLL,// A scrollbar (not implemented yet)
}; };
enum eTextFont {DUNGEON, GENEVA, SILOM, MAIDENWORD};
//typedef bool (*click_callback_t)(cDialog&/*me*/,std::string/*id*/, eKeyMod/*mods*/); //typedef bool (*click_callback_t)(cDialog&/*me*/,std::string/*id*/, eKeyMod/*mods*/);
//typedef bool (*focus_callback_t)(cDialog&/*me*/,std::string/*id*/,bool/*losing*/); // losing is true if losing focus, false if gaining focus. //typedef bool (*focus_callback_t)(cDialog&/*me*/,std::string/*id*/,bool/*losing*/); // losing is true if losing focus, false if gaining focus.
typedef std::function<bool(cDialog&,std::string,eKeyMod)> click_callback_t; typedef std::function<bool(cDialog&,std::string,eKeyMod)> click_callback_t;
@@ -70,7 +68,6 @@ public:
class cControl { class cControl {
public: public:
static void init();
void attachKey(cKey key); void attachKey(cKey key);
void detachKey(); void detachKey();
void setTextToKey(); void setTextToKey();
@@ -111,12 +108,9 @@ protected:
RECT frame; RECT frame;
int frameStyle; int frameStyle;
cKey key; cKey key;
static bool foundSilom();
static std::string font_nums[4];
void drawFrame(short amt, bool med_or_lt); void drawFrame(short amt, bool med_or_lt);
private: private:
eControlType type; eControlType type;
static bool found_silom;
}; };
#endif #endif

View File

@@ -225,13 +225,13 @@ template<> pair<string,cTextMsg*> cDialog::parse(Element& who /*text*/){
std::string val; std::string val;
attr->GetValue(&val); attr->GetValue(&val);
if(val == "dungeon") if(val == "dungeon")
p.second->setFormat(TXT_FONT, DUNGEON); p.second->setFormat(TXT_FONT, FONT_DUNGEON);
else if(val == "geneva") else if(val == "plain")
p.second->setFormat(TXT_FONT, GENEVA); p.second->setFormat(TXT_FONT, FONT_PLAIN);
else if(val == "silom") else if(val == "bold")
p.second->setFormat(TXT_FONT, SILOM); p.second->setFormat(TXT_FONT, FONT_BOLD);
else if(val == "maidenword") else if(val == "maidenword")
p.second->setFormat(TXT_FONT, MAIDENWORD); p.second->setFormat(TXT_FONT, FONT_MAIDWORD);
else throw xBadVal("text",name,val,attr->Row(),attr->Column(),fname); else throw xBadVal("text",name,val,attr->Row(),attr->Column(),fname);
}else if(name == "size"){ }else if(name == "size"){
std::string val; std::string val;
@@ -584,13 +584,13 @@ template<> pair<string,cLed*> cDialog::parse(Element& who /*LED*/){
std::string val; std::string val;
attr->GetValue(&val); attr->GetValue(&val);
if(val == "dungeon") if(val == "dungeon")
p.second->setFormat(TXT_FONT, DUNGEON); p.second->setFormat(TXT_FONT, FONT_DUNGEON);
else if(val == "geneva") else if(val == "plain")
p.second->setFormat(TXT_FONT, GENEVA); p.second->setFormat(TXT_FONT, FONT_PLAIN);
else if(val == "silom") else if(val == "bold")
p.second->setFormat(TXT_FONT, SILOM); p.second->setFormat(TXT_FONT, FONT_BOLD);
else if(val == "maidenword") else if(val == "maidenword")
p.second->setFormat(TXT_FONT, MAIDENWORD); p.second->setFormat(TXT_FONT, FONT_MAIDWORD);
else throw xBadVal("text",name,val,attr->Row(),attr->Column(),fname); else throw xBadVal("text",name,val,attr->Row(),attr->Column(),fname);
}else if(name == "size"){ }else if(name == "size"){
std::string val; std::string val;
@@ -857,7 +857,6 @@ void cDialog::recalcRect(){
} }
void cDialog::init(){ void cDialog::init(){
cControl::init();
cButton::init(); cButton::init();
cLed::init(); cLed::init();
cPict::init(); cPict::init();
@@ -1145,7 +1144,7 @@ bool cDialog::addLabelFor(std::string key, std::string label, eLabelPos where, s
labelCtrl = new cTextMsg(*this); labelCtrl = new cTextMsg(*this);
} }
labelCtrl->setText(label); labelCtrl->setText(label);
labelCtrl->setFormat(TXT_FONT, bold ? SILOM : GENEVA); labelCtrl->setFormat(TXT_FONT, bold ? FONT_BOLD : FONT_PLAIN);
if(bg == BG_DARK && dynamic_cast<cButton*>(&ctrl) != NULL) if(bg == BG_DARK && dynamic_cast<cButton*>(&ctrl) != NULL)
labelCtrl->setColour(defTextClr); labelCtrl->setColour(defTextClr);
else labelCtrl->setColour(ctrl.getColour()); else labelCtrl->setColour(ctrl.getColour());

View File

@@ -265,10 +265,11 @@ cThreeChoice::cThreeChoice
} }
void cThreeChoice::init_strings(std::vector<std::string>& strings, unsigned short left){ void cThreeChoice::init_strings(std::vector<std::string>& strings, unsigned short left){
TextStyle style;
RECT cur_text_rect = {2, left, 0, 0}; RECT cur_text_rect = {2, left, 0, 0};
size_t total_len, str_width, str_height; size_t total_len, str_width, str_height;
for (unsigned int i = 0; i < strings.size(); i++) for (unsigned int i = 0; i < strings.size(); i++)
total_len += string_length(strings[i]); total_len += string_length(strings[i], style);
total_len = total_len * 12; total_len = total_len * 12;
str_width = s_sqrt(total_len) + 20; str_width = s_sqrt(total_len) + 20;
//print_nums(0,total_len,str_width); //print_nums(0,total_len,str_width);
@@ -279,7 +280,7 @@ void cThreeChoice::init_strings(std::vector<std::string>& strings, unsigned shor
for(unsigned int j = 0; j < strings.size(); j++){ for(unsigned int j = 0; j < strings.size(); j++){
std::ostringstream sout; std::ostringstream sout;
sout << "str" << j + 1; sout << "str" << j + 1;
str_height = ((string_length(strings[j]) + 60) / str_width) * 12 + 16; str_height = ((string_length(strings[j], style) + 60) / str_width) * 12 + 16;
cur_text_rect.bottom = cur_text_rect.top + str_height; cur_text_rect.bottom = cur_text_rect.top + str_height;
cTextMsg* str = new cTextMsg(*me); cTextMsg* str = new cTextMsg(*me);
str->setText(strings[j]); str->setText(strings[j]);

View File

@@ -88,19 +88,20 @@ void cTextField::draw(){
std::string contents = getText(); std::string contents = getText();
RECT rect = frame; RECT rect = frame;
rect.inset(2,6); rect.inset(2,6);
TEXT.font = "Geneva"; TextStyle style;
TEXT.style = sf::Text::Regular; style.font = FONT_PLAIN;
TEXT.pointSize = 12; style.pointSize = 12;
TEXT.colour = sf::Color::Black; style.colour = sf::Color::Black;
style.lineHeight = 14;
// TODO: Proper support for multiline fields // TODO: Proper support for multiline fields
int ip_offset, sel_offset; int ip_offset, sel_offset;
if(haveFocus) { if(haveFocus) {
std::string pre_ip = contents.substr(0, insertionPoint); std::string pre_ip = contents.substr(0, insertionPoint);
// TODO: Update string_length to take a std::string // TODO: Update string_length to take a std::string
ip_offset = string_length(pre_ip); ip_offset = string_length(pre_ip, style);
if(insertionPoint != selectionPoint) { if(insertionPoint != selectionPoint) {
std::string pre_sel = contents.substr(0, selectionPoint); std::string pre_sel = contents.substr(0, selectionPoint);
sel_offset = string_length(pre_sel); sel_offset = string_length(pre_sel, style);
int sel_start = std::min(ip_offset, sel_offset) + 1; int sel_start = std::min(ip_offset, sel_offset) + 1;
int sel_width = abs(ip_offset - sel_offset) + 3; int sel_width = abs(ip_offset - sel_offset) + 3;
RECT selectRect = frame; RECT selectRect = frame;
@@ -122,7 +123,7 @@ void cTextField::draw(){
} }
} }
// TODO: Update win_draw_string to take a std::string // TODO: Update win_draw_string to take a std::string
win_draw_string(*inWindow, rect, contents, 0, 14); win_draw_string(*inWindow, rect, contents, 0, style);
} }
void cTextField::handleInput(cKey key) { void cTextField::handleInput(cKey key) {

View File

@@ -43,10 +43,10 @@ void cTextMsg::setFormat(eFormat prop, short val) throw(xUnsupportedProp){
textSize = val; textSize = val;
break; break;
case TXT_FONT: case TXT_FONT:
if(val == DUNGEON) textFont = DUNGEON; if(val == FONT_DUNGEON) textFont = FONT_DUNGEON;
else if(val == GENEVA) textFont = GENEVA; else if(val == FONT_PLAIN) textFont = FONT_PLAIN;
else if(val == MAIDENWORD) textFont = MAIDENWORD; else if(val == FONT_MAIDWORD) textFont = FONT_MAIDWORD;
else textFont = SILOM; // Defaults to Silom if an invalid value is provided. else textFont = FONT_BOLD; // Defaults to bold if an invalid value is provided.
break; break;
case TXT_WRAP: case TXT_WRAP:
throw xUnsupportedProp(prop); throw xUnsupportedProp(prop);
@@ -76,7 +76,7 @@ short cTextMsg::getFormat(eFormat prop) throw(xUnsupportedProp){
cTextMsg::cTextMsg(cDialog& parent) : cTextMsg::cTextMsg(cDialog& parent) :
cControl(CTRL_TEXT,parent), cControl(CTRL_TEXT,parent),
drawFramed(false), drawFramed(false),
textFont(SILOM), textFont(FONT_BOLD),
textSize(10), textSize(10),
color(parent.defTextClr), color(parent.defTextClr),
clickable(false), clickable(false),
@@ -85,7 +85,7 @@ cTextMsg::cTextMsg(cDialog& parent) :
cTextMsg::cTextMsg(sf::RenderWindow& parent) : cTextMsg::cTextMsg(sf::RenderWindow& parent) :
cControl(CTRL_TEXT,parent), cControl(CTRL_TEXT,parent),
drawFramed(false), drawFramed(false),
textFont(SILOM), textFont(FONT_BOLD),
textSize(10), textSize(10),
color(cDialog::defaultBackground == cDialog::BG_DARK ? sf::Color::White : sf::Color::Black), color(cDialog::defaultBackground == cDialog::BG_DARK ? sf::Color::White : sf::Color::Black),
clickable(false), clickable(false),
@@ -101,10 +101,9 @@ void cTextMsg::draw(){
inWindow->setActive(); inWindow->setActive();
if(visible){ if(visible){
TEXT.font = font_nums[textFont]; TextStyle style;
if(textFont == SILOM && !foundSilom()) TEXT.style = sf::Text::Bold; style.font = textFont;
else TEXT.style = sf::Text::Regular; style.pointSize = textSize;
TEXT.pointSize = textSize;
if(drawFramed) drawFrame(2,frameStyle); if(drawFramed) drawFrame(2,frameStyle);
sf::Color draw_color = color; sf::Color draw_color = color;
if(clickable && depressed){ if(clickable && depressed){
@@ -112,13 +111,15 @@ void cTextMsg::draw(){
draw_color.g = 256 - draw_color.g; draw_color.g = 256 - draw_color.g;
draw_color.b = 256 - draw_color.b; draw_color.b = 256 - draw_color.b;
} }
TEXT.colour = draw_color; style.colour = draw_color;
if (to_rect.bottom - to_rect.top < 20) { // essentially, it's a single line if (to_rect.bottom - to_rect.top < 20) { // essentially, it's a single line
style.lineHeight = 12;
to_rect.left += 3; to_rect.left += 3;
win_draw_string(*inWindow,to_rect,lbl,3,12); win_draw_string(*inWindow,to_rect,lbl,3,style);
}else { }else {
style.lineHeight = textSize + 2;
to_rect.inset(4,4); to_rect.inset(4,4);
win_draw_string(*inWindow,to_rect,lbl,0,textSize + 2); win_draw_string(*inWindow,to_rect,lbl,0,style);
} }
} }
} }

View File

@@ -13,6 +13,7 @@
#include <string> #include <string>
#include "control.h" #include "control.h"
#include "graphtool.h" // for eFont
class cTextMsg : public cControl { class cTextMsg : public cControl {
public: public:
@@ -31,7 +32,7 @@ public:
private: private:
bool drawFramed, clickable; bool drawFramed, clickable;
short textSize; short textSize;
eTextFont textFont; eFont textFont;
sf::Color color; sf::Color color;
std::string fromList; std::string fromList;
click_callback_t onClick; click_callback_t onClick;

View File

@@ -59,7 +59,6 @@ short store_page_on,store_num_i;
// TODO: The duplication of RECT here shouldn't be necessary... // TODO: The duplication of RECT here shouldn't be necessary...
RECT ed_buttons_from[2] = {RECT{0,0,57,57},RECT{0,57,57,114}}; RECT ed_buttons_from[2] = {RECT{0,0,57,57},RECT{0,57,57,114}};
short current_pressed_button = -1; short current_pressed_button = -1;
bool init_once = false;
sf::Texture spec_scen_g; // not actually needed; just here to silence compiler because it's reference in fileio.h sf::Texture spec_scen_g; // not actually needed; just here to silence compiler because it's reference in fileio.h
// (actually, it WILL be needed eventually; the same is true about most of the rest of these.) // (actually, it WILL be needed eventually; the same is true about most of the rest of these.)
sf::Texture items_gworld,tiny_obj_gworld,fields_gworld,roads_gworld,boom_gworld,missiles_gworld; sf::Texture items_gworld,tiny_obj_gworld,fields_gworld,roads_gworld,boom_gworld,missiles_gworld;
@@ -74,12 +73,6 @@ void init_main_buttons()
RECT base_rect; RECT base_rect;
if (init_once == false) {
init_once = true;
TEXT.font = "Silom";
TEXT.style = sf::Text::Regular;
TEXT.pointSize = 10;
}
//whole_win_rect = mainPtr->portRect; //whole_win_rect = mainPtr->portRect;
//Initialize pc_info_rect in center //Initialize pc_info_rect in center
pc_info_rect= whole_win_rect; pc_info_rect= whole_win_rect;
@@ -282,16 +275,17 @@ void draw_main_screen()
dest_rect.top = dest_rect.bottom; dest_rect.top = dest_rect.bottom;
dest_rect.bottom = dest_rect.top + 50; dest_rect.bottom = dest_rect.top + 50;
// initialize rectangle to draw text into // initialize rectangle to draw text into
TextStyle style;
style.lineHeight = 10;
// TODO: Is this needed? // TODO: Is this needed?
#if 0 #if 0
TEXT.pointSize = 12; style.pointSize = 12;
TEXT.style = sf::Text::Underlined; style.underline = true;
// set the pen // set the pen
win_draw_string(mainPtr,dest_rect,"Characters",0,10); win_draw_string(mainPtr,dest_rect,"Characters",0,style);
// This draws a chunk of text on the screen // This draws a chunk of text on the screen
#endif #endif
TEXT.pointSize = 10; style.pointSize = 10;
TEXT.style = sf::Text::Regular;
frame_dlog_rect(mainPtr,pc_info_rect); // draw the frame frame_dlog_rect(mainPtr,pc_info_rect); // draw the frame
//i = pc_info_rect.left-pc_info_rect.right; //i = pc_info_rect.left-pc_info_rect.right;
@@ -299,33 +293,33 @@ void draw_main_screen()
//(short) i); //(short) i);
//win_draw_string(mainPtr,pc_info_rect,temp_str,0,12); //win_draw_string(mainPtr,pc_info_rect,temp_str,0,12);
TEXT.colour = sf::Color::Black; style.colour = sf::Color::Black;
dest_rect = pc_area_buttons[5][0]; dest_rect = pc_area_buttons[5][0];
dest_rect.right = whole_win_rect.right - 30; //What is this for? Commenting it out has no effect. dest_rect.right = whole_win_rect.right - 30; //What is this for? Commenting it out has no effect.
dest_rect.left += 60; dest_rect.left += 60;
//Off0setRect(&dest_rect,0,45); //Off0setRect(&dest_rect,0,45);
dest_rect.offset(0,21); dest_rect.offset(0,21);
if(!file_in_mem.empty()) if(!file_in_mem.empty())
win_draw_string(mainPtr,dest_rect,"Click on character to edit it.",0,10); win_draw_string(mainPtr,dest_rect,"Click on character to edit it.",0,style);
else else
win_draw_string(mainPtr,dest_rect,"Select Open from File menu.",0,10); win_draw_string(mainPtr,dest_rect,"Select Open from File menu.",0,style);
if(!file_in_mem.empty() && party_in_scen && !scen_items_loaded){ if(!file_in_mem.empty() && party_in_scen && !scen_items_loaded){
dest_rect.offset(200,0); dest_rect.offset(200,0);
win_draw_string(mainPtr,dest_rect,"Warning: Scenario item data could not be loaded.",0,10); win_draw_string(mainPtr,dest_rect,"Warning: Scenario item data could not be loaded.",0,style);
dest_rect.offset(-200,0); dest_rect.offset(-200,0);
} }
dest_rect.offset(0,12); dest_rect.offset(0,12);
if(!file_in_mem.empty()) if(!file_in_mem.empty())
win_draw_string(mainPtr,dest_rect,"Press 'I' button to identify item, and 'D' button to drop item.",0,10); win_draw_string(mainPtr,dest_rect,"Press 'I' button to identify item, and 'D' button to drop item.",0,style);
TEXT.pointSize = 12; style.pointSize = 12;
dest_rect.offset(0,16); dest_rect.offset(0,16);
if(!file_in_mem.empty()) if(!file_in_mem.empty())
win_draw_string(mainPtr,dest_rect,"Back up save file before editing it!",0,10); win_draw_string(mainPtr,dest_rect,"Back up save file before editing it!",0,style);
TEXT.pointSize = 10; style.pointSize = 10;
TEXT.font = "Geneva"; style.font = FONT_PLAIN;
dest_rect.offset(280,0); dest_rect.offset(280,0);
win_draw_string(mainPtr,dest_rect,"Created in 1997 by Spiderweb Software, Inc.",0,10); win_draw_string(mainPtr,dest_rect,"Created in 1997 by Spiderweb Software, Inc.",0,style);
TEXT.font = "Silom";
reg_rect = whole_win_rect; reg_rect = whole_win_rect;
reg_rect.left = reg_rect.right - 170; reg_rect.left = reg_rect.right - 170;
@@ -392,7 +386,9 @@ void draw_items()
// else sprintf((char *) to_draw, "%d %d %d %d", // else sprintf((char *) to_draw, "%d %d %d %d",
// name_rect.left,name_rect.right,name_rect.top,name_rect.bottom); // name_rect.left,name_rect.right,name_rect.top,name_rect.bottom);
win_draw_string(mainPtr,item_string_rects[i][0],(char *) to_draw,0,10); TextStyle style;
style.lineHeight = 10;
win_draw_string(mainPtr,item_string_rects[i][0],(char *) to_draw,0,style);
//Draw id/drop buttons //Draw id/drop buttons
rect_draw_some_item(invenbtn_gworld,d_from,mainPtr,item_string_rects[i][1],sf::BlendAlpha); rect_draw_some_item(invenbtn_gworld,d_from,mainPtr,item_string_rects[i][1],sf::BlendAlpha);
@@ -413,29 +409,31 @@ void display_party()
char to_draw[256], skill_value[256]; char to_draw[256], skill_value[256];
RECT from_base = {0,0,36,28},from_rect,no_party_rect,temp_rect; RECT from_base = {0,0,36,28},from_rect,no_party_rect,temp_rect;
TextStyle style;
style.lineHeight = 10;
if(file_in_mem.empty()) { // what if no party loaded? if(file_in_mem.empty()) { // what if no party loaded?
no_party_rect=pc_info_rect; no_party_rect=pc_info_rect;
no_party_rect.top+=5; no_party_rect.top+=5;
no_party_rect.left+=5; no_party_rect.left+=5;
win_draw_string(mainPtr,no_party_rect,"No party loaded.",0,10); win_draw_string(mainPtr,no_party_rect,"No party loaded.",0,style);
} }
else { else {
from_rect = pc_info_rect; from_rect = pc_info_rect;
from_rect.top = from_rect.bottom - 14; from_rect.top = from_rect.bottom - 14;
if (party_in_scen == false) if (party_in_scen == false)
win_draw_string(mainPtr,from_rect,"Party not in a scenario.",0,10); win_draw_string(mainPtr,from_rect,"Party not in a scenario.",0,style);
else else
win_draw_string(mainPtr,from_rect,"Party is in a scenario.",0,10); win_draw_string(mainPtr,from_rect,"Party is in a scenario.",0,style);
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
// TODO: This appears to be expecting a tint? // TODO: This appears to be expecting a tint?
if (i == current_active_pc) // active pc is drawn in blue if (i == current_active_pc) // active pc is drawn in blue
TEXT.colour = sf::Color::Blue; style.colour = sf::Color::Blue;
else TEXT.colour = sf::Color::Black; else style.colour = sf::Color::Black;
from_rect = (current_pressed_button == i) ? ed_buttons_from[1] : ed_buttons_from[0]; from_rect = (current_pressed_button == i) ? ed_buttons_from[1] : ed_buttons_from[0];
rect_draw_some_item(buttons_gworld,from_rect,mainPtr,pc_area_buttons[i][0]); rect_draw_some_item(buttons_gworld,from_rect,mainPtr,pc_area_buttons[i][0]);
TEXT.colour = sf::Color::Black; style.colour = sf::Color::Black;
// pc_record_type is the records that contains chaarcters // pc_record_type is the records that contains chaarcters
// main_status determins 0 - not exist, 1 - alive, OK, 2 - dead, 3 - stoned, 4 - dust // main_status determins 0 - not exist, 1 - alive, OK, 2 - dead, 3 - stoned, 4 - dust
@@ -447,28 +445,28 @@ void display_party()
//frame_dlog_rect(GetWindowPort(mainPtr),pc_area_buttons[i][1],0); //frame_dlog_rect(GetWindowPort(mainPtr),pc_area_buttons[i][1],0);
// draw name // draw name
TEXT.pointSize = 9; style.pointSize = 9;
if( (univ.party[i].name.length()) >= 10) { if( (univ.party[i].name.length()) >= 10) {
TEXT.font = "Geneva"; style.font = FONT_PLAIN;
TEXT.pointSize = 6; style.pointSize = 6;
sprintf((char *) to_draw, "%-s ", (char *) univ.party[i].name.c_str()); sprintf((char *) to_draw, "%-s ", (char *) univ.party[i].name.c_str());
} }
else { else {
sprintf((char *) to_draw, "%-s ", (char *) univ.party[i].name.c_str()); sprintf((char *) to_draw, "%-s ", (char *) univ.party[i].name.c_str());
} }
TEXT.colour = sf::Color::White; style.colour = sf::Color::White;
win_draw_string(mainPtr,pc_area_buttons[i][2],to_draw,1,10); win_draw_string(mainPtr,pc_area_buttons[i][2],to_draw,1,style);
TEXT.font = "Silom"; style.font = FONT_BOLD;
TEXT.pointSize = 10; style.pointSize = 10;
if (i == current_active_pc){ if (i == current_active_pc){
sprintf((char *) to_draw, "%-.18s ", (char *) univ.party[i].name.c_str()); sprintf((char *) to_draw, "%-.18s ", (char *) univ.party[i].name.c_str());
if( (univ.party[i].name.length()) > 12) if( (univ.party[i].name.length()) > 12)
TEXT.pointSize = 8; style.pointSize = 8;
TEXT.colour = sf::Color::Black; style.colour = sf::Color::Black;
win_draw_string(mainPtr,name_rect,to_draw,1,10); win_draw_string(mainPtr,name_rect,to_draw,1,style);
TEXT.pointSize = 10; style.pointSize = 10;
} }
switch (univ.party[i].main_status) { switch (univ.party[i].main_status) {
@@ -477,277 +475,281 @@ void display_party()
if (i == current_active_pc) { if (i == current_active_pc) {
//Draw in race //Draw in race
if (univ.party[i].race == 0) if (univ.party[i].race == 0)
win_draw_string(mainPtr,pc_race_rect,"Human ",1,10); win_draw_string(mainPtr,pc_race_rect,"Human ",1,style);
if (univ.party[i].race == 1) if (univ.party[i].race == 1)
win_draw_string(mainPtr,pc_race_rect,"Nephilim ",1,10); win_draw_string(mainPtr,pc_race_rect,"Nephilim ",1,style);
if (univ.party[i].race == 2) if (univ.party[i].race == 2)
win_draw_string(mainPtr,pc_race_rect,"Slithzerikai ",1,10); win_draw_string(mainPtr,pc_race_rect,"Slithzerikai ",1,style);
// Draw in skills // Draw in skills
sprintf((char *) to_draw, "Skills:"); sprintf((char *) to_draw, "Skills:");
win_draw_string(mainPtr,skill_rect,to_draw,0,10); win_draw_string(mainPtr,skill_rect,to_draw,0,style);
sprintf((char *) to_draw, "Hp: %d/%d Sp: %d/%d",univ.party[i].cur_health,univ.party[i].max_health,univ.party[i].cur_sp, sprintf((char *) to_draw, "Hp: %d/%d Sp: %d/%d",univ.party[i].cur_health,univ.party[i].max_health,univ.party[i].cur_sp,
univ.party[i].max_sp); univ.party[i].max_sp);
win_draw_string(mainPtr,hp_sp_rect,to_draw,0,10); win_draw_string(mainPtr,hp_sp_rect,to_draw,0,style);
TEXT.pointSize = 9; style.pointSize = 9;
TEXT.font = "Geneva"; style.font = FONT_PLAIN;
style.lineHeight = 9;
string_num=1; string_num=1;
for( k = 0; k < 19 ; ++k) for( k = 0; k < 19 ; ++k)
{ {
temp_rect = pc_skills_rect[k]; temp_rect = pc_skills_rect[k];
temp_rect.left = pc_skills_rect[k].left + 80; temp_rect.left = pc_skills_rect[k].left + 80;
win_draw_string(mainPtr,pc_skills_rect[k],get_str("skills",string_num),0,9); win_draw_string(mainPtr,pc_skills_rect[k],get_str("skills",string_num),0,style);
sprintf((char *) skill_value,"%d",univ.party[i].skills[k]); sprintf((char *) skill_value,"%d",univ.party[i].skills[k]);
win_draw_string(mainPtr,temp_rect,skill_value,0,9); win_draw_string(mainPtr,temp_rect,skill_value,0,style);
//frame_dlog_rect(GetWindowPort(mainPtr),pc_skills_rect[k],0); //frame_dlog_rect(GetWindowPort(mainPtr),pc_skills_rect[k],0);
string_num+=2; string_num+=2;
} }
style.lineHeight = 10;
//end skills //end skills
//Write in pc Status //Write in pc Status
TEXT.pointSize = 10; style.pointSize = 10;
TEXT.font = "Silom"; style.font = FONT_BOLD;
sprintf((char *) to_draw, "Status:"); sprintf((char *) to_draw, "Status:");
win_draw_string(mainPtr,status_rect,to_draw,0,10); win_draw_string(mainPtr,status_rect,to_draw,0,style);
TEXT.pointSize = 9;
TEXT.font = "Geneva";
style.pointSize = 9;
style.font = FONT_PLAIN;
style.lineHeight = 9;
//for(k = 0 ; k < 10; k++) //for(k = 0 ; k < 10; k++)
//frame_dlog_rect(GetWindowPort(mainPtr),pc_status_rect[k],0); //frame_dlog_rect(GetWindowPort(mainPtr),pc_status_rect[k],0);
if (univ.party[i].status[0] > 0) if (univ.party[i].status[0] > 0)
if(cur_rect <= 9) { if(cur_rect <= 9) {
win_draw_string(mainPtr,pc_status_rect[cur_rect],"Poisoned Weap.",0,9); win_draw_string(mainPtr,pc_status_rect[cur_rect],"Poisoned Weap.",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].status[1] > 0) if (univ.party[i].status[1] > 0)
if(cur_rect <= 9) { if(cur_rect <= 9) {
win_draw_string(mainPtr,pc_status_rect[cur_rect],"Blessed",0,9); win_draw_string(mainPtr,pc_status_rect[cur_rect],"Blessed",0,style);
cur_rect++; cur_rect++;
} }
else if(univ.party[i].status[1] < 0) else if(univ.party[i].status[1] < 0)
if(cur_rect <= 9) { if(cur_rect <= 9) {
win_draw_string(mainPtr,pc_status_rect[cur_rect],"Cursed",0,9); win_draw_string(mainPtr,pc_status_rect[cur_rect],"Cursed",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].status[2] > 0) if (univ.party[i].status[2] > 0)
if(cur_rect <= 9) { if(cur_rect <= 9) {
win_draw_string(mainPtr,pc_status_rect[cur_rect],"Poisoned",0,9); win_draw_string(mainPtr,pc_status_rect[cur_rect],"Poisoned",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].status[3] > 0) if (univ.party[i].status[3] > 0)
if(cur_rect <= 9) { if(cur_rect <= 9) {
win_draw_string(mainPtr,pc_status_rect[cur_rect],"Hasted",0,9); win_draw_string(mainPtr,pc_status_rect[cur_rect],"Hasted",0,style);
cur_rect++; cur_rect++;
} }
else if(univ.party[i].status[3] < 0) else if(univ.party[i].status[3] < 0)
if(cur_rect <= 9) { if(cur_rect <= 9) {
win_draw_string(mainPtr,pc_status_rect[cur_rect],"Slowed",0,9); win_draw_string(mainPtr,pc_status_rect[cur_rect],"Slowed",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].status[4] > 0) if (univ.party[i].status[4] > 0)
if(cur_rect <= 9) { if(cur_rect <= 9) {
win_draw_string(mainPtr,pc_status_rect[cur_rect],"Invulnerable",0,9); win_draw_string(mainPtr,pc_status_rect[cur_rect],"Invulnerable",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].status[5] > 0) if (univ.party[i].status[5] > 0)
if(cur_rect <= 9) { if(cur_rect <= 9) {
win_draw_string(mainPtr,pc_status_rect[cur_rect],"Magic Resistant",0,9); win_draw_string(mainPtr,pc_status_rect[cur_rect],"Magic Resistant",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].status[6] > 0) if (univ.party[i].status[6] > 0)
if(cur_rect <= 9) { if(cur_rect <= 9) {
win_draw_string(mainPtr,pc_status_rect[cur_rect],"Webbed",0,9); win_draw_string(mainPtr,pc_status_rect[cur_rect],"Webbed",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].status[7] > 0) if (univ.party[i].status[7] > 0)
if(cur_rect <= 9) { if(cur_rect <= 9) {
win_draw_string(mainPtr,pc_status_rect[cur_rect],"Diseased",0,9); win_draw_string(mainPtr,pc_status_rect[cur_rect],"Diseased",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].status[8] > 0) if (univ.party[i].status[8] > 0)
if(cur_rect <= 9) { if(cur_rect <= 9) {
win_draw_string(mainPtr,pc_status_rect[cur_rect],"Sanctury",0,9); win_draw_string(mainPtr,pc_status_rect[cur_rect],"Sanctury",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].status[9] > 0) if (univ.party[i].status[9] > 0)
if(cur_rect <= 9) { if(cur_rect <= 9) {
win_draw_string(mainPtr,pc_status_rect[cur_rect],"Dumbfounded",0,9); win_draw_string(mainPtr,pc_status_rect[cur_rect],"Dumbfounded",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].status[10] > 0) if (univ.party[i].status[10] > 0)
if(cur_rect <= 9) { if(cur_rect <= 9) {
win_draw_string(mainPtr,pc_status_rect[cur_rect],"Martyr's Shield",0,9); win_draw_string(mainPtr,pc_status_rect[cur_rect],"Martyr's Shield",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].status[11] > 0) if (univ.party[i].status[11] > 0)
if(cur_rect <= 9) { if(cur_rect <= 9) {
win_draw_string(mainPtr,pc_status_rect[cur_rect],"Asleep",0,9); win_draw_string(mainPtr,pc_status_rect[cur_rect],"Asleep",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].status[12] > 0) if (univ.party[i].status[12] > 0)
if(cur_rect <= 9) { if(cur_rect <= 9) {
win_draw_string(mainPtr,pc_status_rect[cur_rect],"Paralyzed",0,9); win_draw_string(mainPtr,pc_status_rect[cur_rect],"Paralyzed",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].status[13] > 0) if (univ.party[i].status[13] > 0)
if(cur_rect <= 9) { if(cur_rect <= 9) {
win_draw_string(mainPtr,pc_status_rect[cur_rect],"Acid",0,9); win_draw_string(mainPtr,pc_status_rect[cur_rect],"Acid",0,style);
cur_rect++; cur_rect++;
} }
style.lineHeight = 10;
//end pc status section //end pc status section
//Write in Traits //Write in Traits
TEXT.pointSize = 10; style.pointSize = 10;
TEXT.font = "Silom"; style.font = FONT_BOLD;
sprintf((char *) to_draw, "Traits:"); sprintf((char *) to_draw, "Traits:");
win_draw_string(mainPtr,traits_rect,to_draw,0,10); win_draw_string(mainPtr,traits_rect,to_draw,0,style);
//for(k = 0 ; k < 16; k++) //for(k = 0 ; k < 16; k++)
//frame_dlog_rect(GetWindowPort(mainPtr),pc_traits_rect[k],0); //frame_dlog_rect(GetWindowPort(mainPtr),pc_traits_rect[k],0);
TEXT.pointSize = 9; style.pointSize = 9;
TEXT.font = "Geneva"; style.font = FONT_PLAIN;
style.lineHeight = 9;
cur_rect=0; cur_rect=0;
if (univ.party[i].traits[0] == 1) if (univ.party[i].traits[0] == 1)
if(cur_rect <= 15) { if(cur_rect <= 15) {
win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Toughness",0,9); win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Toughness",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].traits[1] == 1) if (univ.party[i].traits[1] == 1)
if(cur_rect <= 15) { if(cur_rect <= 15) {
win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Magically Apt",0,9); win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Magically Apt",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].traits[2] == 1) if (univ.party[i].traits[2] == 1)
if(cur_rect <= 15) { if(cur_rect <= 15) {
win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Ambidextrous",0,9); win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Ambidextrous",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].traits[3] == 1) if (univ.party[i].traits[3] == 1)
if(cur_rect <= 15) { if(cur_rect <= 15) {
win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Nimble Fingers",0,9); win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Nimble Fingers",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].traits[4] == 1) if (univ.party[i].traits[4] == 1)
if(cur_rect <= 15) { if(cur_rect <= 15) {
win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Cave Lore",0,9); win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Cave Lore",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].traits[5] == 1) if (univ.party[i].traits[5] == 1)
if(cur_rect <= 15) { if(cur_rect <= 15) {
win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Woodsman",0,9); win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Woodsman",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].traits[6] == 1) if (univ.party[i].traits[6] == 1)
if(cur_rect <= 15) { if(cur_rect <= 15) {
win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Good Constitution",0,9); win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Good Constitution",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].traits[7] == 1) if (univ.party[i].traits[7] == 1)
if(cur_rect <= 15) { if(cur_rect <= 15) {
win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Highly Alert",0,9); win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Highly Alert",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].traits[8] == 1) if (univ.party[i].traits[8] == 1)
if(cur_rect <= 15) { if(cur_rect <= 15) {
win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Exceptional Str.",0,9); win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Exceptional Str.",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].traits[9] == 1) if (univ.party[i].traits[9] == 1)
if(cur_rect <= 15) { if(cur_rect <= 15) {
win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Recuperation",0,9); win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Recuperation",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].traits[10] == 1) if (univ.party[i].traits[10] == 1)
if(cur_rect <= 15) { if(cur_rect <= 15) {
win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Sluggish",0,9); win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Sluggish",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].traits[11] == 1) if (univ.party[i].traits[11] == 1)
if(cur_rect <= 15) { if(cur_rect <= 15) {
win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Magically Inept",0,9); win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Magically Inept",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].traits[12] == 1) if (univ.party[i].traits[12] == 1)
if(cur_rect <= 15) { if(cur_rect <= 15) {
win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Frail",0,9); win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Frail",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].traits[13] == 1) if (univ.party[i].traits[13] == 1)
if(cur_rect <= 15) { if(cur_rect <= 15) {
win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Chronic Disease",0,9); win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Chronic Disease",0,style);
cur_rect++; cur_rect++;
} }
if (univ.party[i].traits[14] == 1) if (univ.party[i].traits[14] == 1)
if(cur_rect <= 15) { if(cur_rect <= 15) {
win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Bad Back",0,9); win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Bad Back",0,style);
cur_rect++; cur_rect++;
} }
style.lineHeight = 10;
//end traits //end traits
} }
TEXT.colour = sf::Color::White; style.colour = sf::Color::White;
TEXT.pointSize = 9; style.pointSize = 9;
TEXT.font = "Geneva"; style.font = FONT_PLAIN;
win_draw_string(mainPtr,pc_area_buttons[i][3],"Alive ",1,10); win_draw_string(mainPtr,pc_area_buttons[i][3],"Alive ",1,style);
TEXT.font = "Silom"; style.font = FONT_BOLD;
TEXT.pointSize = 10; style.pointSize = 10;
break; break;
case 2: case 2:
TEXT.colour = sf::Color::White; style.colour = sf::Color::White;
TEXT.pointSize = 9; style.pointSize = 9;
TEXT.font = "Geneva"; style.font = FONT_PLAIN;
win_draw_string(mainPtr,pc_area_buttons[i][3],"Dead ",1,10); win_draw_string(mainPtr,pc_area_buttons[i][3],"Dead ",1,style);
TEXT.font = "Silom"; style.font = FONT_BOLD;
TEXT.pointSize = 10; style.pointSize = 10;
break; break;
case 3: case 3:
TEXT.colour = sf::Color::White; style.colour = sf::Color::White;
TEXT.pointSize = 9; style.pointSize = 9;
TEXT.font = "Geneva"; style.font = FONT_PLAIN;
win_draw_string(mainPtr,pc_area_buttons[i][3],"Dust ",1,10); win_draw_string(mainPtr,pc_area_buttons[i][3],"Dust ",1,style);
TEXT.font = "Silom"; style.font = FONT_BOLD;
TEXT.pointSize = 10; style.pointSize = 10;
break; break;
case 4: case 4:
TEXT.colour = sf::Color::White; style.colour = sf::Color::White;
TEXT.pointSize = 9; style.pointSize = 9;
TEXT.font = "Geneva"; style.font = FONT_PLAIN;
win_draw_string(mainPtr,pc_area_buttons[i][3],"Stone ",1,10); win_draw_string(mainPtr,pc_area_buttons[i][3],"Stone ",1,style);
TEXT.font = "Silom"; style.font = FONT_BOLD;
TEXT.pointSize = 10; style.pointSize = 10;
break; break;
case 5: case 5:
TEXT.colour = sf::Color::White; style.colour = sf::Color::White;
TEXT.pointSize = 9; style.pointSize = 9;
TEXT.font = "Geneva"; style.font = FONT_PLAIN;
win_draw_string(mainPtr,pc_area_buttons[i][3],"Fled ",1,10); win_draw_string(mainPtr,pc_area_buttons[i][3],"Fled ",1,style);
TEXT.font = "Silom"; style.font = FONT_BOLD;
TEXT.pointSize = 10; style.pointSize = 10;
break; break;
case 6: case 6:
TEXT.colour = sf::Color::White; style.colour = sf::Color::White;
TEXT.pointSize = 9; style.pointSize = 9;
TEXT.font = "Geneva"; style.font = FONT_PLAIN;
win_draw_string(mainPtr,pc_area_buttons[i][3],"Surface ",1,10); win_draw_string(mainPtr,pc_area_buttons[i][3],"Surface ",1,style);
TEXT.font = "Silom"; style.font = FONT_BOLD;
TEXT.pointSize = 10; style.pointSize = 10;
break; break;
default: default:
TEXT.colour = sf::Color::White; style.colour = sf::Color::White;
TEXT.pointSize = 9; style.pointSize = 9;
TEXT.font = "Geneva"; style.font = FONT_PLAIN;
win_draw_string(mainPtr,pc_area_buttons[i][3],"Absent ",1,10); win_draw_string(mainPtr,pc_area_buttons[i][3],"Absent ",1,style);
TEXT.font = "Silom"; style.font = FONT_BOLD;
TEXT.pointSize = 10; style.pointSize = 10;
break; break;
} }
//frame_dlog_rect(GetWindowPort(mainPtr),pc_area_buttons[i][0],0); //frame_dlog_rect(GetWindowPort(mainPtr),pc_area_buttons[i][0],0);
@@ -756,45 +758,37 @@ void display_party()
} }
} // Closes the for i=6 loop } // Closes the for i=6 loop
TEXT.colour = sf::Color::Black;
for(i = 0; i < 5; i++) { for(i = 0; i < 5; i++) {
//frame_dlog_rect(GetWindowPort(mainPtr),edit_rect[i][0],0); //frame_dlog_rect(GetWindowPort(mainPtr),edit_rect[i][0],0);
//frame_dlog_rect(GetWindowPort(mainPtr),edit_rect[i][1],0); //frame_dlog_rect(GetWindowPort(mainPtr),edit_rect[i][1],0);
from_rect = (current_pressed_button == i + 10) ? ed_buttons_from[1] : ed_buttons_from[0]; from_rect = (current_pressed_button == i + 10) ? ed_buttons_from[1] : ed_buttons_from[0];
rect_draw_some_item(buttons_gworld,from_rect,mainPtr,edit_rect[i][0]); rect_draw_some_item(buttons_gworld,from_rect,mainPtr,edit_rect[i][0]);
TEXT.colour = sf::Color::White; style.colour = sf::Color::White;
switch(i) { switch(i) {
case 0: case 0:
win_draw_string(mainPtr,edit_rect[0][1]," Add|Mage|Spells",0,10); win_draw_string(mainPtr,edit_rect[0][1]," Add|Mage|Spells",0,style);
break; break;
case 1: case 1:
win_draw_string(mainPtr,edit_rect[1][1]," Add|Priest|Spells",0,10); win_draw_string(mainPtr,edit_rect[1][1]," Add|Priest|Spells",0,style);
break; break;
case 2: case 2:
win_draw_string(mainPtr,edit_rect[2][1]," Edit|Traits",0,10); win_draw_string(mainPtr,edit_rect[2][1]," Edit|Traits",0,style);
break; break;
case 3: case 3:
win_draw_string(mainPtr,edit_rect[3][1]," Edit|Skills",0,10); win_draw_string(mainPtr,edit_rect[3][1]," Edit|Skills",0,style);
break; break;
case 4: case 4:
win_draw_string(mainPtr,edit_rect[4][1]," Edit| XP",0,10); win_draw_string(mainPtr,edit_rect[4][1]," Edit| XP",0,style);
break; break;
default: default:
break; break;
} }
TEXT.colour = sf::Color::Black;
} }
// MoveTo(start_h + 10, start_v + 127); // MoveTo(start_h + 10, start_v + 127);
// sprintf((char *) to_draw, " Gold: %d Food: %d ",(short) party.gold, (short) party.food); // sprintf((char *) to_draw, " Gold: %d Food: %d ",(short) party.gold, (short) party.food);
// DrawString(to_draw); // DrawString(to_draw);
} }
TEXT.colour = sf::Color::Black;
} }
//void rect_draw_some_item (GWorldPtr src_gworld, RECT src_rect, GWorldPtr targ_gworld,RECT targ_rect, //void rect_draw_some_item (GWorldPtr src_gworld, RECT src_rect, GWorldPtr targ_gworld,RECT targ_rect,

View File

@@ -39,7 +39,6 @@ RECT bg[21];
RECT map_pat[30]; RECT map_pat[30];
RECT bw_pats[6]; RECT bw_pats[6];
sf::Texture bg_gworld; sf::Texture bg_gworld;
TextStyle TEXT;
bool use_win_graphics = false; bool use_win_graphics = false;
CursorRef GetCursorFromPath(std::string filename, location hotspot); CursorRef GetCursorFromPath(std::string filename, location hotspot);
sf::Shader maskShader; sf::Shader maskShader;
@@ -230,8 +229,24 @@ void rect_draw_some_item(const sf::Texture& src_gworld,RECT src_rect,const sf::T
} }
void TextStyle::applyTo(sf::Text& text) { void TextStyle::applyTo(sf::Text& text) {
text.setFont(*ResMgr::get<FontRsrc>(font)); switch(font) {
case FONT_PLAIN:
text.setFont(*ResMgr::get<FontRsrc>("plain"));
break;
case FONT_BOLD:
text.setFont(*ResMgr::get<FontRsrc>("bold"));
break;
case FONT_DUNGEON:
text.setFont(*ResMgr::get<FontRsrc>("dungeon"));
break;
case FONT_MAIDWORD:
text.setFont(*ResMgr::get<FontRsrc>("maidenword"));
break;
}
text.setCharacterSize(pointSize); text.setCharacterSize(pointSize);
int style = sf::Text::Regular;
if(italic) style |= sf::Text::Italic;
if(underline) style |= sf::Text::Underlined;
text.setStyle(style); text.setStyle(style);
text.setColor(colour); text.setColor(colour);
} }
@@ -240,9 +255,10 @@ void TextStyle::applyTo(sf::Text& text) {
// str is a c string, 256 characters // str is a c string, 256 characters
// uses current font // uses current font
// TODO: Make an enum for the mode parameter // TODO: Make an enum for the mode parameter
void win_draw_string(sf::RenderTarget& dest_window,RECT dest_rect,std::string str,short mode,short line_height,location offset){ void win_draw_string(sf::RenderTarget& dest_window,RECT dest_rect,std::string str,short mode,TextStyle style,location offset){
short line_height = style.lineHeight;
sf::Text str_to_draw; sf::Text str_to_draw;
TEXT.applyTo(str_to_draw); style.applyTo(str_to_draw);
short str_len,i; short str_len,i;
short last_line_break = 0,last_word_break = 0; short last_line_break = 0,last_word_break = 0;
short total_width = 0; short total_width = 0;
@@ -347,11 +363,11 @@ void win_draw_string(sf::RenderTarget& dest_window,RECT dest_rect,std::string st
//printf("String drawn.\n"); //printf("String drawn.\n");
} }
short string_length(std::string str){ short string_length(std::string str, TextStyle style){
short total_width = 0; short total_width = 0;
sf::Text text; sf::Text text;
TEXT.applyTo(text); style.applyTo(text);
text.setString(str); text.setString(str);
total_width = text.getLocalBounds().width; total_width = text.getLocalBounds().width;
return total_width; return total_width;

View File

@@ -51,11 +51,19 @@ struct m_pic_index_t {
unsigned char i, x, y; unsigned char i, x, y;
}; };
enum eFont {
FONT_PLAIN,
FONT_BOLD,
FONT_DUNGEON,
FONT_MAIDWORD
};
struct TextStyle { struct TextStyle {
int style; bool italic = false, underline = false;
std::string font; eFont font = FONT_BOLD;
int pointSize; int pointSize = 10, lineHeight;
sf::Color colour; sf::Color colour;
TextStyle() : colour(sf::Color::Black) {}
void applyTo(sf::Text& text); void applyTo(sf::Text& text);
}; };
@@ -93,8 +101,6 @@ struct cCustomGraphics {
graf_pos find_graphic(pic_num_t pic, bool party = false); graf_pos find_graphic(pic_num_t pic, bool party = false);
}; };
void init_graph_tool(); void init_graph_tool();
void clean_up_graphtool(); void clean_up_graphtool();
void set_cursor(cursor_type which_curs); void set_cursor(cursor_type which_curs);
@@ -103,8 +109,8 @@ void rect_draw_some_item(sf::RenderTarget& targ_gworld,RECT targ_rect);
void rect_draw_some_item(const sf::Texture& src_gworld,RECT src_rect,sf::RenderTarget& targ_gworld,RECT targ_rect,sf::BlendMode mode = sf::BlendNone); void rect_draw_some_item(const sf::Texture& src_gworld,RECT src_rect,sf::RenderTarget& targ_gworld,RECT targ_rect,sf::BlendMode mode = sf::BlendNone);
void rect_draw_some_item(const sf::Texture& src_gworld,RECT src_rect,RECT targ_rect,location offset,sf::BlendMode mode = sf::BlendNone); void rect_draw_some_item(const sf::Texture& src_gworld,RECT src_rect,RECT targ_rect,location offset,sf::BlendMode mode = sf::BlendNone);
void rect_draw_some_item(const sf::Texture& src_gworld,RECT src_rect,const sf::Texture& mask_gworld,RECT mask_rect,sf::RenderTarget& targ_gworld,RECT targ_rect); void rect_draw_some_item(const sf::Texture& src_gworld,RECT src_rect,const sf::Texture& mask_gworld,RECT mask_rect,sf::RenderTarget& targ_gworld,RECT targ_rect);
void win_draw_string(sf::RenderTarget& dest_window,RECT dest_rect,std::string str,short mode,short line_height,location offset = {0,0}); void win_draw_string(sf::RenderTarget& dest_window,RECT dest_rect,std::string str,short mode,TextStyle style,location offset = {0,0});
short string_length(std::string str); short string_length(std::string str, TextStyle style);
//OSStatus flip_pict(OSType domain, OSType type, short id, void *ptr, UInt32 size, bool isNative, void *refcon); //OSStatus flip_pict(OSType domain, OSType type, short id, void *ptr, UInt32 size, bool isNative, void *refcon);
//void draw_terrain(); //void draw_terrain();
RECT calc_rect(short i, short j); RECT calc_rect(short i, short j);
@@ -129,7 +135,6 @@ extern cursor_type arrow_curs[3][3];
extern cursor_type current_cursor; extern cursor_type current_cursor;
extern m_pic_index_t m_pic_index[200]; extern m_pic_index_t m_pic_index[200];
extern RECT bg[]; extern RECT bg[];
extern TextStyle TEXT;
#endif #endif
#endif #endif

View File

@@ -18,13 +18,6 @@
#include <fstream> #include <fstream>
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
// The four default fonts, defined here for convenience
// It's likely they'll be moved to another file eventually.
#define fontGeneva "Geneva,Tahoma,Liberation Sans,Futura,Arial"
#define fontSilom "Silom,Arial Rounded MT Bold,Impact"
#define fontDungeon "Dungeon,MS Serif,New York,Georgia,URW Bookman L"
#define fontMaidword "MaidenWord,Apple Chancery,Monotype Corsiva,URW Chancery L,Gabriola,Segoe Print,Comic Sans MS"
struct cCursor { struct cCursor {
sf::Image img; sf::Image img;
int xHot, yHot; int xHot, yHot;

View File

@@ -96,7 +96,7 @@ title {
background-position: center; background-position: center;
text-align: center; text-align: center;
font-size: 12px; font-size: 12px;
font-family: Silom; font-family: Capriola, Silom;
vertical-align: middle; vertical-align: middle;
padding-top: 6px; padding-top: 6px;
} }
@@ -135,7 +135,7 @@ title {
padding-left: 18px; padding-left: 18px;
padding-top: 0px; padding-top: 0px;
padding-bottom: 5px; padding-bottom: 5px;
font-family: Geneva; font-family: 'DejaVu Sans', Geneva;
font-size: 10px; font-size: 10px;
} }
@@ -163,7 +163,7 @@ title {
.text { .text {
font-size: 10px; font-size: 10px;
font-family: Silom; font-family: Capriola, Silom;
line-height: 12px; line-height: 12px;
} }
@@ -183,5 +183,5 @@ title {
} }
.text.plain { .text.plain {
font-family: Geneva; font-family: 'DejaVu Sans', Geneva;
} }

View File

@@ -130,12 +130,12 @@
<xs:attribute name="key-mod" type="mod"/> <xs:attribute name="key-mod" type="mod"/>
</xs:attributeGroup> </xs:attributeGroup>
<xs:attributeGroup name="font"> <xs:attributeGroup name="font">
<xs:attribute name="font" default="silom"> <xs:attribute name="font" default="bold">
<xs:simpleType> <xs:simpleType>
<xs:restriction base="xs:token"> <xs:restriction base="xs:token">
<xs:enumeration value="dungeon"/> <xs:enumeration value="dungeon"/>
<xs:enumeration value="geneva"/> <xs:enumeration value="plain"/>
<xs:enumeration value="silom"/> <xs:enumeration value="bold"/>
<xs:enumeration value="maidenword"/> <xs:enumeration value="maidenword"/>
</xs:restriction> </xs:restriction>
</xs:simpleType> </xs:simpleType>

View File

@@ -109,8 +109,8 @@
color: <xsl:value-of select='./@color'/> <xsl:value-of select='/dialog/@fore'/>; color: <xsl:value-of select='./@color'/> <xsl:value-of select='/dialog/@fore'/>;
font-family: font-family:
<xsl:choose> <xsl:choose>
<xsl:when test='@font = "plain"'>Geneva</xsl:when> <xsl:when test='@font = "plain"'>'DejaVu Sans', Geneva</xsl:when>
<xsl:when test='@font = "bold"'>Silom</xsl:when> <xsl:when test='@font = "bold"'>Capriola, Silom</xsl:when>
<xsl:otherwise><xsl:value-of select='./@font'/></xsl:otherwise> <xsl:otherwise><xsl:value-of select='./@font'/></xsl:otherwise>
</xsl:choose>; </xsl:choose>;
<xsl:if test='./@state'> <xsl:if test='./@state'>
@@ -138,8 +138,8 @@
color: <xsl:value-of select='./@color'/> <xsl:value-of select='/dialog/@fore'/>; color: <xsl:value-of select='./@color'/> <xsl:value-of select='/dialog/@fore'/>;
font-family: font-family:
<xsl:choose> <xsl:choose>
<xsl:when test='@font = "plain"'>Geneva</xsl:when> <xsl:when test='@font = "plain"'>'DejaVu Sans', Geneva</xsl:when>
<xsl:when test='@font = "bold"'>Silom</xsl:when> <xsl:when test='@font = "bold"'>Capriola, Silom</xsl:when>
<xsl:otherwise><xsl:value-of select='./@font'/></xsl:otherwise> <xsl:otherwise><xsl:value-of select='./@font'/></xsl:otherwise>
</xsl:choose>; </xsl:choose>;
border-color: red; border-color: red;
@@ -195,7 +195,7 @@
<div class='tfield-inner'> <div class='tfield-inner'>
<xsl:attribute name='style'> <xsl:attribute name='style'>
width: <xsl:value-of select='./@width'/>px; height: <xsl:value-of select='./@height'/>px; width: <xsl:value-of select='./@width'/>px; height: <xsl:value-of select='./@height'/>px;
font-family: Geneva; font-family: 'DejaVu Sans', Geneva;
font-size: 12px; font-size: 12px;
</xsl:attribute> </xsl:attribute>
(<xsl:value-of select='@name'/>) (<xsl:value-of select='@name'/>)

View File

@@ -21,9 +21,9 @@
<led name='obstructed' top='107' left='293' state='off' width='120'>Blocked, obstructed</led> <led name='obstructed' top='107' left='293' state='off' width='120'>Blocked, obstructed</led>
<led name='opaque' top='124' left='293' state='off' width='120'>Blocked, opaque</led> <led name='opaque' top='124' left='293' state='off' width='120'>Blocked, opaque</led>
</group> </group>
<led name='flight' top='150' left='26' state='off' width='120' font='silom'>Can fly over?</led> <led name='flight' top='150' left='26' state='off' width='120' font='bold'>Can fly over?</led>
<led name='boat' top='150' left='154' state='off' width='120' font='silom'>Can boat over?</led> <led name='boat' top='150' left='154' state='off' width='120' font='bold'>Can boat over?</led>
<led name='horse' top='150' left='307' state='off' width='120' font='silom'>Blocked to horses?</led> <led name='horse' top='150' left='307' state='off' width='120' font='bold'>Blocked to horses?</led>
<text top='165' left='8' height='14' width='91'>Step sound:</text> <text top='165' left='8' height='14' width='91'>Step sound:</text>
<group name='sound'> <group name='sound'>
<led name="step" top='167' left='102' state='off' width='60'>Footstep</led> <led name="step" top='167' left='102' state='off' width='60'>Footstep</led>