From 7d34d2a49ca7ea7d6cbb1a2e08b0357579c09e68 Mon Sep 17 00:00:00 2001 From: ALONSO Laurent Date: Sat, 25 Sep 2021 14:34:01 +0200 Subject: [PATCH] talk: try to make "Go Back" and the keys work again, shopping: try to make work again, + minor corrections... --- src/game/boe.actions.cpp | 11 ++++++++--- src/game/boe.dlgutil.cpp | 36 ++++++++++++++++++++++++++++++++++++ src/game/boe.newgraph.cpp | 35 ++--------------------------------- src/game/boe.town.cpp | 4 +--- src/gfx/render_text.cpp | 2 +- src/scenedit/scen.main.cpp | 2 ++ 6 files changed, 50 insertions(+), 40 deletions(-) diff --git a/src/game/boe.actions.cpp b/src/game/boe.actions.cpp index 10546339..2b66aa23 100644 --- a/src/game/boe.actions.cpp +++ b/src/game/boe.actions.cpp @@ -1629,6 +1629,7 @@ bool handle_keystroke(const sf::Event& event){ else if(chr2 == kb::PageDown) chr2 = kb::Numpad3; sf::Event pass_event = {sf::Event::MouseButtonPressed}; + extern rectangle talk_area_rect; if(overall_mode == MODE_TALKING) { if(chr2 == kb::Escape) chr2 = kb::D; @@ -1637,8 +1638,10 @@ bool handle_keystroke(const sf::Event& event){ for(short i = 0; i < 9; i++) if(chr2 == talk_chars[i] && (!talk_end_forced || i == 6 || i == 5)) { int j = talk_end_forced ? i - 5 : i; + // related to talk_area_rect, unsure why adding +9 is needed? pass_point = talk_words[j].rect.topLeft(); - pass_point.x += 9; pass_point.y += 9; + pass_point.x += talk_area_rect.left+9; + pass_point.y += talk_area_rect.top+9; pass_point = mainPtr.mapCoordsToPixel(pass_point, mainView); pass_event.mouseButton.x = pass_point.x; pass_event.mouseButton.y = pass_point.y; @@ -1653,7 +1656,9 @@ bool handle_keystroke(const sf::Event& event){ for(short i = 0; i < 8; i++) if(chr2 == shop_chars[i]) { pass_point = shopping_rects[i][SHOPRECT_ACTIVE_AREA].topLeft(); - pass_point.x += 9; pass_point.y += 9; + // related to talk_area_rect + pass_point.x += talk_area_rect.left+9; + pass_point.y += talk_area_rect.top+9; pass_point = mainPtr.mapCoordsToPixel(pass_point, mainView); pass_event.mouseButton.x = pass_point.x; pass_event.mouseButton.y = pass_point.y; @@ -2585,7 +2590,7 @@ void handle_death() { if(univ.party.is_alive()) { if(overall_mode == MODE_STARTUP) post_load(), finish_load_party(); - return; + return; } } else if(choice == "new") { diff --git a/src/game/boe.dlgutil.cpp b/src/game/boe.dlgutil.cpp index f95b1b34..e86161c2 100644 --- a/src/game/boe.dlgutil.cpp +++ b/src/game/boe.dlgutil.cpp @@ -32,6 +32,7 @@ #include "button.hpp" #include "ledgroup.hpp" #include "pict.hpp" +#include "render_shapes.hpp" #include "stack.hpp" #include #include "prefs.hpp" @@ -588,6 +589,41 @@ void start_talk_mode(short m_num,short personality,mon_num_t monst_type,short st store_pre_talk_mode = overall_mode; overall_mode = MODE_TALKING; talk_end_forced = false; + + // first initialise talk_words here + talk_words.clear(); + static const rectangle preset_rects[9] = { + rectangle{366,4,386,54}, rectangle{366,70,386,130}, rectangle{366,136,386,186}, + rectangle{389,4,409,54}, rectangle{389,70,409,120}, rectangle{389,121,409,186}, + rectangle{389,210,409,270}, rectangle{366,190,386,270}, + rectangle{343,4,363,134}, + }; + static const char*const preset_words[9] = { + "Look", "Name", "Job", + "Buy", "Sell", "Record", + "Done", "Go Back", + "Ask About...", + }; + + // Place buttons at bottom. + for(short i = 0; i < 9; i++) { + word_rect_t preset_word(preset_words[i], preset_rects[i]); + preset_word.on = Colours::DARK_GREEN; + preset_word.off = Colours::LIGHT_GREEN; + switch(i) { + case 0: preset_word.node = TALK_LOOK; break; + case 1: preset_word.node = TALK_NAME; break; + case 2: preset_word.node = TALK_JOB; break; + case 3: preset_word.node = TALK_BUY; break; + case 4: preset_word.node = TALK_SELL; break; + case 5: preset_word.node = TALK_RECORD; break; + case 6: preset_word.node = TALK_DONE; break; + case 7: preset_word.node = TALK_BACK; break; + case 8: preset_word.node = TALK_ASK; break; + } + talk_words.push_back(preset_word); + } + stat_screen_mode = MODE_SHOP; current_talk_node = TALK_LOOK; diff --git a/src/game/boe.newgraph.cpp b/src/game/boe.newgraph.cpp index fc7657e6..0615d9f9 100644 --- a/src/game/boe.newgraph.cpp +++ b/src/game/boe.newgraph.cpp @@ -941,45 +941,14 @@ void place_talk_str(std::string str_to_place,std::string str_to_place2,short col style.colour = Colours::TITLE_BLUE; win_draw_string(talk_gworld,dest_rect,title_string,eTextMode::LEFT_TOP,style); - talk_words.clear(); - static const rectangle preset_rects[9] = { - rectangle{366,4,386,54}, rectangle{366,70,386,130}, rectangle{366,136,386,186}, - rectangle{389,4,409,54}, rectangle{389,70,409,120}, rectangle{389,121,409,186}, - rectangle{389,210,409,270}, rectangle{366,190,386,270}, - rectangle{343,4,363,134}, - }; - static const char*const preset_words[9] = { - "Look", "Name", "Job", - "Buy", "Sell", "Record", - "Done", "Go Back", - "Ask About...", - }; - // Place buttons at bottom. if(color == 0) style.colour = Colours::DARK_GREEN; else style.colour = Colours::LIGHT_GREEN; for(short i = 0; i < 9; i++) { - if(!talk_end_forced || i == 6 || i == 5) { - word_rect_t preset_word(preset_words[i], preset_rects[i]); - preset_word.on = Colours::DARK_GREEN; - preset_word.off = Colours::LIGHT_GREEN; - switch(i) { - case 0: preset_word.node = TALK_LOOK; break; - case 1: preset_word.node = TALK_NAME; break; - case 2: preset_word.node = TALK_JOB; break; - case 3: preset_word.node = TALK_BUY; break; - case 4: preset_word.node = TALK_SELL; break; - case 5: preset_word.node = TALK_RECORD; break; - case 6: preset_word.node = TALK_DONE; break; - case 7: preset_word.node = TALK_BACK; break; - case 8: preset_word.node = TALK_ASK; break; - } - talk_words.push_back(preset_word); - rectangle draw_rect = preset_word.rect; - win_draw_string(talk_gworld,draw_rect,preset_word.word,eTextMode::LEFT_TOP,style); - } + if(!talk_end_forced || i == 6 || i == 5) + win_draw_string(talk_gworld,talk_words[i].rect,talk_words[i].word,eTextMode::LEFT_TOP,style); } style.colour = Colours::NAVY; diff --git a/src/game/boe.town.cpp b/src/game/boe.town.cpp index 8e291cb2..51430ba1 100644 --- a/src/game/boe.town.cpp +++ b/src/game/boe.town.cpp @@ -71,7 +71,7 @@ void force_town_enter(short which_town,location where_start) { //short entry_dir; // if 9, go to forced void start_town_mode(short which_town, short entry_dir) { short town_number; - short at_which_save_slot,former_town; + short former_town; bool monsters_loaded = false,town_toast = false; location loc; unsigned short temp; @@ -143,8 +143,6 @@ void start_town_mode(short which_town, short entry_dir) { univ.town.monst.which_town = town_number; univ.town.monst.hostile = false; - at_which_save_slot = univ.party.at_which_save_slot; - for(auto& pop : univ.party.creature_save) if(town_number == pop.which_town) { univ.town.monst = pop; diff --git a/src/gfx/render_text.cpp b/src/gfx/render_text.cpp index fcffbecb..bc1df758 100644 --- a/src/gfx/render_text.cpp +++ b/src/gfx/render_text.cpp @@ -77,7 +77,7 @@ static void push_snippets(size_t start, size_t end, text_params_t& options, size } size_t amount = end - start; snippets.push_back({str.substr(start,amount), loc, hilited}); - if(hilited) std::cout << "Hiliting passage : \"" << snippets.back().text << '"' << std::endl; + //if(hilited) std::cout << "Hiliting passage : \"" << snippets.back().text << '"' << std::endl; loc.x += string_length(snippets.back().text, options.style); start = end; end = upper_bound; diff --git a/src/scenedit/scen.main.cpp b/src/scenedit/scen.main.cpp index 0249bc41..e05e3525 100644 --- a/src/scenedit/scen.main.cpp +++ b/src/scenedit/scen.main.cpp @@ -26,6 +26,8 @@ #include "scen.menus.hpp" #include "res_image.hpp" #include "button.hpp" +#include "keycodes.hpp" +#include "led.hpp" #include "prefs.hpp" #include "framerate_limiter.hpp" #include "event_listener.hpp"