New feature: dialogs with pictures can animate
This commit is contained in:
@@ -579,7 +579,7 @@ bool show_get_items(std::string titleText, std::vector<cItem*>& itemRefs, short
|
||||
|
||||
}
|
||||
|
||||
short custom_choice_dialog(std::array<std::string, 6>& strs,short pic_num,ePicType pic_type,std::array<short, 3>& buttons) {
|
||||
short custom_choice_dialog(std::array<std::string, 6>& strs,short pic_num,ePicType pic_type,std::array<short, 3>& buttons,bool anim_pict,short anim_loops, int anim_fps) {
|
||||
set_cursor(sword_curs);
|
||||
|
||||
std::vector<std::string> vec(strs.begin(), strs.end());
|
||||
@@ -587,6 +587,9 @@ short custom_choice_dialog(std::array<std::string, 6>& strs,short pic_num,ePicTy
|
||||
while(!vec.empty() && vec.back().empty())
|
||||
vec.pop_back();
|
||||
cThreeChoice customDialog(vec, buttons, pic_num, pic_type);
|
||||
if(anim_pict)
|
||||
setup_dialog_pict_anim(*(customDialog.operator->()), "pict", anim_loops, anim_fps);
|
||||
|
||||
std::string item_hit = customDialog.show();
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
@@ -620,9 +623,17 @@ void custom_pic_dialog(std::string title, pic_num_t bigpic) {
|
||||
pic_dlg.run();
|
||||
}
|
||||
|
||||
void story_dialog(std::string title, str_num_t first, str_num_t last, eSpecCtxType which_str_type, pic_num_t pic, ePicType pt) {
|
||||
void setup_dialog_pict_anim(cDialog& dialog, std::string pict_id, short anim_loops, short anim_fps) {
|
||||
cPict& pict = dynamic_cast<cPict&>(dialog[pict_id]);
|
||||
pict.setAnimLoops(anim_loops);
|
||||
dialog.setAnimPictFPS(anim_fps);
|
||||
dialog.setDoAnimations(true);
|
||||
}
|
||||
|
||||
void story_dialog(std::string title, str_num_t first, str_num_t last, eSpecCtxType which_str_type, pic_num_t pic, ePicType pt, short anim_loops, int anim_fps) {
|
||||
cDialog story_dlg(*ResMgr::dialogs.get("many-str"));
|
||||
dynamic_cast<cPict&>(story_dlg["pict"]).setPict(pic, pt);
|
||||
setup_dialog_pict_anim(story_dlg, "pict", anim_loops, anim_fps);
|
||||
str_num_t cur = first;
|
||||
story_dlg.attachClickHandlers([&cur,first,last,which_str_type](cDialog& me, std::string clicked, eKeyMod) -> bool {
|
||||
if(clicked == "left") {
|
||||
|
@@ -24,9 +24,10 @@ void make_town_hostile();
|
||||
void set_town_attitude(short lo,short hi,eAttitude att);
|
||||
bool show_get_items(std::string titleText, std::vector<cItem*>& itemRefs, short pc_getting, bool overload = false);
|
||||
bool display_item(location from_loc,short pc_num,short mode, bool check_container);
|
||||
short custom_choice_dialog(std::array<std::string, 6>& strs,short pic_num,ePicType pic_type,std::array<short, 3>& buttons) ;
|
||||
short custom_choice_dialog(std::array<std::string, 6>& strs,short pic_num,ePicType pic_type,std::array<short, 3>& buttons, bool anim_pict = false, short anim_loops = -1, int anim_fps = -1);
|
||||
void custom_pic_dialog(std::string title, pic_num_t bigpic);
|
||||
void story_dialog(std::string title, str_num_t first, str_num_t last, eSpecCtxType which_str_type, pic_num_t pic, ePicType pt);
|
||||
void setup_dialog_pict_anim(cDialog& dialog, std::string pict_id, short anim_loops, short anim_fps);
|
||||
void story_dialog(std::string title, str_num_t first, str_num_t last, eSpecCtxType which_str_type, pic_num_t pic, ePicType pt, short anim_loops, int anim_fps);
|
||||
short get_num_of_items(short max_num);
|
||||
void init_mini_map();
|
||||
void draw_help_dialog_item_buttons(cDialog& dialog,short item);
|
||||
|
@@ -2405,7 +2405,7 @@ void general_spec(const runtime_state& ctx) {
|
||||
break;
|
||||
case eSpecType::STORY_DIALOG:
|
||||
get_str(str1,ctx.cur_spec_type,spec.m1);
|
||||
story_dialog(str1, spec.m2, spec.m3, ctx.cur_spec_type, spec.pic, ePicType(spec.pictype));
|
||||
story_dialog(str1, spec.m2, spec.m3, ctx.cur_spec_type, spec.pic, ePicType(spec.pictype), spec.ex1c, spec.ex2c);
|
||||
break;
|
||||
case eSpecType::CLEAR_BUF:
|
||||
univ.get_buf().clear();
|
||||
@@ -2582,7 +2582,7 @@ void oneshot_spec(const runtime_state& ctx) {
|
||||
showError("Dialog box ended up with no buttons.");
|
||||
break;
|
||||
}
|
||||
dlg_res = custom_choice_dialog(strs, spec.pic, ePicType(spec.pictype), buttons);
|
||||
dlg_res = custom_choice_dialog(strs, spec.pic, ePicType(spec.pictype), buttons, true, spec.ex1c, spec.ex2c);
|
||||
if(spec.m3 > 0) {
|
||||
if(dlg_res == 1) {
|
||||
if((spec.ex1a >= 0) || (spec.ex2a >= 0)) {
|
||||
@@ -2602,7 +2602,7 @@ void oneshot_spec(const runtime_state& ctx) {
|
||||
break;
|
||||
get_strs(strs, ctx.cur_spec_type, spec.m1);
|
||||
buttons[0] = 20; buttons[1] = 19;
|
||||
dlg_res = custom_choice_dialog(strs, spec.pic, ePicType(spec.pictype), buttons);
|
||||
dlg_res = custom_choice_dialog(strs, spec.pic, ePicType(spec.pictype), buttons, true, spec.ex1c, spec.ex2c);
|
||||
if(dlg_res == 1) {set_sd = false; ctx.next_spec = -1;}
|
||||
else {
|
||||
store_i = univ.scenario.get_stored_item(spec.ex1a);
|
||||
@@ -2642,7 +2642,7 @@ void oneshot_spec(const runtime_state& ctx) {
|
||||
if((spec.m1 >= 0) || (spec.m2 >= 0)) {
|
||||
get_strs(strs[0],strs[1], ctx.cur_spec_type, spec.m1, spec.m2);
|
||||
buttons[0] = 3; buttons[1] = 2;
|
||||
dlg_res = custom_choice_dialog(strs,spec.pic,ePicType(spec.pictype),buttons);
|
||||
dlg_res = custom_choice_dialog(strs,spec.pic,ePicType(spec.pictype),buttons, true, spec.ex1c, spec.ex2c);
|
||||
// TODO: Make custom_choice_dialog return string?
|
||||
}
|
||||
else dlg_res = cChoiceDlog("basic-trap",{"yes","no"}).show() == "no";
|
||||
@@ -3968,7 +3968,7 @@ void townmode_spec(const runtime_state& ctx) {
|
||||
else {
|
||||
get_strs(strs,ctx.cur_spec_type, spec.m1);
|
||||
buttons[0] = 9; buttons[1] = 35;
|
||||
if(custom_choice_dialog(strs, spec.pic, ePicType(spec.pictype), buttons) == 1)
|
||||
if(custom_choice_dialog(strs, spec.pic, ePicType(spec.pictype), buttons, true, spec.ex1c, spec.ex2c) == 1)
|
||||
ctx.next_spec = -1;
|
||||
else {
|
||||
int x = univ.party.get_ptr(10), y = univ.party.get_ptr(11);
|
||||
@@ -3999,7 +3999,7 @@ void townmode_spec(const runtime_state& ctx) {
|
||||
else {
|
||||
get_strs(strs, ctx.cur_spec_type,spec.m1);
|
||||
buttons[0] = 9; buttons[1] = 8;
|
||||
if(custom_choice_dialog(strs, spec.pic, ePicType(spec.pictype), buttons) == 1) {
|
||||
if(custom_choice_dialog(strs, spec.pic, ePicType(spec.pictype), buttons, true, spec.ex1c, spec.ex2c) == 1) {
|
||||
ctx.next_spec = -1;
|
||||
if(ctx.which_mode == eSpecCtx::OUT_MOVE || ctx.which_mode == eSpecCtx::TOWN_MOVE || ctx.which_mode == eSpecCtx::COMBAT_MOVE)
|
||||
*ctx.ret_a = 1;
|
||||
|
@@ -2995,6 +2995,7 @@ bool edit_make_scen_2(short& out_w, short& out_h, short& town_l, short& town_m,
|
||||
|
||||
extern fs::path progDir;
|
||||
extern eScenMode overall_mode;
|
||||
|
||||
bool build_scenario() {
|
||||
short width, height, lg, med, sm;
|
||||
bool default_town, grass;
|
||||
@@ -3092,7 +3093,6 @@ bool build_scenario() {
|
||||
scenario.shops.push_back(cShop(SHOP_HEALING));
|
||||
|
||||
overall_mode = MODE_MAIN_SCREEN;
|
||||
|
||||
editing_town = false;
|
||||
scenario.outdoors.resize(width, height);
|
||||
for(int x = 0; x < width; x++) {
|
||||
|
Reference in New Issue
Block a user