diff --git a/osx/boe.graphics.cpp b/osx/boe.graphics.cpp index 2a93b3b4..80127550 100644 --- a/osx/boe.graphics.cpp +++ b/osx/boe.graphics.cpp @@ -346,7 +346,7 @@ void draw_startup_stats() if(!party_in_memory) { style.pointSize = 20; to_rect.offset(175,40); - win_draw_string(mainPtr,to_rect,"No Party in Memory",0,style,ul); + win_draw_string(mainPtr,to_rect,"No Party in Memory",eTextMode::WRAP,style,ul); } else { frame_rect = startup_top; frame_rect.inset(50,50); @@ -356,7 +356,7 @@ void draw_startup_stats() ::frame_rect(mainPtr, frame_rect, sf::Color::White); to_rect.offset(203,37); - win_draw_string(mainPtr,to_rect,"Your party:",0,style,ul); + win_draw_string(mainPtr,to_rect,"Your party:",eTextMode::WRAP,style,ul); style.pointSize = 12; style.font = FONT_BOLD; for (i = 0; i < 6; i++) { @@ -373,7 +373,7 @@ void draw_startup_stats() style.pointSize = 14; pc_rect.offset(35,0); - win_draw_string(mainPtr,pc_rect,univ.party[i].name,0,style,ul); + win_draw_string(mainPtr,pc_rect,univ.party[i].name,eTextMode::WRAP,style,ul); to_rect.offset(pc_rect.left + 8,pc_rect.top + 8); } @@ -404,23 +404,23 @@ void draw_startup_stats() 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; } - win_draw_string(mainPtr,pc_rect,str,0,style,ul); + win_draw_string(mainPtr,pc_rect,str,eTextMode::WRAP,style,ul); pc_rect.offset(0,13); sprintf((char *) str,"Health %d, Spell pts. %d", univ.party[i].max_health,univ.party[i].max_sp); - win_draw_string(mainPtr,pc_rect,str,0,style,ul); + win_draw_string(mainPtr,pc_rect,str,eTextMode::WRAP,style,ul); break; case MAIN_STATUS_DEAD: - win_draw_string(mainPtr,pc_rect,"Dead",0,style,ul); + win_draw_string(mainPtr,pc_rect,"Dead",eTextMode::WRAP,style,ul); break; case MAIN_STATUS_DUST: - win_draw_string(mainPtr,pc_rect,"Dust",0,style,ul); + win_draw_string(mainPtr,pc_rect,"Dust",eTextMode::WRAP,style,ul); break; case MAIN_STATUS_STONE: - win_draw_string(mainPtr,pc_rect,"Stone",0,style,ul); + win_draw_string(mainPtr,pc_rect,"Stone",eTextMode::WRAP,style,ul); break; case MAIN_STATUS_FLED: - win_draw_string(mainPtr,pc_rect,"Fled",0,style,ul); + win_draw_string(mainPtr,pc_rect,"Fled",eTextMode::WRAP,style,ul); break; default: //absent, and all variations thereof; do nothing break; @@ -435,7 +435,7 @@ void draw_startup_stats() pc_rect.top = pc_rect.bottom - 25; pc_rect.left = pc_rect.right - 300; // 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,style,ul); + win_draw_string(mainPtr,pc_rect,"Copyright 1997, All Rights Reserved, v1.0.2",eTextMode::WRAP,style,ul); } @@ -471,7 +471,7 @@ void draw_start_button(short which_position,short which_button) style.lineHeight = 18; if (which_position == 3) to_rect.offset(-7,0); - win_draw_string(mainPtr,to_rect,button_labels[which_position],1,style,ul); + win_draw_string(mainPtr,to_rect,button_labels[which_position],eTextMode::CENTRE,style,ul); } void main_button_click(short mode,RECT button_rect) @@ -757,25 +757,25 @@ void put_text_bar(char *str) { style.lineHeight = 12; RECT to_rect = RECT(text_bar_gworld); // TODO: Not sure what the line height should be, so I just picked something - win_draw_string(text_bar_gworld, to_rect, str, 2, style); + win_draw_string(text_bar_gworld, to_rect, str, eTextMode::LEFT_TOP, style); if (monsters_going == false) { to_rect.left = 205; to_rect.top = 14; if (PSD[SDF_PARTY_STEALTHY] > 0) { - win_draw_string(text_bar_gworld, to_rect, "Stealth", 2, style); + win_draw_string(text_bar_gworld, to_rect, "Stealth", eTextMode::LEFT_TOP, style); to_rect.left -= 60; } if (PSD[SDF_PARTY_FLIGHT] > 0) { - win_draw_string(text_bar_gworld, to_rect, "Flying", 2, style); + win_draw_string(text_bar_gworld, to_rect, "Flying", eTextMode::LEFT_TOP, style); to_rect.left -= 60; } if (PSD[SDF_PARTY_DETECT_LIFE] > 0) { - win_draw_string(text_bar_gworld, to_rect, "Detect Life", 2, style); + win_draw_string(text_bar_gworld, to_rect, "Detect Life", eTextMode::LEFT_TOP, style); to_rect.left -= 60; } if (PSD[SDF_PARTY_FIREWALK] > 0) { - win_draw_string(text_bar_gworld, to_rect, "Firewalk", 2, style); + win_draw_string(text_bar_gworld, to_rect, "Firewalk", eTextMode::LEFT_TOP, style); to_rect.left -= 60; } } @@ -1556,7 +1556,7 @@ void boom_space(location where,short mode,short type,short damage,short sound) if ((damage < 10) && (dest_rect.right - dest_rect.left > 19)) text_rect.left += 10; text_rect.offset(-4,-5); - win_draw_string(mainPtr,text_rect,dam_str,1,style,ul); + win_draw_string(mainPtr,text_rect,dam_str,eTextMode::CENTRE,style,ul); } play_sound((skip_boom_delay?-1:1)*sound_to_play[sound]); mainPtr.display(); @@ -1726,7 +1726,7 @@ void draw_targeting_line(location where_curs) const char chr[2] = {static_cast(num_targets_left + '0')}; int x = ((target_rect.left + target_rect.right) / 2) - 3; int y = (target_rect.top + target_rect.bottom) / 2; - win_draw_string(mainPtr, RECT(y, x, y + 12, x + 12), chr, 1, style); + win_draw_string(mainPtr, RECT(y, x, y + 12, x + 12), chr, eTextMode::CENTRE, style); } } diff --git a/osx/boe.newgraph.cpp b/osx/boe.newgraph.cpp index 737e2f80..e4d17a46 100644 --- a/osx/boe.newgraph.cpp +++ b/osx/boe.newgraph.cpp @@ -668,7 +668,7 @@ void do_explosion_anim(short sound_num,short special_draw) sprintf(str,"%d",store_booms[i].val_to_place); style.colour = sf::Color::White; style.lineHeight = 12; - win_draw_string(temp_gworld,text_rect,str,1,style); + win_draw_string(temp_gworld,text_rect,str,eTextMode::CENTRE,style); style.colour = sf::Color::Black; mainPtr.setActive(); } @@ -796,10 +796,10 @@ void draw_shop_graphics(bool pressed,RECT clip_area_rect) style.lineHeight = 18; dest_rect = title_rect; dest_rect.offset(1,1); - win_draw_string(talk_gworld,dest_rect,store_store_name,2,style); + win_draw_string(talk_gworld,dest_rect,store_store_name,eTextMode::LEFT_TOP,style); dest_rect.offset(-1,-1); style.colour = c[4]; - win_draw_string(talk_gworld,dest_rect,store_store_name,2,style); + win_draw_string(talk_gworld,dest_rect,store_store_name,eTextMode::LEFT_TOP,style); style.font = FONT_BOLD; style.pointSize = 12; @@ -813,7 +813,7 @@ void draw_shop_graphics(bool pressed,RECT clip_area_rect) case 4: sprintf(cur_name,"Buying Food.");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,style); + win_draw_string(talk_gworld,shopper_name,cur_name,eTextMode::LEFT_TOP,style); // Place help and done buttons // TODO: Reimplement these with a cButton @@ -902,11 +902,11 @@ void draw_shop_graphics(bool pressed,RECT clip_area_rect) // 4 - item cost 5 - item extra str 6 - item help button style.pointSize = 12; style.lineHeight = 12; - win_draw_string(talk_gworld,shopping_rects[i][3],cur_name,0,style); + win_draw_string(talk_gworld,shopping_rects[i][3],cur_name,eTextMode::WRAP,style); sprintf(cur_name,"Cost: %d",cur_cost); - win_draw_string(talk_gworld,shopping_rects[i][4],cur_name,0,style); + win_draw_string(talk_gworld,shopping_rects[i][4],cur_name,eTextMode::WRAP,style); style.pointSize = 10; - win_draw_string(talk_gworld,shopping_rects[i][5],cur_info_str,0,style); + win_draw_string(talk_gworld,shopping_rects[i][5],cur_info_str,eTextMode::WRAP,style); 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); @@ -916,11 +916,11 @@ void draw_shop_graphics(bool pressed,RECT clip_area_rect) sprintf(cur_name,"Prices here are %s.",cost_strs[store_cost_mult]); style.pointSize = 10; style.lineHeight = 12; - win_draw_string(talk_gworld,bottom_help_rects[0],cur_name,0,style); - 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); + win_draw_string(talk_gworld,bottom_help_rects[0],cur_name,eTextMode::WRAP,style); + win_draw_string(talk_gworld,bottom_help_rects[1],"Click on item name (or type 'a'-'h') to buy.",eTextMode::WRAP,style); + win_draw_string(talk_gworld,bottom_help_rects[2],"Hit done button (or Esc.) to quit.",eTextMode::WRAP,style); if ((store_shop_type != 3) && (store_shop_type != 4)) - win_draw_string(talk_gworld,bottom_help_rects[3],"'I' button brings up description.",0,style); + win_draw_string(talk_gworld,bottom_help_rects[3],"'I' button brings up description.",eTextMode::WRAP,style); undo_clip(talk_gworld); talk_gworld.display(); @@ -1143,10 +1143,10 @@ void place_talk_str(std::string str_to_place,std::string str_to_place2,short col style.lineHeight = 18; dest_rect = title_rect; dest_rect.offset(1,1); - win_draw_string(talk_gworld,dest_rect,title_string,2,style); + win_draw_string(talk_gworld,dest_rect,title_string,eTextMode::LEFT_TOP,style); dest_rect.offset(-1,-1); style.colour = c[4]; - win_draw_string(talk_gworld,dest_rect,title_string,2,style); + win_draw_string(talk_gworld,dest_rect,title_string,eTextMode::LEFT_TOP,style); // Place buttons at bottom. if (color == 0) @@ -1155,7 +1155,7 @@ void place_talk_str(std::string str_to_place,std::string str_to_place2,short col for (i = 0; i < 9; i++) if ((talk_end_forced == false) || (i == 6) || (i == 5)) { preset_words[i].word_rect.offset(0,8); - win_draw_string(talk_gworld,preset_words[i].word_rect,preset_words[i].word,2,style); + win_draw_string(talk_gworld,preset_words[i].word_rect,preset_words[i].word,eTextMode::LEFT_TOP,style); preset_words[i].word_rect.offset(0,-8); } // Place bulk of what said. Save words. @@ -1185,7 +1185,7 @@ void place_talk_str(std::string str_to_place,std::string str_to_place2,short col style.lineHeight = line_height; style.applyTo(str_to_draw); // TODO: The entire text flashes when clicking anything - win_draw_string(talk_gworld, dest_rect, str, 0, style); + win_draw_string(talk_gworld, dest_rect, str, eTextMode::WRAP, style); 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 (((i - store_last_word_break >= 4) || (i >= str_len - 1)) @@ -1256,7 +1256,7 @@ void place_talk_str(std::string str_to_place,std::string str_to_place2,short col str_to_draw.setString(str); last_line_break = store_last_word_break = last_word_break = last_stored_word_break = 0; - win_draw_string(talk_gworld, dest_rect, str, 0, style); + win_draw_string(talk_gworld, dest_rect, str, eTextMode::WRAP, style); 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 (((i - store_last_word_break >= 4) || (i >= str_len - 1)) diff --git a/osx/boe.text.cpp b/osx/boe.text.cpp index c91bbf65..4916d575 100644 --- a/osx/boe.text.cpp +++ b/osx/boe.text.cpp @@ -149,12 +149,12 @@ void put_pc_screen() style.lineHeight = 10; // Put food, gold, day sprintf((char *) to_draw, "%d", (short) univ.party.gold); - win_draw_string( pc_stats_gworld,small_erase_rects[1],to_draw,0,style); + win_draw_string( pc_stats_gworld,small_erase_rects[1],to_draw,eTextMode::WRAP,style); sprintf((char *) to_draw, "%d", (short) univ.party.food); - win_draw_string( pc_stats_gworld,small_erase_rects[0],to_draw,0,style); + win_draw_string( pc_stats_gworld,small_erase_rects[0],to_draw,eTextMode::WRAP,style); i = calc_day(); sprintf((char *) to_draw, "%d", i); - win_draw_string( pc_stats_gworld,small_erase_rects[2],to_draw,0,style); + win_draw_string( pc_stats_gworld,small_erase_rects[2],to_draw,eTextMode::WRAP,style); style.colour = sf::Color::Black; for (i = 0; i < 6; i++) { @@ -167,7 +167,7 @@ void put_pc_screen() } 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,style); + win_draw_string(pc_stats_gworld,pc_buttons[i][0],to_draw,eTextMode::WRAP,style); style.italic = false; style.colour = sf::Color::Black; @@ -179,12 +179,12 @@ void put_pc_screen() style.colour = sf::Color::Green; else style.colour = sf::Color::Red; sprintf((char *) to_draw, "%-3d ",univ.party[i].cur_health); - win_draw_string( pc_stats_gworld,pc_buttons[i][1],to_draw,0,style); + win_draw_string( pc_stats_gworld,pc_buttons[i][1],to_draw,eTextMode::WRAP,style); if (univ.party[i].cur_sp == univ.party[i].max_sp) style.colour = sf::Color::Blue; else style.colour = sf::Color::Magenta; sprintf((char *) to_draw, "%-3d ",univ.party[i].cur_sp); - win_draw_string( pc_stats_gworld,pc_buttons[i][2],to_draw,0,style); + win_draw_string( pc_stats_gworld,pc_buttons[i][2],to_draw,eTextMode::WRAP,style); draw_pc_effects(i); break; case 2: @@ -210,7 +210,7 @@ void put_pc_screen() break; } if (univ.party[i].main_status != 1) - win_draw_string( pc_stats_gworld,to_draw_rect,to_draw,0,style); + win_draw_string( pc_stats_gworld,to_draw_rect,to_draw,eTextMode::WRAP,style); style.colour = sf::Color::Black; // Now put trade and info buttons @@ -283,13 +283,13 @@ void put_item_screen(short screen_num,short suppress_buttons) case 6: // On special items page style.font = FONT_BOLD; style.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:",eTextMode::WRAP,style); style.colour = sf::Color::Black; for (i = 0; i < 8; i++) { i_num = i + item_offset; if (spec_item_array[i_num] >= 0) { // 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,style); + win_draw_string(item_stats_gworld,item_buttons[i][0],scenario.scen_strs(60 + spec_item_array[i_num] * 2),eTextMode::WRAP,style); place_item_button(3,i,4,0); if ((scenario.special_items[spec_item_array[i_num]].flags % 10 == 1) @@ -308,7 +308,7 @@ void put_item_screen(short screen_num,short suppress_buttons) style.font = FONT_PLAIN; sout.str("");; sout << univ.party[pc].name << " inventory:", - win_draw_string(item_stats_gworld,upper_frame_rect,sout.str(),0,style); + win_draw_string(item_stats_gworld,upper_frame_rect,sout.str(),eTextMode::WRAP,style); style.colour = sf::Color::Black; style.font = FONT_BOLD; @@ -316,7 +316,7 @@ void put_item_screen(short screen_num,short suppress_buttons) i_num = i + item_offset; sout.str(""); sout << i_num + 1 << '.'; - win_draw_string(item_stats_gworld,item_buttons[i][0],sout.str(),0,style); + win_draw_string(item_stats_gworld,item_buttons[i][0],sout.str(),eTextMode::WRAP,style); dest_rect = item_buttons[i][0]; dest_rect.left += 36; @@ -346,7 +346,7 @@ void put_item_screen(short screen_num,short suppress_buttons) sout << '(' << int(univ.party[pc].items[i_num].charges) << ')'; } dest_rect.left -= 2; - win_draw_string(item_stats_gworld,dest_rect,sout.str(),0,style); + win_draw_string(item_stats_gworld,dest_rect,sout.str(),eTextMode::WRAP,style); style.italic = false; style.colour = sf::Color::Black; @@ -459,7 +459,7 @@ void place_buy_button(short position,short pc_num,short item_num) if (val_to_place >= 10000) style.font = FONT_PLAIN; style.lineHeight = 10; - win_draw_string(item_stats_gworld,item_buttons[position][5],store_str,2,style); + win_draw_string(item_stats_gworld,item_buttons[position][5],store_str,eTextMode::LEFT_TOP,style); } } diff --git a/osx/boe.town.cpp b/osx/boe.town.cpp index d18359c4..9556b81c 100644 --- a/osx/boe.town.cpp +++ b/osx/boe.town.cpp @@ -1562,8 +1562,8 @@ void draw_map(bool need_refresh) { theGraphic.draw(); style.colour = sf::Color::White; style.lineHeight = 12; - win_draw_string(mini_map, map_title_rect,title_string,0,style); - win_draw_string(mini_map, map_bar_rect,"(Hit Escape to close.)",0,style); + win_draw_string(mini_map, map_title_rect,title_string,eTextMode::WRAP,style); + win_draw_string(mini_map, map_bar_rect,"(Hit Escape to close.)",eTextMode::WRAP,style); /*SetPort( mini_map); GetDialogItem(mini_map, 1, &the_type, &the_handle, &the_rect); diff --git a/osx/dialogxml/button.cpp b/osx/dialogxml/button.cpp index 23b63ec7..91ba25c4 100644 --- a/osx/dialogxml/button.cpp +++ b/osx/dialogxml/button.cpp @@ -65,9 +65,9 @@ void cButton::draw(){ rect_draw_some_item(buttons[btnGW[type]],from_rect,*inWindow,to_rect,sf::BlendAlpha); style.colour = sf::Color::Black; style.lineHeight = 8; - int textMode = 1; + eTextMode textMode = eTextMode::CENTRE; if(type == BTN_TINY) { - textMode = 2; + textMode = eTextMode::LEFT_TOP; to_rect.left += 18; } else if(type == BTN_PUSH) { to_rect.top += 34; @@ -256,7 +256,7 @@ void cLed::draw(){ style.colour = parent->defTextClr; to_rect.right = frame.right; to_rect.left = frame.left + 18; // Possibly could be 20 - win_draw_string(*inWindow,to_rect,lbl,2,style); + win_draw_string(*inWindow,to_rect,lbl,eTextMode::LEFT_TOP,style); }else{ tileImage(*inWindow,frame,bg_gworld,bg[parent->bg]); } diff --git a/osx/dialogxml/field.cpp b/osx/dialogxml/field.cpp index 70e70631..43f30ab3 100644 --- a/osx/dialogxml/field.cpp +++ b/osx/dialogxml/field.cpp @@ -123,8 +123,7 @@ void cTextField::draw(){ ip_timer.restart(); } } - // TODO: Update win_draw_string to take a std::string - win_draw_string(*inWindow, rect, contents, 0, style); + win_draw_string(*inWindow, rect, contents, eTextMode::WRAP, style); } void cTextField::handleInput(cKey key) { diff --git a/osx/dialogxml/message.cpp b/osx/dialogxml/message.cpp index 24f3372f..e6ec60f4 100644 --- a/osx/dialogxml/message.cpp +++ b/osx/dialogxml/message.cpp @@ -115,11 +115,11 @@ void cTextMsg::draw(){ if (to_rect.bottom - to_rect.top < 20) { // essentially, it's a single line style.lineHeight = 12; to_rect.left += 3; - win_draw_string(*inWindow,to_rect,lbl,3,style); + win_draw_string(*inWindow,to_rect,lbl,eTextMode::LEFT_BOTTOM,style); }else { style.lineHeight = textSize + 2; to_rect.inset(4,4); - win_draw_string(*inWindow,to_rect,lbl,0,style); + win_draw_string(*inWindow,to_rect,lbl,eTextMode::WRAP,style); } } } diff --git a/osx/pcedit/pc.graphics.cpp b/osx/pcedit/pc.graphics.cpp index 258e4ec0..82dc8008 100644 --- a/osx/pcedit/pc.graphics.cpp +++ b/osx/pcedit/pc.graphics.cpp @@ -280,7 +280,7 @@ void draw_main_screen() dest_rect.bottom = dest_rect.top + 12; style.pointSize = 12; style.underline = true; - win_draw_string(mainPtr,dest_rect,"Characters",0,style); + win_draw_string(mainPtr,dest_rect,"Characters",eTextMode::WRAP,style); style.underline = false; style.pointSize = 10; } @@ -298,25 +298,25 @@ void draw_main_screen() //Off0setRect(&dest_rect,0,45); dest_rect.offset(0,21); if(!file_in_mem.empty()) - win_draw_string(mainPtr,dest_rect,"Click on character to edit it.",0,style); + win_draw_string(mainPtr,dest_rect,"Click on character to edit it.",eTextMode::WRAP,style); else - win_draw_string(mainPtr,dest_rect,"Select Open from File menu.",0,style); + win_draw_string(mainPtr,dest_rect,"Select Open from File menu.",eTextMode::WRAP,style); if(!file_in_mem.empty() && party_in_scen && !scen_items_loaded){ dest_rect.offset(200,0); - win_draw_string(mainPtr,dest_rect,"Warning: Scenario item data could not be loaded.",0,style); + win_draw_string(mainPtr,dest_rect,"Warning: Scenario item data could not be loaded.",eTextMode::WRAP,style); dest_rect.offset(-200,0); } dest_rect.offset(0,12); if(!file_in_mem.empty()) - win_draw_string(mainPtr,dest_rect,"Press 'I' button to identify item, and 'D' button to drop item.",0,style); + win_draw_string(mainPtr,dest_rect,"Press 'I' button to identify item, and 'D' button to drop item.",eTextMode::WRAP,style); style.pointSize = 12; dest_rect.offset(0,16); if(!file_in_mem.empty()) - win_draw_string(mainPtr,dest_rect,"Back up save file before editing it!",0,style); + win_draw_string(mainPtr,dest_rect,"Back up save file before editing it!",eTextMode::WRAP,style); style.pointSize = 10; style.font = FONT_PLAIN; dest_rect.offset(280,0); - win_draw_string(mainPtr,dest_rect,"Created in 1997 by Spiderweb Software, Inc.",0,style); + win_draw_string(mainPtr,dest_rect,"Created in 1997 by Spiderweb Software, Inc.",eTextMode::WRAP,style); reg_rect = whole_win_rect; @@ -386,7 +386,7 @@ void draw_items() TextStyle style; style.lineHeight = 10; - win_draw_string(mainPtr,item_string_rects[i][0],(char *) to_draw,0,style); + win_draw_string(mainPtr,item_string_rects[i][0],(char *) to_draw,eTextMode::WRAP,style); //Draw id/drop buttons rect_draw_some_item(invenbtn_gworld,d_from,mainPtr,item_string_rects[i][1],sf::BlendAlpha); @@ -413,15 +413,15 @@ void display_party() no_party_rect=pc_info_rect; no_party_rect.top+=5; no_party_rect.left+=5; - win_draw_string(mainPtr,no_party_rect,"No party loaded.",0,style); + win_draw_string(mainPtr,no_party_rect,"No party loaded.",eTextMode::WRAP,style); } else { from_rect = pc_info_rect; from_rect.top = from_rect.bottom - 14; if (party_in_scen == false) - win_draw_string(mainPtr,from_rect,"Party not in a scenario.",0,style); + win_draw_string(mainPtr,from_rect,"Party not in a scenario.",eTextMode::WRAP,style); else - win_draw_string(mainPtr,from_rect,"Party is in a scenario (day " + std::to_string(1 + univ.party.age / 3700) + ").",0,style); + win_draw_string(mainPtr,from_rect,"Party is in a scenario (day " + std::to_string(1 + univ.party.age / 3700) + ").",eTextMode::WRAP,style); for (i = 0; i < 6; i++) { if (i == current_active_pc) // active pc is drawn in blue fill_rect(mainPtr, pc_area_buttons[i][0], sf::Color::Blue); @@ -452,7 +452,7 @@ void display_party() } style.colour = sf::Color::White; - win_draw_string(mainPtr,pc_area_buttons[i][2],to_draw,1,style); + win_draw_string(mainPtr,pc_area_buttons[i][2],to_draw,eTextMode::CENTRE,style); style.font = FONT_BOLD; style.pointSize = 10; @@ -461,7 +461,7 @@ void display_party() if( (univ.party[i].name.length()) > 12) style.pointSize = 8; style.colour = sf::Color::Black; - win_draw_string(mainPtr,name_rect,to_draw,1,style); + win_draw_string(mainPtr,name_rect,to_draw,eTextMode::CENTRE,style); style.pointSize = 10; } @@ -471,18 +471,18 @@ void display_party() if (i == current_active_pc) { //Draw in race if (univ.party[i].race == 0) - win_draw_string(mainPtr,pc_race_rect,"Human ",1,style); + win_draw_string(mainPtr,pc_race_rect,"Human ",eTextMode::CENTRE,style); if (univ.party[i].race == 1) - win_draw_string(mainPtr,pc_race_rect,"Nephilim ",1,style); + win_draw_string(mainPtr,pc_race_rect,"Nephilim ",eTextMode::CENTRE,style); if (univ.party[i].race == 2) - win_draw_string(mainPtr,pc_race_rect,"Slithzerikai ",1,style); + win_draw_string(mainPtr,pc_race_rect,"Slithzerikai ",eTextMode::CENTRE,style); // Draw in skills sprintf((char *) to_draw, "Skills:"); - win_draw_string(mainPtr,skill_rect,to_draw,0,style); + win_draw_string(mainPtr,skill_rect,to_draw,eTextMode::WRAP,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, univ.party[i].max_sp); - win_draw_string(mainPtr,hp_sp_rect,to_draw,0,style); + win_draw_string(mainPtr,hp_sp_rect,to_draw,eTextMode::WRAP,style); style.pointSize = 9; @@ -494,10 +494,10 @@ void display_party() temp_rect = pc_skills_rect[k]; temp_rect.left = pc_skills_rect[k].left + 80; - win_draw_string(mainPtr,pc_skills_rect[k],get_str("skills",string_num),0,style); + win_draw_string(mainPtr,pc_skills_rect[k],get_str("skills",string_num),eTextMode::WRAP,style); sprintf((char *) skill_value,"%d",univ.party[i].skills[k]); - win_draw_string(mainPtr,temp_rect,skill_value,0,style); + win_draw_string(mainPtr,temp_rect,skill_value,eTextMode::WRAP,style); //frame_dlog_rect(GetWindowPort(mainPtr),pc_skills_rect[k],0); string_num+=2; } @@ -508,7 +508,7 @@ void display_party() style.pointSize = 10; style.font = FONT_BOLD; sprintf((char *) to_draw, "Status:"); - win_draw_string(mainPtr,status_rect,to_draw,0,style); + win_draw_string(mainPtr,status_rect,to_draw,eTextMode::WRAP,style); style.pointSize = 9; style.font = FONT_PLAIN; @@ -519,82 +519,82 @@ void display_party() //frame_dlog_rect(GetWindowPort(mainPtr),pc_status_rect[k],0); if (univ.party[i].status[0] > 0) if(cur_rect <= 9) { - win_draw_string(mainPtr,pc_status_rect[cur_rect],"Poisoned Weap.",0,style); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Poisoned Weap.",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].status[1] > 0) if(cur_rect <= 9) { - win_draw_string(mainPtr,pc_status_rect[cur_rect],"Blessed",0,style); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Blessed",eTextMode::WRAP,style); cur_rect++; } else if(univ.party[i].status[1] < 0) if(cur_rect <= 9) { - win_draw_string(mainPtr,pc_status_rect[cur_rect],"Cursed",0,style); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Cursed",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].status[2] > 0) if(cur_rect <= 9) { - win_draw_string(mainPtr,pc_status_rect[cur_rect],"Poisoned",0,style); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Poisoned",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].status[3] > 0) if(cur_rect <= 9) { - win_draw_string(mainPtr,pc_status_rect[cur_rect],"Hasted",0,style); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Hasted",eTextMode::WRAP,style); cur_rect++; } else if(univ.party[i].status[3] < 0) if(cur_rect <= 9) { - win_draw_string(mainPtr,pc_status_rect[cur_rect],"Slowed",0,style); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Slowed",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].status[4] > 0) if(cur_rect <= 9) { - win_draw_string(mainPtr,pc_status_rect[cur_rect],"Invulnerable",0,style); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Invulnerable",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].status[5] > 0) if(cur_rect <= 9) { - win_draw_string(mainPtr,pc_status_rect[cur_rect],"Magic Resistant",0,style); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Magic Resistant",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].status[6] > 0) if(cur_rect <= 9) { - win_draw_string(mainPtr,pc_status_rect[cur_rect],"Webbed",0,style); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Webbed",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].status[7] > 0) if(cur_rect <= 9) { - win_draw_string(mainPtr,pc_status_rect[cur_rect],"Diseased",0,style); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Diseased",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].status[8] > 0) if(cur_rect <= 9) { - win_draw_string(mainPtr,pc_status_rect[cur_rect],"Sanctury",0,style); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Sanctury",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].status[9] > 0) if(cur_rect <= 9) { - win_draw_string(mainPtr,pc_status_rect[cur_rect],"Dumbfounded",0,style); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Dumbfounded",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].status[10] > 0) if(cur_rect <= 9) { - win_draw_string(mainPtr,pc_status_rect[cur_rect],"Martyr's Shield",0,style); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Martyr's Shield",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].status[11] > 0) if(cur_rect <= 9) { - win_draw_string(mainPtr,pc_status_rect[cur_rect],"Asleep",0,style); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Asleep",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].status[12] > 0) if(cur_rect <= 9) { - win_draw_string(mainPtr,pc_status_rect[cur_rect],"Paralyzed",0,style); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Paralyzed",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].status[13] > 0) if(cur_rect <= 9) { - win_draw_string(mainPtr,pc_status_rect[cur_rect],"Acid",0,style); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Acid",eTextMode::WRAP,style); cur_rect++; } style.lineHeight = 10; @@ -604,7 +604,7 @@ void display_party() style.pointSize = 10; style.font = FONT_BOLD; sprintf((char *) to_draw, "Traits:"); - win_draw_string(mainPtr,traits_rect,to_draw,0,style); + win_draw_string(mainPtr,traits_rect,to_draw,eTextMode::WRAP,style); //for(k = 0 ; k < 16; k++) //frame_dlog_rect(GetWindowPort(mainPtr),pc_traits_rect[k],0); style.pointSize = 9; @@ -614,78 +614,78 @@ void display_party() cur_rect=0; if (univ.party[i].traits[0] == 1) if(cur_rect <= 15) { - win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Toughness",0,style); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Toughness",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].traits[1] == 1) if(cur_rect <= 15) { - win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Magically Apt",0,style); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Magically Apt",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].traits[2] == 1) if(cur_rect <= 15) { - win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Ambidextrous",0,style); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Ambidextrous",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].traits[3] == 1) if(cur_rect <= 15) { - win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Nimble Fingers",0,style); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Nimble Fingers",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].traits[4] == 1) if(cur_rect <= 15) { - win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Cave Lore",0,style); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Cave Lore",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].traits[5] == 1) if(cur_rect <= 15) { - win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Woodsman",0,style); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Woodsman",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].traits[6] == 1) if(cur_rect <= 15) { - win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Good Constitution",0,style); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Good Constitution",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].traits[7] == 1) if(cur_rect <= 15) { - win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Highly Alert",0,style); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Highly Alert",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].traits[8] == 1) if(cur_rect <= 15) { - win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Exceptional Str.",0,style); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Exceptional Str.",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].traits[9] == 1) if(cur_rect <= 15) { - win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Recuperation",0,style); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Recuperation",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].traits[10] == 1) if(cur_rect <= 15) { - win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Sluggish",0,style); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Sluggish",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].traits[11] == 1) if(cur_rect <= 15) { - win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Magically Inept",0,style); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Magically Inept",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].traits[12] == 1) if(cur_rect <= 15) { - win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Frail",0,style); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Frail",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].traits[13] == 1) if(cur_rect <= 15) { - win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Chronic Disease",0,style); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Chronic Disease",eTextMode::WRAP,style); cur_rect++; } if (univ.party[i].traits[14] == 1) if(cur_rect <= 15) { - win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Bad Back",0,style); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Bad Back",eTextMode::WRAP,style); cur_rect++; } style.lineHeight = 10; @@ -695,7 +695,7 @@ void display_party() style.colour = sf::Color::White; style.pointSize = 9; style.font = FONT_PLAIN; - win_draw_string(mainPtr,pc_area_buttons[i][3],"Alive ",1,style); + win_draw_string(mainPtr,pc_area_buttons[i][3],"Alive ",eTextMode::CENTRE,style); style.font = FONT_BOLD; style.pointSize = 10; break; @@ -703,7 +703,7 @@ void display_party() style.colour = sf::Color::White; style.pointSize = 9; style.font = FONT_PLAIN; - win_draw_string(mainPtr,pc_area_buttons[i][3],"Dead ",1,style); + win_draw_string(mainPtr,pc_area_buttons[i][3],"Dead ",eTextMode::CENTRE,style); style.font = FONT_BOLD; style.pointSize = 10; break; @@ -711,7 +711,7 @@ void display_party() style.colour = sf::Color::White; style.pointSize = 9; style.font = FONT_PLAIN; - win_draw_string(mainPtr,pc_area_buttons[i][3],"Dust ",1,style); + win_draw_string(mainPtr,pc_area_buttons[i][3],"Dust ",eTextMode::CENTRE,style); style.font = FONT_BOLD; style.pointSize = 10; break; @@ -719,7 +719,7 @@ void display_party() style.colour = sf::Color::White; style.pointSize = 9; style.font = FONT_PLAIN; - win_draw_string(mainPtr,pc_area_buttons[i][3],"Stone ",1,style); + win_draw_string(mainPtr,pc_area_buttons[i][3],"Stone ",eTextMode::CENTRE,style); style.font = FONT_BOLD; style.pointSize = 10; break; @@ -727,7 +727,7 @@ void display_party() style.colour = sf::Color::White; style.pointSize = 9; style.font = FONT_PLAIN; - win_draw_string(mainPtr,pc_area_buttons[i][3],"Fled ",1,style); + win_draw_string(mainPtr,pc_area_buttons[i][3],"Fled ",eTextMode::CENTRE,style); style.font = FONT_BOLD; style.pointSize = 10; break; @@ -735,7 +735,7 @@ void display_party() style.colour = sf::Color::White; style.pointSize = 9; style.font = FONT_PLAIN; - win_draw_string(mainPtr,pc_area_buttons[i][3],"Surface ",1,style); + win_draw_string(mainPtr,pc_area_buttons[i][3],"Surface ",eTextMode::CENTRE,style); style.font = FONT_BOLD; style.pointSize = 10; break; @@ -743,7 +743,7 @@ void display_party() style.colour = sf::Color::White; style.pointSize = 9; style.font = FONT_PLAIN; - win_draw_string(mainPtr,pc_area_buttons[i][3],"Absent ",1,style); + win_draw_string(mainPtr,pc_area_buttons[i][3],"Absent ",eTextMode::CENTRE,style); style.font = FONT_BOLD; style.pointSize = 10; break; @@ -763,19 +763,19 @@ void display_party() style.colour = sf::Color::White; switch(i) { case 0: - win_draw_string(mainPtr,edit_rect[0][1]," Add|Mage|Spells",0,style); + win_draw_string(mainPtr,edit_rect[0][1]," Add|Mage|Spells",eTextMode::WRAP,style); break; case 1: - win_draw_string(mainPtr,edit_rect[1][1]," Add|Priest|Spells",0,style); + win_draw_string(mainPtr,edit_rect[1][1]," Add|Priest|Spells",eTextMode::WRAP,style); break; case 2: - win_draw_string(mainPtr,edit_rect[2][1]," Edit|Traits",0,style); + win_draw_string(mainPtr,edit_rect[2][1]," Edit|Traits",eTextMode::WRAP,style); break; case 3: - win_draw_string(mainPtr,edit_rect[3][1]," Edit|Skills",0,style); + win_draw_string(mainPtr,edit_rect[3][1]," Edit|Skills",eTextMode::WRAP,style); break; case 4: - win_draw_string(mainPtr,edit_rect[4][1]," Edit| XP",0,style); + win_draw_string(mainPtr,edit_rect[4][1]," Edit| XP",eTextMode::WRAP,style); break; default: break; @@ -787,7 +787,7 @@ void display_party() RECT dest_rect = title_from; dest_rect.offset(100,60); sprintf(to_draw, " Gold: %d Food: %d ",(short) univ.party.gold, (short) univ.party.food); - win_draw_string(mainPtr,dest_rect,to_draw,0,style); + win_draw_string(mainPtr,dest_rect,to_draw,eTextMode::WRAP,style); } } diff --git a/osx/scenedit/scen.graphics.cpp b/osx/scenedit/scen.graphics.cpp index eb78c851..49f282ed 100644 --- a/osx/scenedit/scen.graphics.cpp +++ b/osx/scenedit/scen.graphics.cpp @@ -465,7 +465,7 @@ void draw_lb_slot (short which,short mode) { if (mode > 0) style.colour = sf::Color::Blue; style.lineHeight = 12; - win_draw_string(mainPtr,text_rect,strings_ls[which],0,style); + win_draw_string(mainPtr,text_rect,strings_ls[which],eTextMode::WRAP,style); } void draw_rb() { @@ -494,7 +494,7 @@ void draw_rb_slot (short which,short mode) { if (mode > 0) style.colour = sf::Color::Red; style.lineHeight = 12; - win_draw_string(mainPtr,text_rect,(char *)strings_rs[which],0,style); + win_draw_string(mainPtr,text_rect,(char *)strings_rs[which],eTextMode::WRAP,style); } void set_up_terrain_buttons() { @@ -1142,13 +1142,13 @@ void place_location() { } TextStyle style; style.lineHeight = 12; - win_draw_string(terrain_buttons_gworld, draw_rect, draw_str, 2, style); + win_draw_string(terrain_buttons_gworld, draw_rect, draw_str, eTextMode::LEFT_TOP, style); moveTo = location(260 ,terrain_rects[255].top + 26); draw_rect = text_rect; draw_rect.offset(moveTo); sprintf((char*)draw_str,"%i",current_terrain_type); - win_draw_string(terrain_buttons_gworld, draw_rect, draw_str, 2, style); + win_draw_string(terrain_buttons_gworld, draw_rect, draw_str, eTextMode::LEFT_TOP, style); erase_rect.left = 2; erase_rect.right = RIGHT_AREA_WIDTH - 1; @@ -1160,11 +1160,11 @@ void place_location() { moveTo = location(5,terrain_rects[255].bottom + 129); draw_rect = text_rect; draw_rect.offset(moveTo); - win_draw_string(terrain_buttons_gworld, draw_rect, current_string, 2, style); + win_draw_string(terrain_buttons_gworld, draw_rect, current_string, eTextMode::LEFT_TOP, style); moveTo = location(RIGHT_AREA_WIDTH / 2,terrain_rects[255].bottom + 129); draw_rect = text_rect; draw_rect.offset(moveTo); - win_draw_string(terrain_buttons_gworld, draw_rect, current_string2, 2, style); + win_draw_string(terrain_buttons_gworld, draw_rect, current_string2, eTextMode::LEFT_TOP, style); } draw_rect.top = palette_buttons[0][0].top + terrain_rects[255].bottom + 5; @@ -1232,7 +1232,7 @@ void place_just_location() { } TextStyle style; style.lineHeight = 12; - win_draw_string(terrain_buttons_gworld, draw_rect, draw_str, 2, style); + win_draw_string(terrain_buttons_gworld, draw_rect, draw_str, eTextMode::LEFT_TOP, style); from_rect = terrain_buttons_rect; from_rect.top = erase_rect.top; diff --git a/osx/tools/graphtool.cpp b/osx/tools/graphtool.cpp index d004bee8..38e93573 100644 --- a/osx/tools/graphtool.cpp +++ b/osx/tools/graphtool.cpp @@ -193,24 +193,33 @@ void TextStyle::applyTo(sf::Text& text) { text.setColor(colour); } -// mode: 0 - align up and left, 1 - center on one line -// str is a c string, 256 characters -// uses current font -// TODO: Make an enum for the mode parameter -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; +struct text_params_t { + TextStyle style; + eTextMode mode; + location offset = {0,0}; +}; + +void win_draw_string(sf::RenderTarget& dest_window,RECT dest_rect,std::string str,text_params_t options); + +void win_draw_string(sf::RenderTarget& dest_window,RECT dest_rect,std::string str,eTextMode mode,TextStyle style, location offset) { + text_params_t params; + params.mode = mode; + params.style = style; + params.offset = offset; + win_draw_string(dest_window, dest_rect, str, params); +} + +void win_draw_string(sf::RenderTarget& dest_window,RECT dest_rect,std::string str,text_params_t options) { + short line_height = options.style.lineHeight; sf::Text str_to_draw; - style.applyTo(str_to_draw); + options.style.applyTo(str_to_draw); short str_len,i; short last_line_break = 0,last_word_break = 0; short total_width = 0; - //bool /*end_loop,*/force_skip = false; - //KeyMap key_state; - //RgnHandle current_clip; short adjust_x = 0,adjust_y = 0; - adjust_x = offset.x; - adjust_y = offset.y; + adjust_x = options.offset.x; + adjust_y = options.offset.y; str_to_draw.setString("fj"); // Something that has both an ascender and a descender adjust_y -= str_to_draw.getLocalBounds().height; @@ -220,14 +229,12 @@ void win_draw_string(sf::RenderTarget& dest_window,RECT dest_rect,std::string st return; } - //current_clip = NewRgn(); - //GetClip(current_clip); - + eTextMode mode = options.mode; total_width = str_to_draw.getLocalBounds().width; - if ((mode == 0) && (total_width < dest_rect.width())) - mode = 2; - if(mode == 2 && str.find('|') != std::string::npos) - mode = 0; + if(mode == eTextMode::WRAP && total_width < dest_rect.width()) + mode = eTextMode::LEFT_TOP; + if(mode == eTextMode::LEFT_TOP && str.find('|') != std::string::npos) + mode = eTextMode::WRAP; auto text_len = [&str_to_draw](size_t i) -> int { return str_to_draw.findCharacterPos(i).x; @@ -237,72 +244,52 @@ void win_draw_string(sf::RenderTarget& dest_window,RECT dest_rect,std::string st line_height -= 2; switch (mode) { - case 0: // Wrapped + case eTextMode::WRAP: moveTo = location(dest_rect.left + 1 + adjust_x, dest_rect.top + 1 + adjust_y + 9); for(i = 0; text_len(i) != text_len(i + 1) && i < str_len;i++) { if(((text_len(i) - text_len(last_line_break) > (dest_rect.width() - 6)) && (last_word_break > last_line_break)) || (str[i] == '|')) { if(str[i] == '|') { str[i] = ' '; - //force_skip = true; last_word_break = i + 1; } size_t amount = last_word_break - last_line_break - 1; sf::Text line_to_draw(str_to_draw); line_to_draw.setString(str.substr(last_line_break,amount)); - //sprintf((char *)str_to_draw2," %s",str_to_draw); - //str_to_draw2[0] = (char) strlen((char *)str_to_draw); - //DrawString(str_to_draw2); line_to_draw.setPosition(moveTo); dest_window.draw(line_to_draw); moveTo.y += line_height; last_line_break = last_word_break; - //if (force_skip) { - //force_skip = false; - //i++; - //last_line_break++; - //last_word_break++; - //} } if(str[i] == ' ') last_word_break = i + 1; -// if (on_what_line == LINES_IN_TEXT_WIN - 1) -// i = 10000; } if (i - last_line_break > 1) { str_to_draw.setPosition(moveTo); str_to_draw.setString(str.substr(last_line_break)); - //sprintf((char *)str_to_draw2," %s",str_to_draw); - //if (strlen((char *) str_to_draw2) > 3) { - // str_to_draw2[0] = (char) strlen((char *)str_to_draw); - // DrawString(str_to_draw2); - //} if(str_to_draw.getString().getSize() > 2){ dest_window.draw(str_to_draw); } } break; - case 1: // Centred? + case eTextMode::CENTRE: moveTo = location((dest_rect.right + dest_rect.left) / 2 - (4 * total_width) / 9 + adjust_x, (dest_rect.bottom + dest_rect.top - line_height) / 2 + 9 + adjust_y); str_to_draw.setPosition(moveTo); dest_window.draw(str_to_draw); break; - case 2: // Align left and top? + case eTextMode::LEFT_TOP: moveTo = location(dest_rect.left + 1 + adjust_x, dest_rect.top + 1 + adjust_y + 9); str_to_draw.setPosition(moveTo); dest_window.draw(str_to_draw); break; - case 3: // Align left and bottom? + case eTextMode::LEFT_BOTTOM: moveTo = location(dest_rect.left + 1 + adjust_x, dest_rect.top + 1 + adjust_y + 9 + dest_rect.height() / 6); str_to_draw.setPosition(moveTo); dest_window.draw(str_to_draw); break; } - //SetClip(current_clip); - //DisposeRgn(current_clip); - //printf("String drawn.\n"); } short string_length(std::string str, TextStyle style){ diff --git a/osx/tools/graphtool.h b/osx/tools/graphtool.h index cd96c46c..17330bf6 100644 --- a/osx/tools/graphtool.h +++ b/osx/tools/graphtool.h @@ -77,12 +77,19 @@ struct cCustomGraphics { size_t count(); }; +enum class eTextMode { + WRAP, + CENTRE, + LEFT_TOP, + LEFT_BOTTOM, +}; + void init_graph_tool(); 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,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 win_draw_string(sf::RenderTarget& dest_window,RECT dest_rect,std::string str,short mode,TextStyle style,location offset = {0,0}); +void win_draw_string(sf::RenderTarget& dest_window,RECT dest_rect,std::string str,eTextMode mode,TextStyle style, location offset = {0,0}); 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); //void draw_terrain();