From 41fbd73ef95f7d5001ba987c0b37dc362263abfc Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Wed, 21 Jan 2015 15:59:09 -0500 Subject: [PATCH] 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 --- rsrc/dialogs/dialog.xsl | 3 +- rsrc/dialogs/edit-outdoor-details.xml | 13 +++++-- rsrc/dialogs/edit-scenario-details.xml | 50 ++++++++++---------------- rsrc/dialogs/edit-town-advanced.xml | 42 +++++++++++----------- src/boe.graphutil.cpp | 5 ++- src/classes/outdoors.cpp | 1 + src/classes/outdoors.h | 9 +++++ src/classes/town.h | 18 +--------- src/classes/universe.h | 8 ----- src/dialogxml/button.cpp | 6 ++++ src/scenedit/scen.core.cpp | 4 +++ src/scenedit/scen.keydlgs.cpp | 2 +- src/scenedit/scen.townout.cpp | 47 +++++++++++++++++++++++- 13 files changed, 123 insertions(+), 85 deletions(-) diff --git a/rsrc/dialogs/dialog.xsl b/rsrc/dialogs/dialog.xsl index 71700e97..989da31c 100644 --- a/rsrc/dialogs/dialog.xsl +++ b/rsrc/dialogs/dialog.xsl @@ -69,12 +69,13 @@
+ debug button background-image: url('img/button/.png'); left: px; top: px; - width: ; + width: px; diff --git a/rsrc/dialogs/edit-outdoor-details.xml b/rsrc/dialogs/edit-outdoor-details.xml index cb354205..f74f54bc 100644 --- a/rsrc/dialogs/edit-outdoor-details.xml +++ b/rsrc/dialogs/edit-outdoor-details.xml @@ -3,14 +3,21 @@ - + Outdoors Details Section name: Coordinates: - Comment:

+ Ambient Sound: + + None + Drips + Birdsong + Custom + + Comment:

You can put useful notes for yourself here. It's not used by the game for anything.
- +
\ No newline at end of file diff --git a/rsrc/dialogs/edit-scenario-details.xml b/rsrc/dialogs/edit-scenario-details.xml index d117d535..fd8aaf7c 100644 --- a/rsrc/dialogs/edit-scenario-details.xml +++ b/rsrc/dialogs/edit-scenario-details.xml @@ -7,7 +7,7 @@ - + This is where you can define the various pieces of information the user will see when deciding whether or not to play your scenario. @@ -18,41 +18,29 @@ Credits, Part 1: Credits, Part 2: Contact Information: - Rating: - - G - PG - R - NC-17 - + Rating: - - - - + G + PG + R + NC-17 - Difficulty: - - Low Level (1-8) - Medium Level (9-18) - High Level (19-30) + Difficulty: - Very High Level (30+) - - - - - + Low Level (1-8) + Medium Level (9-18) + High Level (19-30) + Very High Level (30+) + Adjust difficulty if played by a party stronger than recommended + Campaign ID: + + + If your scenario is part of a campaign of several scenarios, + the ID specified here makes it easy to carry information from one scenario to the next. + It should be the same in each scenario in the series. + \ No newline at end of file diff --git a/rsrc/dialogs/edit-town-advanced.xml b/rsrc/dialogs/edit-town-advanced.xml index 3e959aee..71789faf 100644 --- a/rsrc/dialogs/edit-town-advanced.xml +++ b/rsrc/dialogs/edit-town-advanced.xml @@ -6,8 +6,9 @@ - - + + + @@ -16,8 +17,8 @@ - - + + Advanced town details @@ -32,30 +33,31 @@ Town entry special node: - (Enter the number of the town special node to call if the party enters the town when it’s still alive, and/or when it’s been abandoned.) + (Enter the number of the town special node to call if the party enters the town when it's still alive, and/or when it's been abandoned.) Exit town specials: (These are the numbers of the town special nodes to call when the party tries to leave town in the given direction.) - Still alive - Been abandoned - Top - Left - Bottom - Right + + + + + + + Top Left Bottom Right - X - Y - - + X + Y + Town Properties: + Town hidden? - (This town cannot be seen until it’s made visible with a special encounter.) - - + (This town cannot be seen until it's made visible with a special encounter.) + + No automap in this town + Defy scrying (Magic Map doesn't work) + Magical barriers are stronger in this town \ No newline at end of file diff --git a/src/boe.graphutil.cpp b/src/boe.graphutil.cpp index c21cc803..b75637d2 100644 --- a/src/boe.graphutil.cpp +++ b/src/boe.graphutil.cpp @@ -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: diff --git a/src/classes/outdoors.cpp b/src/classes/outdoors.cpp index de6a0211..b0ba5f5a 100644 --- a/src/classes/outdoors.cpp +++ b/src/classes/outdoors.cpp @@ -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 unused_special_slots; for(i = 0; i < 60; i++) { diff --git a/src/classes/outdoors.h b/src/classes/outdoors.h index dd75ff28..ce17013c 100644 --- a/src/classes/outdoors.h +++ b/src/classes/outdoors.h @@ -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 spec_strs; std::array 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); diff --git a/src/classes/town.h b/src/classes/town.h index c64dd1b1..f075b82d 100644 --- a/src/classes/town.h +++ b/src/classes/town.h @@ -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() diff --git a/src/classes/universe.h b/src/classes/universe.h index 9b36cfcd..65b95bfd 100644 --- a/src/classes/universe.h +++ b/src/classes/universe.h @@ -145,13 +145,6 @@ public: explicit cCurOut(cUniverse& univ); }; -enum eAmbientSound { - AMBIENT_NONE, - AMBIENT_DRIP, - AMBIENT_BIRD, - AMBIENT_CUSTOM, -}; - class cUniverse{ template using update_info = std::set; std::map> 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); diff --git a/src/dialogxml/button.cpp b/src/dialogxml/button.cpp index a5d772f7..46c0ef73 100644 --- a/src/dialogxml/button.cpp +++ b/src/dialogxml/button.cpp @@ -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; diff --git a/src/scenedit/scen.core.cpp b/src/scenedit/scen.core.cpp index 53f3c87f..1a3c2403 100644 --- a/src/scenedit/scen.core.cpp +++ b/src/scenedit/scen.core.cpp @@ -2038,22 +2038,26 @@ static bool save_scen_details(cDialog& me) { cLedGroup& rating = dynamic_cast(me["rating"]); scenario.rating = rating.getSelected()[4] - '1'; } + scenario.adjust_diff = dynamic_cast(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(me["difficulty"]).setSelected("lvl" + std::to_string(scenario.difficulty + 1)); dynamic_cast(me["rating"]).setSelected("rate" + std::to_string(scenario.rating + 1)); + dynamic_cast(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) { diff --git a/src/scenedit/scen.keydlgs.cpp b/src/scenedit/scen.keydlgs.cpp index 0d5fd33c..cbcbefb6 100644 --- a/src/scenedit/scen.keydlgs.cpp +++ b/src/scenedit/scen.keydlgs.cpp @@ -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); diff --git a/src/scenedit/scen.townout.cpp b/src/scenedit/scen.townout.cpp index 4a747b28..c72f0b87 100644 --- a/src/scenedit/scen.townout.cpp +++ b/src/scenedit/scen.townout.cpp @@ -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(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(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(me["hidden"]).getState() != led_off; + town->defy_mapping = dynamic_cast(me["nomap"]).getState() != led_off; + town->defy_scrying = dynamic_cast(me["noscry"]).getState() != led_off; + town->strong_barriers = dynamic_cast(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(me["hidden"]).setState(town->is_hidden ? led_red : led_off); + dynamic_cast(me["nomap"]).setState(town->defy_mapping ? led_red : led_off); + dynamic_cast(me["noscry"]).setState(town->defy_scrying ? led_red : led_off); + dynamic_cast(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);