Get the scenario, town, and outdoor details dialogs updated for new stuff

- Advanced town details now offers edit buttons to edit the specials immediately

Changes to dialog engine:
- Fix tiny buttons stretching to fill label area
- Fix LEDs stretching if label area is higher than LED button
- Fix LEDs ignoring font setting
This commit is contained in:
2015-01-21 15:59:09 -05:00
parent 2a2e7068d0
commit 41fbd73ef9
13 changed files with 123 additions and 85 deletions

View File

@@ -59,7 +59,6 @@ extern cCustomGraphics spec_scen_g;
// TODO: The duplication of rectangle here shouldn't be necessary...
rectangle boat_rects[4] = {rectangle{0,0,36,28}, rectangle{0,28,36,56},rectangle{0,56,36,84},rectangle{0,84,36,112}};
bool gave_no_g_error = false;
eAmbientSound ambient_sound;
//short dest; // 0 - terrain gworld 1 - screen
// if terrain_to_draw is -1, do black
@@ -696,7 +695,7 @@ void play_ambient_sound(){ // TODO: Maybe add a system for in-town ambient sound
if(overall_mode != MODE_OUTDOORS) return; // ambient sounds are outdoors only at the moment
if(get_ran(1,1,100) > 10) return; // 10% chance per move of playing a sound
short sound_to_play;
switch(ambient_sound){
switch(univ.out->ambient_sound){
case AMBIENT_DRIP:
sound_to_play = get_ran(1,0,1);
play_sound(-drip[sound_to_play]);
@@ -706,7 +705,7 @@ void play_ambient_sound(){ // TODO: Maybe add a system for in-town ambient sound
play_sound(-bird[sound_to_play]);
break;
case AMBIENT_CUSTOM:
sound_to_play = univ.out_sound;
sound_to_play = univ.out->out_sound;
play_sound(-sound_to_play);
break;
case AMBIENT_NONE:

View File

@@ -17,6 +17,7 @@
void cOutdoors::append(legacy::outdoor_record_type& old){
int i,j;
ambient_sound = AMBIENT_NONE;
// Collect a list of unused special nodes, to be used for fixing specials that could be triggered in a boat.
std::vector<int> unused_special_slots;
for(i = 0; i < 60; i++) {

View File

@@ -26,6 +26,13 @@ namespace legacy {
class cScenario;
enum eAmbientSound {
AMBIENT_NONE,
AMBIENT_DRIP,
AMBIENT_BIRD,
AMBIENT_CUSTOM,
};
class cOutdoors {
cScenario& scenario;
public:
@@ -71,6 +78,8 @@ public:
std::array<std::string,90> spec_strs;
std::array<std::string,8> sign_strs;
bool special_spot[48][48];
eAmbientSound ambient_sound;
snd_num_t out_sound;
explicit cOutdoors(cScenario& scenario, bool init_strings = false);
void append(legacy::outdoor_record_type& old);

View File

@@ -42,21 +42,6 @@ class cTown { // formerly town_record_type
protected:
cScenario& scenario;
public:
// class cCreature { // formerly creature_start_type
// public:
// unsigned short number;
// unsigned char start_attitude;
// location start_loc;
// unsigned char mobile;
// unsigned char time_flag;
// unsigned char extra1,extra2;
// short spec1, spec2;
// char spec_enc_code,time_code;
// short monster_time,personality;
// short special_on_kill,facial_pic;
//
// cCreature& operator = (legacy::creature_start_type old);
// };
class cWandering { // formerly wandering_type
public:
mon_num_t monst[4];
@@ -105,8 +90,7 @@ public:
bool defy_mapping : 1;
bool defy_scrying : 1;
bool is_hidden : 1;
char reserved_bits : 4;
short hostile_fry_party; // number of a special to be called when the town goes hostile TODO: Not sure about this yet though
char : 4;
short difficulty;
std::string town_name;
// Using std::array here so we can have .size()

View File

@@ -145,13 +145,6 @@ public:
explicit cCurOut(cUniverse& univ);
};
enum eAmbientSound {
AMBIENT_NONE,
AMBIENT_DRIP,
AMBIENT_BIRD,
AMBIENT_CUSTOM,
};
class cUniverse{
template<typename T> using update_info = std::set<T*>;
std::map<pic_num_t, update_info<cItem>> update_items;
@@ -172,7 +165,6 @@ public:
char town_maps[200][8][64]; // formerly stored_town_maps_type
cCurOut out;
char out_maps[100][6][48]; // formerly stored_outdoor_maps_type
snd_num_t out_sound;
fs::path file;
void append(legacy::stored_town_maps_type& old);

View File

@@ -62,6 +62,10 @@ void cButton::draw(){
else style.pointSize = 12;
from_rect = btnRects[type][depressed];
to_rect = frame;
if(type == BTN_TINY) {
to_rect.right = to_rect.left + 14;
to_rect.bottom = to_rect.top + 10;
}
rect_draw_some_item(buttons[btnGW[type]],from_rect,*inWindow,to_rect,sf::BlendAlpha);
style.colour = sf::Color::Black;
style.lineHeight = 8;
@@ -244,9 +248,11 @@ void cLed::draw(){
TextStyle style;
style.pointSize = textSize;
style.lineHeight = textSize - 1;
style.font = textFont;
from_rect = ledRects[state][depressed];
to_rect = frame;
to_rect.right = to_rect.left + 14;
to_rect.bottom = to_rect.top + 10;
rect_draw_some_item(buttons[btnGW[BTN_LED]],from_rect,*inWindow,to_rect);
style.colour = parent->getDefTextClr();
to_rect.right = frame.right;

View File

@@ -2038,22 +2038,26 @@ static bool save_scen_details(cDialog& me) {
cLedGroup& rating = dynamic_cast<cLedGroup&>(me["rating"]);
scenario.rating = rating.getSelected()[4] - '1';
}
scenario.adjust_diff = dynamic_cast<cLed&>(me["adjust"]).getState() != led_red;
for(i = 0; i < 3; i++)
scenario.format.ver[i] = me["ver" + std::to_string(i + 1)].getTextAsNum();
scenario.who_wrote[0] = me["who1"].getText().substr(0, 60);
scenario.who_wrote[1] = me["who2"].getText().substr(0, 60);
scenario.contact_info = me["contact"].getText().substr(0, 256);
scenario.campaign_id = me["cpnid"].getText();
return true;
}
static void put_scen_details_in_dlog(cDialog& me) {
dynamic_cast<cLedGroup&>(me["difficulty"]).setSelected("lvl" + std::to_string(scenario.difficulty + 1));
dynamic_cast<cLedGroup&>(me["rating"]).setSelected("rate" + std::to_string(scenario.rating + 1));
dynamic_cast<cLed&>(me["adjust"]).setState(scenario.adjust_diff ? led_red : led_off);
for(int i = 0; i < 3; i++)
me["ver" + std::to_string(i + 1)].setTextToNum(scenario.format.ver[i]);
me["who1"].setText(scenario.who_wrote[0]);
me["who2"].setText(scenario.who_wrote[1]);
me["contact"].setText(scenario.contact_info);
me["cpnid"].setText(scenario.campaign_id);
}
static bool edit_scen_details_event_filter(cDialog& me, std::string, eKeyMod) {

View File

@@ -270,7 +270,7 @@ short choose_text(eStrType list, unsigned short cur_choice, cDialog* parent, con
break;
}
if(cur_choice < 0 || cur_choice >= strings.size())
cur_choice = 0;
cur_choice = -1;
cStringChoice dlog(strings, title, parent);
return dlog.show(cur_choice);

View File

@@ -434,6 +434,24 @@ void outdoor_details() {
out_dlg["loc"].setText(str_out.str());
out_dlg["comment"].setText(current_terrain->comment);
out_dlg["name"].setText(current_terrain->out_name);
dynamic_cast<cLedGroup&>(out_dlg["ambient"]).setSelected("snd" + std::to_string(int(current_terrain->ambient_sound) + 1));
out_dlg["ambient"].attachFocusHandler([](cDialog& me, std::string, bool) -> bool {
cLedGroup& lg = dynamic_cast<cLedGroup&>(me["ambient"]);
std::string hit = lg.getSelected();
std::string prev = lg.getPrevSelection();
eAmbientSound choice = eAmbientSound(hit[3] - '1');
if(choice == AMBIENT_CUSTOM) {
int i = prev == "snd4" ? current_terrain->out_sound : -1;
i = choose_text(STRT_SND, i, &me, "Choose ambient sound:");
if(i < 0) {
lg.setSelected(prev);
return false;
}
current_terrain->out_sound = i;
}
current_terrain->ambient_sound = choice;
return true;
});
out_dlg.run();
}
@@ -685,7 +703,11 @@ static bool save_advanced_town(cDialog& me, std::string, eKeyMod) {
}
town->spec_on_entry = me["onenter"].getTextAsNum();
town->spec_on_entry_if_dead = me["onenterdead"].getTextAsNum();
town->spec_on_hostile = me["onhostile"].getTextAsNum();
town->is_hidden = dynamic_cast<cLed&>(me["hidden"]).getState() != led_off;
town->defy_mapping = dynamic_cast<cLed&>(me["nomap"]).getState() != led_off;
town->defy_scrying = dynamic_cast<cLed&>(me["noscry"]).getState() != led_off;
town->strong_barriers = dynamic_cast<cLed&>(me["barrier"]).getState() != led_off;
return true;
}
@@ -699,7 +721,28 @@ static void put_advanced_town_in_dlog(cDialog& me) {
}
me["onenter"].setTextToNum(town->spec_on_entry);
me["onenterdead"].setTextToNum(town->spec_on_entry_if_dead);
me["onhostile"].setTextToNum(town->spec_on_hostile);
dynamic_cast<cLed&>(me["hidden"]).setState(town->is_hidden ? led_red : led_off);
dynamic_cast<cLed&>(me["nomap"]).setState(town->defy_mapping ? led_red : led_off);
dynamic_cast<cLed&>(me["noscry"]).setState(town->defy_scrying ? led_red : led_off);
dynamic_cast<cLed&>(me["barrier"]).setState(town->strong_barriers ? led_red : led_off);
}
static bool edit_advanced_town_special(cDialog& me, std::string hit, eKeyMod) {
std::string fld = hit.substr(5);
short spec = me[fld].getTextAsNum();
if(spec < 0 || spec > 99) {
spec = get_fresh_spec(2);
if(spec < 0) {
giveError("You can't create a new town special encounter because there are no more free special nodes.",
"To free a special node, set its type to No Special and set its Jump To special to -1.", &me);
return true;
}
}
if(edit_spec_enc(spec,2,&me)) {
me[fld].setTextToNum(spec);
}
return true;
}
void edit_advanced_town() {
@@ -711,9 +754,11 @@ void edit_advanced_town() {
auto loc_check = std::bind(check_range_msg, _1, _2, _3, -1, 47, "The town exit coordinates", "-1 if you want them ignored");
auto spec_check = std::bind(check_range_msg, _1, _2, _3, -1, 99, _4, "-1 for no special");
town_dlg.attachFocusHandlers(std::bind(spec_check, _1, _2, _3, "The town exit special"), {"onexit1", "onexit2", "onexit3", "onexit4"});
town_dlg.attachFocusHandlers(std::bind(spec_check, _1, _2, _3, "Thw town entry special"), {"onenter", "onenterdead"});
town_dlg.attachFocusHandlers(std::bind(spec_check, _1, _2, _3, "The town entry special"), {"onenter", "onenterdead"});
town_dlg["onhostile"].attachFocusHandler(std::bind(spec_check, _1, _2, _3, "The town hostile special"));
town_dlg.attachFocusHandlers(loc_check, {"exit1-x", "exit2-x", "exit3-x", "exit4-x"});
town_dlg.attachFocusHandlers(loc_check, {"exit1-y", "exit2-y", "exit3-y", "exit4-y"});
town_dlg.attachClickHandlers(edit_advanced_town_special, {"edit-onexit1", "edit-onexit2", "edit-onexit3", "edit-onexit4", "edit-onenter", "edit-onenterdead", "edit-onhostile"});
put_advanced_town_in_dlog(town_dlg);