record and replay dialog choices
This commit is contained in:
@@ -710,37 +710,16 @@ static void show_job_bank(int which_bank, std::string title) {
|
||||
job_dlg.run();
|
||||
}
|
||||
|
||||
void handle_talk_event(location p, cFramerateLimiter& fps_limiter) {
|
||||
void handle_talk_node(int which_talk_entry) {
|
||||
if(which_talk_entry == TALK_DUNNO)
|
||||
return;
|
||||
|
||||
short get_pc,s1 = -1,s2 = -1;
|
||||
char asked[4];
|
||||
|
||||
short a,b,c,d;
|
||||
eTalkNode ttype;
|
||||
|
||||
if(p.in(talk_help_rect)) {
|
||||
if(!help_btn->handleClick(p, fps_limiter))
|
||||
return;
|
||||
give_help_and_record(205,6);
|
||||
return;
|
||||
}
|
||||
|
||||
p.x -= 5;
|
||||
p.y -= 5;
|
||||
|
||||
int which_talk_entry = TALK_DUNNO;
|
||||
for(word_rect_t& word : talk_words) {
|
||||
if(word.node == -1) continue;
|
||||
rectangle wordRect(word.rect);
|
||||
wordRect.offset(talk_area_rect.topLeft());
|
||||
wordRect.offset(-1, -10); // TODO: This corrects for the byzantine offsets that win_draw_string applies for some reason...
|
||||
if(!p.in(wordRect)) continue;
|
||||
click_talk_rect(word);
|
||||
which_talk_entry = word.node;
|
||||
break;
|
||||
}
|
||||
if(which_talk_entry == TALK_DUNNO)
|
||||
return;
|
||||
|
||||
switch(which_talk_entry) {
|
||||
case TALK_DUNNO:
|
||||
SPECIAL_DUNNO:
|
||||
@@ -1101,6 +1080,31 @@ void handle_talk_event(location p, cFramerateLimiter& fps_limiter) {
|
||||
place_talk_str(save_talk_str1,save_talk_str2,0,dummy_rect);
|
||||
}
|
||||
|
||||
void handle_talk_event(location p, cFramerateLimiter& fps_limiter) {
|
||||
if(p.in(talk_help_rect)) {
|
||||
if(!help_btn->handleClick(p, fps_limiter))
|
||||
return;
|
||||
give_help_and_record(205,6);
|
||||
return;
|
||||
}
|
||||
|
||||
p.x -= 5;
|
||||
p.y -= 5;
|
||||
|
||||
int which_talk_entry = TALK_DUNNO;
|
||||
for(word_rect_t& word : talk_words) {
|
||||
if(word.node == -1) continue;
|
||||
rectangle wordRect(word.rect);
|
||||
wordRect.offset(talk_area_rect.topLeft());
|
||||
wordRect.offset(-1, -10); // TODO: This corrects for the byzantine offsets that win_draw_string applies for some reason...
|
||||
if(!p.in(wordRect)) continue;
|
||||
click_talk_rect(word);
|
||||
which_talk_entry = word.node;
|
||||
break;
|
||||
}
|
||||
handle_talk_node(which_talk_entry);
|
||||
}
|
||||
|
||||
//town_num; // Will be 0 - 200 for town, 200 - 290 for outdoors
|
||||
//short sign_type; // terrain type
|
||||
void do_sign(short town_num, short which_sign, short sign_type) {
|
||||
|
@@ -13,6 +13,7 @@ void handle_info_request(cShopItem item);
|
||||
void set_up_shop_array();
|
||||
void start_talk_mode(short m_num,short personality,mon_num_t monst_type,short store_face_pic);
|
||||
void end_talk_mode();
|
||||
void handle_talk_node(int which_talk_entry);
|
||||
void handle_talk_event(location p, cFramerateLimiter& fps_limiter);
|
||||
void handle_talk_spec(short ttype,char* place_string1,char* place_string2);
|
||||
void store_responses();
|
||||
|
@@ -533,6 +533,10 @@ static void replay_next_action() {
|
||||
handle_begin_talk(need_reprint);
|
||||
}else if(t == "handle_talk"){
|
||||
handle_talk(location_from_action(next_action), did_something, need_redraw, need_reprint);
|
||||
}else if(t == "click_talk_rect"){
|
||||
word_rect_t word_rect = word_rect_from_action(next_action);
|
||||
click_talk_rect(word_rect);
|
||||
handle_talk_node(word_rect.node);
|
||||
}
|
||||
|
||||
// TODO some of these actions shouldn't call advance_time(). They should return
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include "fileio/resmgr/res_image.hpp"
|
||||
#include "tools/prefs.hpp"
|
||||
#include "tools/enum_map.hpp"
|
||||
#include "replay.hpp"
|
||||
|
||||
short monsters_faces[190] = {
|
||||
0,1,2,3,4,5,6,7,8,9,
|
||||
@@ -824,6 +825,10 @@ static void place_talk_face() {
|
||||
}
|
||||
|
||||
void click_talk_rect(word_rect_t word) {
|
||||
if(recording){
|
||||
record_click_talk_rect(word, word.on == PRESET_WORD_ON);
|
||||
}
|
||||
|
||||
rectangle talkRect(talk_gworld), wordRect(word.rect);
|
||||
mainPtr.setActive();
|
||||
rect_draw_some_item(talk_gworld.getTexture(),talkRect,mainPtr,talk_area_rect);
|
||||
|
@@ -5,6 +5,9 @@
|
||||
#include "scenario/item.hpp"
|
||||
#include "gfx/gfxsheets.hpp"
|
||||
|
||||
#ifndef BOE_NEWGRAPH_H
|
||||
#define BOE_NEWGRAPH_H
|
||||
|
||||
struct word_rect_t {
|
||||
std::string word;
|
||||
rectangle rect;
|
||||
@@ -64,3 +67,5 @@ void place_talk_str(std::string str_to_place,std::string str_to_place2,short col
|
||||
short scan_for_response(const char *str);
|
||||
void refresh_talking();
|
||||
graf_pos calc_item_rect(int num,rectangle& to_rect);
|
||||
|
||||
#endif /* defined(BOE_NEWGRAPH_H) */
|
||||
|
@@ -14,6 +14,8 @@
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
#include <string>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include "render_shapes.hpp"
|
||||
|
||||
using base64 = cppcodec::base64_rfc4648;
|
||||
|
||||
@@ -217,4 +219,31 @@ cKey key_from_action(Element& action) {
|
||||
key.mod = static_cast<eKeyMod>(enum_v);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
word_rect_t word_rect_from_action(Element& action) {
|
||||
auto info = info_from_action(action);
|
||||
|
||||
std::string word = info["word"];
|
||||
rectangle rect = boost::lexical_cast<rectangle>(info["rect"]);
|
||||
|
||||
word_rect_t word_rect(word, rect);
|
||||
|
||||
word_rect.node = boost::lexical_cast<int>(info["node"]);
|
||||
|
||||
bool preset = boost::lexical_cast<bool>(info["preset"]);
|
||||
word_rect.on = preset ? PRESET_WORD_ON : CUSTOM_WORD_ON;
|
||||
word_rect.off = preset ? PRESET_WORD_OFF : CUSTOM_WORD_OFF;
|
||||
return word_rect;
|
||||
}
|
||||
|
||||
void record_click_talk_rect(word_rect_t word_rect, bool preset) {
|
||||
std::map<std::string,std::string> info;
|
||||
|
||||
info["word"] = word_rect.word;
|
||||
info["rect"] = boost::lexical_cast<std::string>(word_rect.rect);
|
||||
info["node"] = boost::lexical_cast<std::string>(word_rect.node);
|
||||
info["preset"] = boost::lexical_cast<std::string>(preset);
|
||||
|
||||
record_action("click_talk_rect", info);
|
||||
}
|
@@ -7,11 +7,14 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
#include "location.hpp"
|
||||
#include "dialogxml/keycodes.hpp"
|
||||
#include "boe.newgraph.hpp"
|
||||
|
||||
// Input recording system
|
||||
namespace ticpp { class Element; }
|
||||
using ticpp::Element;
|
||||
|
||||
struct word_rect_t;
|
||||
|
||||
extern bool recording;
|
||||
extern bool replaying;
|
||||
|
||||
@@ -28,5 +31,7 @@ extern void decode_file(std::string data, fs::path file);
|
||||
extern location location_from_action(Element& action);
|
||||
extern short short_from_action(Element& action);
|
||||
extern cKey key_from_action(Element& action);
|
||||
extern word_rect_t word_rect_from_action(Element& action);
|
||||
extern void record_click_talk_rect(word_rect_t word_rect, bool preset);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user