Several tweaks/fixes

- Nuke some uses of strcpy, sprintf, etc; current info strings in the scenario editor are now stored as std::string instead of C-strings.
- A smarter method of calculating the "erase" terrain for a given terrain type. In case of impassable spaces, trims, and walkways, instead of using the ground terrain, the trim terrain (if any) is used as the erase terrain; if there's no trim, ground 0 (cave, by default) is used. The method of determining if two terrains are essentially the same (ie, whether to paint or erase) has also been improved a little.
- Also, to reduce confusion, the erase terrain is now shown beneath the paint terrain.

Terrain changes:
- Add "archetype" flag as a better way of determining which amongst a set of terrains sharing the same ground type should be considered as the most basic terrain of that ground type. It's automatically applied to any terrains using original graphics when importing an old scenario; generally, any with no terrain special will be marked as an archetype, but if the lava graphic was used, it's instead any with a terrain special. It's a crude method that may easily break, but probably not possible to do better.
- When importing old scenarios, set the two walkways to be separate ground types while the crops should have grass as their ground, and the conveyors have cave.
- Fix fly, boat, block horse LEDs not being cleared if a terrain lacks that flag when using the arrow buttons. This could lead to terrains accidentally picking up the flags of nearby terrains in the list.
- Fix the block horse flag was not correctly saved when closing the dialog.
- Fix the block horse flag not being correctly loaded from the scenario file
This commit is contained in:
2015-06-11 22:32:28 -04:00
parent 21291e168c
commit a990921e90
13 changed files with 171 additions and 149 deletions

View File

@@ -54,6 +54,11 @@ lit, a flying party can pass over this terrain.</li>
<li><b>Can Boat Over - </b>If this light is lit, a party in a boat can pass over this
terrain.</li>
<li><b>Block Horses -</b> If this light is lit, horses will not walk on this terrain.</li>
<li><b>Archetype -</b> This specifies that the terrain is the archetype of its ground
type. Ideally, exactly one archetype should exist for each ground type. However, should
you accidentally mark two archetypes for one ground type, or forget to mark one, the game
treats the first matching terrain as the archetype (if any are marked, the first one
marked; otherwise, the first one with the ground type).
<li><b>Step Sound -</b> The sound that plays when something steps on this terrain. Current
options are a regular stepping sound, a squish, a crunch, or nothing.</li>
<li><b>Shortcut Key -</b> This is a shortcut for you when editing your towns and dungeons.

View File

@@ -27,6 +27,7 @@
<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='bold'>Can boat over?</led>
<led name='horse' top='150' left='307' state='off' width='120' font='bold'>Blocked to horses?</led>
<led name='arch' top='150' left='447' state='off' width='120' font='bold'>Archetype?</led>
<text top='165' left='8' height='14' width='91'>Step sound:</text>
<group name='sound'>
<led name="step" top='167' left='102' state='off' width='60'>Footstep</led>

View File

@@ -153,6 +153,7 @@
<xs:element name="fly" minOccurs="0" type="bool"/>
<xs:element name="boat" minOccurs="0" type="bool"/>
<xs:element name="ride" minOccurs="0" type="bool"/>
<xs:element name="archetype" minOccurs="0" type="bool"/>
<xs:element name="light" minOccurs="0" type="xs:integer"/>
<xs:element name="step-sound" minOccurs="0" type="stepSound"/>
<xs:element name="trim" type="terTrim"/>

View File

@@ -195,10 +195,15 @@ ter_num_t cScenario::get_ground_from_ter(ter_num_t ter){
}
ter_num_t cScenario::get_ter_from_ground(unsigned short ground){
ter_num_t archetype = -1;
for(int i = 0; i < ter_types.size(); i++)
if(ter_types[i].ground_type == ground)
return i;
return 0;
if(ter_types[i].ground_type == ground) {
if(ter_types[i].is_archetype)
return i;
else if(archetype < 0)
archetype = i;
}
return std::max(archetype, ter_num_t());
}
ter_num_t cScenario::get_trim_terrain(unsigned short ground, unsigned short trim_g, eTrimType trim) {

View File

@@ -18,6 +18,16 @@
#include "boe.consts.hpp" // TODO: Put these constants in a global file
void cTerrain::append(legacy::terrain_type_type& old){
static const std::set<int> archetypes = {
// This lists graphics that represent the archetypal terrains for each ground type
// One line per graphics sheet; last line is the animated sheet
0, 2, 5, 18, 32, 46,
74, 88,
100, 110, 123,
157, 163,
215, 216,
400, 404,
};
static const short arenas[274] = {
1, 1, 0, 0, 0, 1, 1, 1, 1, 1, // 0 - grassy field
1, 1, 1, 1, 1, 1, 1, 1, 2, 2, // 1 - ordinary cave
@@ -58,11 +68,11 @@ void cTerrain::append(legacy::terrain_type_type& old){
12,0, 0, 13,13,13,13,13,13,13, 13,13,13,13,13,13,13,13,13,13,
13,13,13,13,13,13,13,13,13,13, 13,13,13,13,13,13,13,14,14,14,
14,14,14,15,15,15,15,15,15,15, 15,15,15,15,15,15,15,15,0, 0,
0, 16,0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 3, 3, 3, 3, 1, 1, 1, 1,
1, 1, 0, 1, 4, 1, 1, 0, 13,14, 15,1, 4, 13,13,17,17,0, 17,17,
17,17,17,17,17,17,0, 1, 18,19, 13,20,0, 13,0, 0, 0, 0, 0, 0,
0, 1 ,0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 3, 3, 3, 3, 1, 1, 1, 1,
1, 1, 0, 1, 4, 1, 1, 0, 13,14, 15,1, 4, 13,13,16,17,0, 16,16,
16,16,17,17,17,17,0, 1, 18,19, 13,20,0, 13,0, 0, 0, 0, 0, 0,
2, 2, 2, 2, 0, 0, 15,15,15,15, 15,13,13,1, 1, 1, 1, 1, 1, 4,
6, 6, 6, 6, 7, 6, 0, 21,22,23, 24,0, 13,13
6, 6, 6, 6, 7, 6, 0, 0, 0, 0, 0, 0, 13,13
};
static const short trims[274] = {
0, 0, 0, 0, 0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,0, 0,
@@ -97,6 +107,8 @@ void cTerrain::append(legacy::terrain_type_type& old){
99,99,99,99,99,2, 99,99,99,99, 99,99,99,99,
};
picture = old.picture;
// This is a weird expression, but necessary, because all archetypes except lava lack a special ability
is_archetype = archetypes.count(picture) && (old.special == 0) == (old.picture != 404);
blockage = (eTerObstruct) old.blockage;
if(picture < 260){
combat_arena = arenas[picture];

View File

@@ -32,6 +32,7 @@ public:
bool fly_over = false;
bool boat_over = false;
bool block_horse = false;
bool is_archetype = false;
unsigned int light_radius = 0;
eStepSnd step_sound = eStepSnd::STEP;
unsigned char shortcut_key = 0; // for editor use only

View File

@@ -24,7 +24,7 @@
#include "scen.btnmg.hpp"
extern char current_string[256];
extern std::string current_string[2];
extern short mini_map_scales[3];
extern eDrawMode draw_mode;
rectangle world_screen;
@@ -94,6 +94,7 @@ ter_num_t current_ground = 0;
short special_to_paste = -1;
bool monst_on_space(location loc,short m_num);
static bool terrain_matches(unsigned char x, unsigned char y, ter_num_t ter);
void init_current_terrain() {
// short i,j;
@@ -765,7 +766,7 @@ static bool handle_terrain_action(location the_point, bool ctrl_hit) {
case 0:
overall_mode = MODE_DRAWING;
set_cursor(wand_curs);
set_string("Drawing mode",(char*)scenario.ter_types[current_terrain_type].name.c_str());
set_string("Drawing mode",scenario.ter_types[current_terrain_type].name);
break;
}
break;
@@ -806,7 +807,7 @@ static bool handle_terrain_action(location the_point, bool ctrl_hit) {
overall_mode = MODE_DRAWING;
set_cursor(wand_curs);
set_string("Drawing mode",(char*)scenario.ter_types[current_terrain_type].name.c_str());
set_string("Drawing mode",scenario.ter_types[current_terrain_type].name);
break;
case MODE_EDIT_ITEM:
for(x = 0; x < town->preset_items.size(); x++)
@@ -1129,7 +1130,7 @@ static bool handle_terrain_action(location the_point, bool ctrl_hit) {
break; // Nothing to do here, of course.
}
if((overall_mode == MODE_DRAWING) && (old_mode != MODE_DRAWING))
set_string("Drawing mode",(char*)scenario.ter_types[current_terrain_type].name.c_str());
set_string("Drawing mode",scenario.ter_types[current_terrain_type].name);
draw_terrain();
return true;
}
@@ -1191,14 +1192,14 @@ static bool handle_terpal_action(location cur_point, bool option_hit) {
}
overall_mode = MODE_PLACE_ITEM;
mode_count = k;
set_string("Place the item:",scenario.scen_items[mode_count].full_name.c_str());
set_string("Place the item:",scenario.scen_items[mode_count].full_name);
break;
case DRAW_MONST:
if(k + 1 >= scenario.scen_monsters.size())
break;
overall_mode = MODE_PLACE_CREATURE;
mode_count = k + 1;
set_string("Place the monster:",scenario.scen_monsters[mode_count].m_name.c_str());
set_string("Place the monster:",scenario.scen_monsters[mode_count].m_name);
break;
}
}
@@ -1248,27 +1249,27 @@ static bool handle_toolpal_action(location cur_point2) {
switch(cur_palette_buttons[j][i]) {
case PAL_BLANK: break;
case PAL_PENCIL:
set_string("Drawing mode",(char*)scenario.ter_types[current_terrain_type].name.c_str());
set_string("Drawing mode",scenario.ter_types[current_terrain_type].name);
overall_mode = MODE_DRAWING;
set_cursor(wand_curs);
break;
case PAL_BRUSH_LG:
set_string("Paintbrush (large)",(char*)scenario.ter_types[current_terrain_type].name.c_str());
set_string("Paintbrush (large)",scenario.ter_types[current_terrain_type].name);
overall_mode = MODE_LARGE_PAINTBRUSH;
set_cursor(brush_curs);
break;
case PAL_BRUSH_SM:
set_string("Paintbrush (small)",(char*)scenario.ter_types[current_terrain_type].name.c_str());
set_string("Paintbrush (small)",scenario.ter_types[current_terrain_type].name);
set_cursor(brush_curs);
overall_mode = MODE_SMALL_PAINTBRUSH;
break;
case PAL_SPRAY_LG:
set_string("Spraycan (large)",(char*)scenario.ter_types[current_terrain_type].name.c_str());
set_string("Spraycan (large)",scenario.ter_types[current_terrain_type].name);
set_cursor(spray_curs);
overall_mode = MODE_LARGE_SPRAYCAN;
break;
case PAL_SPRAY_SM:
set_string("Spraycan (small)",(char*)scenario.ter_types[current_terrain_type].name.c_str());
set_string("Spraycan (small)",scenario.ter_types[current_terrain_type].name);
set_cursor(spray_curs);
overall_mode = MODE_SMALL_SPRAYCAN;
break;
@@ -1620,12 +1621,16 @@ void swap_terrain() {
void set_new_terrain(ter_num_t selected_terrain) {
if(selected_terrain >= scenario.ter_types.size()) return;
current_terrain_type = selected_terrain;
// if(selected_terrain < 2)
// current_ground = 0;
// else if(selected_terrain < 5)
// current_ground = 2;
current_ground = get_ground_from_ter(selected_terrain);
set_string((char*)current_string,(char*)scenario.ter_types[current_terrain_type].name.c_str());
current_ground = scenario.get_ground_from_ter(selected_terrain);
cTerrain& ter = scenario.ter_types[current_terrain_type];
cTerrain& gter = scenario.ter_types[current_ground];
if(gter.blockage >= eTerObstruct::BLOCK_MOVE || ter.trim_type == eTrimType::WALKWAY || /*current_ground == current_terrain_type ||*/
(ter.trim_type >= eTrimType::S && ter.trim_type <= eTrimType::NW_INNER)) {
long trim = scenario.ter_types[current_ground].trim_ter;
if(trim < 0) current_ground = 0;
else current_ground = scenario.get_ter_from_ground(trim);
}
set_string(current_string[0],scenario.ter_types[current_terrain_type].name);
}
void handle_keystroke(sf::Event event) {
@@ -1777,6 +1782,7 @@ void handle_keystroke(sf::Event event) {
j = j % 256;
if(scenario.ter_types[j].shortcut_key == chr) {
set_new_terrain(j);
place_location();
i = 256;
}
}
@@ -1915,15 +1921,7 @@ static ter_num_t find_object_part(unsigned char num, short x, short y, ter_num_t
return fallback;
}
ter_num_t get_ground_from_ter(ter_num_t ter){
unsigned char ground = scenario.ter_types[ter].ground_type;
for(int i = 0; i < scenario.ter_types.size(); i++)
if(scenario.ter_types[i].ground_type == ground)
return i;
return 0;
}
bool terrain_matches(unsigned char x, unsigned char y, ter_num_t ter){
bool terrain_matches(unsigned char x, unsigned char y, ter_num_t ter) {
ter_num_t ter2;
if(editing_town) ter2 = town->terrain(x,y); else ter2 = current_terrain->terrain[x][y];
if(ter2 == ter) return true;
@@ -1932,16 +1930,16 @@ bool terrain_matches(unsigned char x, unsigned char y, ter_num_t ter){
if(scenario.ter_types[ter].trim_type == eTrimType::NONE &&
scenario.ter_types[ter2].trim_type >= eTrimType::S &&
scenario.ter_types[ter2].trim_type <= eTrimType::NW_INNER)
return ter == get_ground_from_ter(ter);
return ter == scenario.get_ground_from_ter(ter);
if(scenario.ter_types[ter2].trim_type == eTrimType::NONE &&
scenario.ter_types[ter].trim_type >= eTrimType::S &&
scenario.ter_types[ter].trim_type <= eTrimType::NW_INNER)
return ter2 == get_ground_from_ter(ter2);
return ter2 == scenario.get_ground_from_ter(ter2);
if(scenario.ter_types[ter2].trim_type >= eTrimType::S &&
scenario.ter_types[ter2].trim_type <= eTrimType::NW_INNER &&
scenario.ter_types[ter].trim_type >= eTrimType::S &&
scenario.ter_types[ter].trim_type <= eTrimType::NW_INNER)
return true;
return scenario.ter_types[ter].trim_type != scenario.ter_types[ter2].trim_type;
return false;
}
@@ -2450,7 +2448,7 @@ void start_town_edit() {
shut_down_menus(2);
right_sbar->hide();
pal_sbar->show();
set_string("Drawing mode",(char*)scenario.ter_types[current_terrain_type].name.c_str());
set_string("Drawing mode",scenario.ter_types[current_terrain_type].name);
place_location();
copied_spec = -1;
for(i = 0; i < town->max_dim(); i++)
@@ -2482,7 +2480,7 @@ void start_out_edit() {
shut_down_menus(4);
shut_down_menus(1);
redraw_screen();
set_string("Drawing mode",(char*)scenario.ter_types[current_terrain_type].name.c_str());
set_string("Drawing mode",scenario.ter_types[current_terrain_type].name);
place_location();
copied_spec = -1;
for(i = 0; i < 48; i++)

View File

@@ -46,5 +46,3 @@ void place_edit_special(location loc);
void set_special(location spot_hit);
bool save_check(std::string which_dlog);
ter_num_t get_ground_from_ter(ter_num_t ter);
bool terrain_matches(unsigned char x, unsigned char y, ter_num_t ter);

View File

@@ -119,7 +119,8 @@ static bool save_ter_info(cDialog& me, cTerrain& ter) {
ter.trans_to_what = me["trans"].getTextAsNum();
ter.fly_over = dynamic_cast<cLed&>(me["flight"]).getState() == led_red;
ter.boat_over = dynamic_cast<cLed&>(me["boat"]).getState() == led_red;
ter.block_horse = dynamic_cast<cLed&>(me["horse"]).getState();
ter.block_horse = dynamic_cast<cLed&>(me["horse"]).getState() == led_red;
ter.is_archetype = dynamic_cast<cLed&>(me["arch"]).getState() == led_red;
ter.light_radius = me["light"].getTextAsNum();
std::string sound = dynamic_cast<cLedGroup&>(me["sound"]).getSelected();
@@ -412,18 +413,10 @@ static void fill_ter_info(cDialog& me, short ter){
break;
}
}
if(ter_type.fly_over){
cLed& led_ctrl = dynamic_cast<cLed&>(me["flight"]);
led_ctrl.setState(led_red);
}
if(ter_type.boat_over){
cLed& led_ctrl = dynamic_cast<cLed&>(me["boat"]);
led_ctrl.setState(led_red);
}
if(ter_type.block_horse){
cLed& led_ctrl = dynamic_cast<cLed&>(me["horse"]);
led_ctrl.setState(led_red);
}
dynamic_cast<cLed&>(me["flight"]).setState(ter_type.fly_over ? led_red : led_off);
dynamic_cast<cLed&>(me["boat"]).setState(ter_type.boat_over ? led_red : led_off);
dynamic_cast<cLed&>(me["horse"]).setState(ter_type.block_horse ? led_red : led_off);
dynamic_cast<cLed&>(me["arch"]).setState(ter_type.is_archetype ? led_red : led_off);
me["flag1"].setTextToNum(ter_type.flag1);
me["flag2"].setTextToNum(ter_type.flag2);
me["flag3"].setTextToNum(ter_type.flag3);

View File

@@ -356,6 +356,7 @@ static void writeTerrainToXml(ticpp::Printer&& data) {
data.PushElement("fly", ter.fly_over);
data.PushElement("boat", ter.boat_over);
data.PushElement("ride", !ter.block_horse);
data.PushElement("archetype", ter.is_archetype);
data.PushElement("light", ter.light_radius);
data.PushElement("step-sound", ter.step_sound);
data.PushElement("trim", ter.trim_type);

View File

@@ -25,7 +25,6 @@ void load_main_screen();
void load_terrain_template();
short terrain_in_index();
void put_terrain_in_template();
void place_location();
void undo_clip();
short find_index_spot();
@@ -56,6 +55,7 @@ short mini_map_scales[3] = {12, 6, 4};
// TODO: What is this for?
//extern btn_t buttons[];
extern location cur_out, mouse_spot;
extern ter_num_t current_ground;
short num_ir[3] = {12,10,4};
@@ -95,8 +95,7 @@ extern rectangle left_buttons[NLS][2]; // 0 - whole, 1 - blue button
rectangle left_button_base = {5,5,21,280};
rectangle right_button_base = {RIGHT_AREA_UL_Y,RIGHT_AREA_UL_X,17,RIGHT_AREA_UL_Y};
rectangle terrain_rect = {0,0,340,272};
char current_string[256] = "";
char current_string2[256] = "";
std::string current_string[2];
extern rectangle terrain_rects[256];
short map_pats[220] = {50,50,1,1,1,6,6,6,6,6,
@@ -1300,9 +1299,40 @@ void draw_frames() {
}
static void place_selected_terrain(ter_num_t ter, rectangle draw_rect) {
pic_num_t picture_wanted = scenario.ter_types[ter].picture;
rectangle source_rect;
if(picture_wanted >= 1000) {
sf::Texture* source_gworld;
graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted % 1000);
rect_draw_some_item(*source_gworld,
source_rect,terrain_buttons_gworld,draw_rect);
}
else if(picture_wanted >= 960) {
picture_wanted -= 960;
source_rect.left = 112 * (picture_wanted / 5);
source_rect.right = source_rect.left + 28;
source_rect.top = 36 * (picture_wanted % 5);
source_rect.bottom = source_rect.top + 36;
rect_draw_some_item(anim_gworld,source_rect,terrain_buttons_gworld,draw_rect);
}
else {
source_rect = get_template_rect(ter);
rect_draw_some_item(terrain_gworld[picture_wanted / 50],source_rect,
terrain_buttons_gworld,draw_rect);
}
short small_i = get_small_icon(ter);
rectangle tiny_to = draw_rect;
tiny_to.top = tiny_to.bottom - 7;
tiny_to.left = tiny_to.right - 7;
rectangle tiny_from = base_small_button_from;
tiny_from.offset(7 * (small_i % 10),7 * (small_i / 10));
if(small_i > 0 && small_i < 255)
rect_draw_some_item(editor_mixed,tiny_from,terrain_buttons_gworld,tiny_to);
}
void place_location() {
char draw_str[256];
std::ostringstream sout;
rectangle draw_rect,source_rect,erase_rect;
rectangle text_rect = {0,0,12,100};
short picture_wanted;
@@ -1317,20 +1347,22 @@ void place_location() {
draw_rect = text_rect;
draw_rect.offset(moveTo);
if(overall_mode < MODE_MAIN_SCREEN)
sprintf((char *) draw_str,"Center: x = %d, y = %d ",cen_x,cen_y);
sout << "Center: x = " << cen_x << ", y = " << cen_y;
else {
moveTo.y += 13; // TODO: Not sure how important this is.
sprintf((char *) draw_str,"Click terrain to edit. ");
sout << "Click terrain to edit. ";
}
TextStyle style;
style.lineHeight = 12;
win_draw_string(terrain_buttons_gworld, draw_rect, draw_str, eTextMode::LEFT_TOP, style);
win_draw_string(terrain_buttons_gworld, draw_rect, sout.str(), eTextMode::LEFT_TOP, style);
sout.str("");
moveTo = location(260 ,terrain_rects[255].top + 15);
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, eTextMode::LEFT_TOP, style);
sout << current_terrain_type;
win_draw_string(terrain_buttons_gworld, draw_rect, sout.str(), eTextMode::LEFT_TOP, style);
sout.str("");
erase_rect.left = 2;
erase_rect.right = RIGHT_AREA_WIDTH - 1;
@@ -1342,141 +1374,115 @@ void place_location() {
moveTo = location(5,terrain_rects[255].bottom + 118);
draw_rect = text_rect;
draw_rect.offset(moveTo);
win_draw_string(terrain_buttons_gworld, draw_rect, current_string, eTextMode::LEFT_TOP, style);
win_draw_string(terrain_buttons_gworld, draw_rect, current_string[0], eTextMode::LEFT_TOP, style);
moveTo = location(RIGHT_AREA_WIDTH / 2,terrain_rects[255].bottom + 118);
draw_rect = text_rect;
draw_rect.offset(moveTo);
win_draw_string(terrain_buttons_gworld, draw_rect, current_string2, eTextMode::LEFT_TOP, style);
win_draw_string(terrain_buttons_gworld, draw_rect, current_string[1], eTextMode::LEFT_TOP, style);
}
draw_rect.top = palette_buttons[0][0].top + terrain_rects[255].bottom + 5;
draw_rect.left = palette_buttons[9][0].right + 10; // + 17;
draw_rect.bottom = draw_rect.top + 36;
draw_rect.right = draw_rect.left + 28;
picture_wanted = scenario.ter_types[current_terrain_type].picture;
if(overall_mode < MODE_MAIN_SCREEN) {
if(picture_wanted >= 1000) {
sf::Texture* source_gworld;
graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted % 1000);
rect_draw_some_item(*source_gworld,
source_rect,terrain_buttons_gworld,draw_rect);
}
else if(picture_wanted >= 960) {
picture_wanted -= 960;
source_rect.left = 112 * (picture_wanted / 5);
source_rect.right = source_rect.left + 28;
source_rect.top = 36 * (picture_wanted % 5);
source_rect.bottom = source_rect.top + 36;
rect_draw_some_item(anim_gworld,source_rect,terrain_buttons_gworld,draw_rect);
}
else {
source_rect = get_template_rect(current_terrain_type);
rect_draw_some_item(terrain_gworld[picture_wanted / 50],source_rect,
terrain_buttons_gworld,draw_rect);
}
short small_i = get_small_icon(current_terrain_type);
rectangle tiny_to = draw_rect;
tiny_to.top = tiny_to.bottom - 7;
tiny_to.left = tiny_to.right - 7;
rectangle tiny_from = base_small_button_from;
tiny_from.offset(7 * (small_i % 10),7 * (small_i / 10));
if(small_i > 0 && small_i < 255)
rect_draw_some_item(editor_mixed,tiny_from,terrain_buttons_gworld,tiny_to);
place_selected_terrain(current_terrain_type, draw_rect);
if(overall_mode == MODE_PLACE_CREATURE || overall_mode == MODE_PLACE_SAME_CREATURE) {
rectangle to_rect = draw_rect;
extern short mode_count;
picture_wanted = scenario.scen_monsters[mode_count].picture_num;
if(picture_wanted >= 4000) {
picture_wanted %= 1000;
tiny_to.width() = tiny_to.width() / 2;
tiny_to.height() = tiny_to.height() / 2;
to_rect.width() = to_rect.width() / 2;
to_rect.height() = to_rect.height() / 2;
sf::Texture* source_gworld;
graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted);
rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha);
rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, to_rect, sf::BlendAlpha);
picture_wanted++;
tiny_to.offset(tiny_to.width(), 0);
to_rect.offset(to_rect.width(), 0);
graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted);
rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha);
rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, to_rect, sf::BlendAlpha);
picture_wanted++;
tiny_to.offset(-tiny_to.width(), tiny_to.height());
to_rect.offset(-to_rect.width(), to_rect.height());
graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted);
rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha);
rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, to_rect, sf::BlendAlpha);
picture_wanted++;
tiny_to.offset(tiny_to.width(), 0);
to_rect.offset(to_rect.width(), 0);
graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted);
rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha);
rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, to_rect, sf::BlendAlpha);
} else if(picture_wanted >= 3000) {
picture_wanted %= 1000;
tiny_to.width() = tiny_to.width() / 2;
tiny_to.height() = tiny_to.height() / 2;
tiny_to.offset(tiny_to.width() / 2, 0);
to_rect.width() = to_rect.width() / 2;
to_rect.height() = to_rect.height() / 2;
to_rect.offset(to_rect.width() / 2, 0);
sf::Texture* source_gworld;
graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted);
rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha);
rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, to_rect, sf::BlendAlpha);
picture_wanted++;
tiny_to.offset(0, tiny_to.height());
to_rect.offset(0, to_rect.height());
graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted);
rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha);
rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, to_rect, sf::BlendAlpha);
} else if(picture_wanted >= 2000) {
picture_wanted %= 1000;
tiny_to.width() = tiny_to.width() / 2;
tiny_to.height() = tiny_to.height() / 2;
tiny_to.offset(0, tiny_to.height() / 2);
to_rect.width() = to_rect.width() / 2;
to_rect.height() = to_rect.height() / 2;
to_rect.offset(0, to_rect.height() / 2);
sf::Texture* source_gworld;
graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted);
rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha);
rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, to_rect, sf::BlendAlpha);
picture_wanted++;
tiny_to.offset(tiny_to.width(), 0);
to_rect.offset(to_rect.width(), 0);
graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted);
rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha);
rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, to_rect, sf::BlendAlpha);
} else if(picture_wanted >= 1000) {
picture_wanted %= 1000;
sf::Texture* source_gworld;
graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted);
rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha);
rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, to_rect, sf::BlendAlpha);
} else {
auto pic_info = m_pic_index[picture_wanted];
picture_wanted = pic_info.i;
if(pic_info.x == 2 && pic_info.y == 2) {
tiny_to.width() = tiny_to.width() / 2;
tiny_to.height() = tiny_to.height() / 2;
to_rect.width() = to_rect.width() / 2;
to_rect.height() = to_rect.height() / 2;
source_rect = calc_rect(2 * ((picture_wanted % 20) / 10), (picture_wanted % 20) % 10);
rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha);
rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, to_rect, sf::BlendAlpha);
picture_wanted++;
tiny_to.offset(tiny_to.width(), 0);
to_rect.offset(to_rect.width(), 0);
source_rect = calc_rect(2 * ((picture_wanted % 20) / 10), (picture_wanted % 20) % 10);
rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha);
rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, to_rect, sf::BlendAlpha);
picture_wanted++;
tiny_to.offset(-tiny_to.width(), tiny_to.height());
to_rect.offset(-to_rect.width(), to_rect.height());
source_rect = calc_rect(2 * ((picture_wanted % 20) / 10), (picture_wanted % 20) % 10);
rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha);
rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, to_rect, sf::BlendAlpha);
picture_wanted++;
tiny_to.offset(tiny_to.width(), 0);
to_rect.offset(to_rect.width(), 0);
source_rect = calc_rect(2 * ((picture_wanted % 20) / 10), (picture_wanted % 20) % 10);
rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha);
rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, to_rect, sf::BlendAlpha);
} else if(pic_info.y == 2) {
tiny_to.width() = tiny_to.width() / 2;
tiny_to.height() = tiny_to.height() / 2;
tiny_to.offset(tiny_to.width() / 2, 0);
to_rect.width() = to_rect.width() / 2;
to_rect.height() = to_rect.height() / 2;
to_rect.offset(to_rect.width() / 2, 0);
source_rect = calc_rect(2 * ((picture_wanted % 20) / 10), (picture_wanted % 20) % 10);
rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha);
rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, to_rect, sf::BlendAlpha);
picture_wanted++;
tiny_to.offset(0, tiny_to.height());
to_rect.offset(0, to_rect.height());
source_rect = calc_rect(2 * ((picture_wanted % 20) / 10), (picture_wanted % 20) % 10);
rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha);
rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, to_rect, sf::BlendAlpha);
} else if(pic_info.x == 2) {
tiny_to.width() = tiny_to.width() / 2;
tiny_to.height() = tiny_to.height() / 2;
tiny_to.offset(0, tiny_to.height() / 2);
to_rect.width() = to_rect.width() / 2;
to_rect.height() = to_rect.height() / 2;
to_rect.offset(0, to_rect.height() / 2);
source_rect = calc_rect(2 * ((picture_wanted % 20) / 10), (picture_wanted % 20) % 10);
rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha);
rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, to_rect, sf::BlendAlpha);
picture_wanted++;
tiny_to.offset(tiny_to.width(), 0);
to_rect.offset(to_rect.width(), 0);
source_rect = calc_rect(2 * ((picture_wanted % 20) / 10), (picture_wanted % 20) % 10);
rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha);
rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, to_rect, sf::BlendAlpha);
} else {
source_rect = calc_rect(2 * ((picture_wanted % 20) / 10), (picture_wanted % 20) % 10);
rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha);
rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, to_rect, sf::BlendAlpha);
}
}
} else if(overall_mode == MODE_PLACE_ITEM || overall_mode == MODE_PLACE_SAME_ITEM) {
@@ -1490,13 +1496,14 @@ void place_location() {
source_rect = calc_rect(picture_wanted % 5,picture_wanted / 5);
rect_draw_some_item(items_gworld,source_rect,terrain_buttons_gworld,draw_rect,sf::BlendAlpha);
} else {
tiny_to = draw_rect;
tiny_to.inset(5, 9);
tiny_from = {0,0,18,18};
draw_rect.inset(5, 9);
rectangle tiny_from = {0,0,18,18};
tiny_from.offset((picture_wanted % 10) * 18,(picture_wanted / 10) * 18);
rect_draw_some_item(tiny_obj_gworld,tiny_from,terrain_buttons_gworld,tiny_to,sf::BlendAlpha);
rect_draw_some_item(tiny_obj_gworld,tiny_from,terrain_buttons_gworld,draw_rect,sf::BlendAlpha);
}
}
draw_rect.offset(0,40);
place_selected_terrain(current_ground, draw_rect);
}
terrain_buttons_gworld.display();
@@ -1505,13 +1512,9 @@ void place_location() {
rect_draw_some_item(terrain_buttons_gworld.getTexture(),terrain_buttons_rect,mainPtr,draw_rect);
}
void set_string(const char *string,const char *string2) {
strcpy((char *)current_string,string);
// if(strlen(string2) == 0)
// current_string2[0] = 0;
// else
// sprintf((char *)current_string2,"Bob");
strcpy((char *)current_string2,string2);
void set_string(std::string string,std::string string2) {
current_string[0] = string;
current_string[1] = string2;
}
/*

View File

@@ -23,7 +23,7 @@ void Draw_Some_Item(sf::Texture& src_gworld,rectangle src_rect,sf::RenderTarget&
rectangle get_template_rect (unsigned short type_wanted);
void draw_frames();
void place_location();
void set_string(const char *string,const char *string2);
void set_string(std::string string,std::string string2);
bool is_special(short i,short j);
void take_special(short i,short j);
void make_special(short i,short j);

View File

@@ -889,7 +889,11 @@ static void readTerrainFromXml(ticpp::Document&& data, cScenario& scenario) {
} else if(type == "ride") {
ter->GetText(&val);
if(val != "true")
the_ter.block_horse = false;
the_ter.block_horse = true;
} else if(type == "archetype") {
ter->GetText(&val);
if(val == "true")
the_ter.is_archetype = true;
} else if(type == "light") {
ter->GetText(&the_ter.light_radius);
} else if(type == "step-sound") {