editor hint for 6-str once dialog
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
|
||||
#include "dialogxml/dialogs/strdlog.hpp"
|
||||
#include "oldstructs.hpp"
|
||||
@@ -21,6 +22,7 @@
|
||||
#include "skills_traits.hpp"
|
||||
#include "damage.hpp"
|
||||
#include "fields.hpp"
|
||||
#include "universe.hpp"
|
||||
#include "scenario.hpp"
|
||||
|
||||
bool cTimer::is_valid() const {
|
||||
@@ -530,28 +532,40 @@ void cSpecial::import_legacy(legacy::special_node_type& old){
|
||||
}
|
||||
}
|
||||
|
||||
static std::string format_sdf_name(int row, int col, std::string name) {
|
||||
|
||||
}
|
||||
|
||||
// In the editor node list, be as helpful as possible about what the specific node instance does
|
||||
std::string cSpecial::editor_hint(const cScenario& scenario) const {
|
||||
std::string cSpecial::editor_hint(cUniverse& univ) const {
|
||||
std::string hint = (*type).name();
|
||||
|
||||
eSpecCtxType cur_type = static_cast<eSpecCtxType>(univ.scenario.editor_state.special_editing_mode);
|
||||
std::string preposition = "to";
|
||||
|
||||
auto first_of_six_str = [&univ, cur_type](int start) {
|
||||
std::array<std::string, 6> strs;
|
||||
univ.get_strs(strs, cur_type, start);
|
||||
for(std::string s : strs){
|
||||
boost::algorithm::trim(s);
|
||||
if(!s.empty()){
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return std::string{""};
|
||||
};
|
||||
|
||||
switch(type){
|
||||
case eSpecType::ONCE_DIALOG:
|
||||
hint += fmt::format(": '{}'", first_of_six_str(m1));
|
||||
break;
|
||||
case eSpecType::INC_SDF:
|
||||
preposition = ex1b == 1 ? "decrease by" : "increase by";
|
||||
BOOST_FALLTHROUGH;
|
||||
case eSpecType::SET_SDF:{
|
||||
std::string name = scenario.sdf_display_name(sd1, sd2);
|
||||
std::string name = univ.scenario.sdf_display_name(sd1, sd2);
|
||||
hint += fmt::format(" {} {} {}", name, preposition, ex1a);
|
||||
}break;
|
||||
case eSpecType::TOWN_STAIR:
|
||||
case eSpecType::TOWN_GENERIC_STAIR:
|
||||
hint += " to ";
|
||||
if(ex2a < scenario.towns.size()) hint += scenario.towns[ex2a]->loc_str(loc(ex1a, ex1b));
|
||||
if(ex2a < univ.scenario.towns.size()) hint += univ.scenario.towns[ex2a]->loc_str(loc(ex1a, ex1b));
|
||||
else hint += "INVALID TOWN";
|
||||
break;
|
||||
default: break;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "dialogxml/widgets/pictypes.hpp"
|
||||
|
||||
namespace legacy { struct special_node_type; };
|
||||
class cScenario;
|
||||
class cUniverse;
|
||||
|
||||
static const short SDF_COMPLETE = 250;
|
||||
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
bool operator!=(const cSpecial& other) const { return !(*this == other); }
|
||||
std::string editor_hint(const cScenario& scenario) const;
|
||||
std::string editor_hint(cUniverse& univ) const;
|
||||
};
|
||||
|
||||
enum class eSpecCtxType {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include "dialogxml/widgets/field.hpp"
|
||||
#include "universe/universe.hpp"
|
||||
|
||||
#include "dialogxml/dialogs/dialog.hpp"
|
||||
|
||||
@@ -531,19 +532,21 @@ static void apply_mode_buttons() {
|
||||
case 2: num_specs = town->specials.size(); break;
|
||||
}
|
||||
|
||||
extern cUniverse temp_universe();
|
||||
cUniverse univ = temp_universe();
|
||||
for(size_t i = 0; i < num_specs; i++) {
|
||||
std::ostringstream strb;
|
||||
switch(mode) {
|
||||
case 0:
|
||||
strb << i << " - " << scenario.scen_specials[i].editor_hint(scenario);
|
||||
strb << i << " - " << scenario.scen_specials[i].editor_hint(univ);
|
||||
set_rb(i,RB_SCEN_SPEC, i, strb.str());
|
||||
break;
|
||||
case 1:
|
||||
strb << i << " - " << current_terrain->specials[i].editor_hint(scenario);
|
||||
strb << i << " - " << current_terrain->specials[i].editor_hint(univ);
|
||||
set_rb(i,RB_OUT_SPEC, i, strb.str());
|
||||
break;
|
||||
case 2:
|
||||
strb << i << " - " << town->specials[i].editor_hint(scenario);
|
||||
strb << i << " - " << town->specials[i].editor_hint(univ);
|
||||
set_rb(i,RB_TOWN_SPEC, i, strb.str());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -858,13 +858,8 @@ static void save_spec_enc(cDialog& me, node_stack_t& edit_stack) {
|
||||
static bool preview_spec_enc_dlog(cDialog& me, std::string, cSpecial& special, short mode) {
|
||||
eSpecCtxType cur_type = static_cast<eSpecCtxType>(mode);
|
||||
|
||||
// Not pretty, but works:
|
||||
cUniverse univ;
|
||||
univ.scenario = scenario;
|
||||
univ.party.town_num = cur_town;
|
||||
univ.party.outdoor_corner = cur_out;
|
||||
univ.party.i_w_c = {0, 0};
|
||||
|
||||
extern cUniverse temp_universe();
|
||||
cUniverse univ = temp_universe();
|
||||
std::string title = "";
|
||||
ePicType pic_type = PIC_SCEN;
|
||||
pic_num_t pic = scenario.intro_pic;
|
||||
|
||||
@@ -1035,3 +1035,13 @@ void Mouse_Pressed(const sf::Event & event) {
|
||||
|
||||
void close_program() {
|
||||
}
|
||||
|
||||
cUniverse temp_universe() {
|
||||
// Not pretty, but works:
|
||||
cUniverse univ;
|
||||
univ.scenario = scenario;
|
||||
univ.party.town_num = cur_town;
|
||||
univ.party.outdoor_corner = cur_out;
|
||||
univ.party.i_w_c = {0, 0};
|
||||
return univ;
|
||||
}
|
||||
Reference in New Issue
Block a user