forked from townforge/townforge
game: print running script name on window title
This commit is contained in:
parent
d8362d78eb
commit
e6e0be698d
@ -354,7 +354,7 @@ public:
|
||||
std::vector<uint64_t> get_item_count(const std::vector<uint32_t> &id) const;
|
||||
bool get_cc_scripts(uint32_t account, uint32_t city, bool include_requirements, std::vector<std::tuple<uint32_t, uint32_t, bool, std::string, std::string, std::string, bool, std::vector<std::pair<std::string, bool>>>> &scripts, uint32_t script, uint32_t owner) const;
|
||||
bool get_cc_script(uint32_t script, std::string &name, std::string &icon, std::string &desc, std::string &blob) const;
|
||||
bool get_cc_script_state(uint32_t account, uint32_t script, uint32_t state, uint32_t city, std::string &ui, std::string &text, std::string &image, std::vector<std::tuple<uint32_t, std::string, std::string>> &choices, std::string &choices_ui, std::vector<std::tuple<uint8_t, uint32_t, std::string>> &overrides) const;
|
||||
bool get_cc_script_state(uint32_t account, uint32_t script, uint32_t state, uint32_t city, std::string &script_name, std::string &ui, std::string &text, std::string &image, std::vector<std::tuple<uint32_t, std::string, std::string>> &choices, std::string &choices_ui, std::vector<std::tuple<uint8_t, uint32_t, std::string>> &overrides) const;
|
||||
bool get_cc_global_variable(const std::string &name, uint64_t &value) const;
|
||||
bool get_cc_runestone(uint32_t flag, uint8_t x, uint8_t y, uint16_t h, cc::runestone_t &runestone) const;
|
||||
bool get_cc_blob_info(const std::vector<crypto::hash> &hashes, std::vector<uint32_t> &refs) const;
|
||||
@ -1240,9 +1240,9 @@ bool GameWalletInternal::get_cc_script(uint32_t script, std::string &name, std::
|
||||
return w->get_cc_script_data(script, name, icon, desc, blob);
|
||||
}
|
||||
|
||||
bool GameWalletInternal::get_cc_script_state(uint32_t account, uint32_t script, uint32_t state, uint32_t city, std::string &ui, std::string &text, std::string &image, std::vector<std::tuple<uint32_t, std::string, std::string>> &choices, std::string &choices_ui, std::vector<std::tuple<uint8_t, uint32_t, std::string>> &overrides) const
|
||||
bool GameWalletInternal::get_cc_script_state(uint32_t account, uint32_t script, uint32_t state, uint32_t city, std::string &script_name, std::string &ui, std::string &text, std::string &image, std::vector<std::tuple<uint32_t, std::string, std::string>> &choices, std::string &choices_ui, std::vector<std::tuple<uint8_t, uint32_t, std::string>> &overrides) const
|
||||
{
|
||||
return w->get_cc_script_state(account, script, state, city, ui, text, image, choices, choices_ui, overrides);
|
||||
return w->get_cc_script_state(account, script, state, city, script_name, ui, text, image, choices, choices_ui, overrides);
|
||||
}
|
||||
|
||||
bool GameWalletInternal::get_cc_global_variable(const std::string &name, uint64_t &value) const
|
||||
@ -1959,9 +1959,9 @@ bool GameWallet::get_cc_script(uint32_t script, std::string &name, std::string &
|
||||
return internal->get_cc_script(script, name, icon, desc, blob);
|
||||
}
|
||||
|
||||
bool GameWallet::get_cc_script_state(uint32_t account, uint32_t script, uint32_t state, uint32_t city, std::string &ui, std::string &text, std::string &image, std::vector<std::tuple<uint32_t, std::string, std::string>> &choices, std::string &choices_ui, std::vector<std::tuple<uint8_t, uint32_t, std::string>> &overrides) const
|
||||
bool GameWallet::get_cc_script_state(uint32_t account, uint32_t script, uint32_t state, uint32_t city, std::string &script_name, std::string &ui, std::string &text, std::string &image, std::vector<std::tuple<uint32_t, std::string, std::string>> &choices, std::string &choices_ui, std::vector<std::tuple<uint8_t, uint32_t, std::string>> &overrides) const
|
||||
{
|
||||
return internal->get_cc_script_state(account, script, state, city, ui, text, image, choices, choices_ui, overrides);
|
||||
return internal->get_cc_script_state(account, script, state, city, script_name, ui, text, image, choices, choices_ui, overrides);
|
||||
}
|
||||
|
||||
bool GameWallet::get_cc_global_variable(const std::string &name, uint64_t &value) const
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
std::vector<uint64_t> get_item_count(const std::vector<uint32_t> &id) const;
|
||||
bool get_cc_scripts(uint32_t account, uint32_t city, bool include_requirements, std::vector<std::tuple<uint32_t, uint32_t, bool, std::string, std::string, std::string, bool, std::vector<std::pair<std::string, bool>>>> &scripts, uint32_t script = 0, uint32_t owner = 0) const;
|
||||
bool get_cc_script(uint32_t script, std::string &name, std::string &icon, std::string &desc, std::string &blob) const;
|
||||
bool get_cc_script_state(uint32_t account, uint32_t script, uint32_t state, uint32_t city, std::string &ui, std::string &text, std::string &image, std::vector<std::tuple<uint32_t, std::string, std::string>> &choices, std::string &choices_ui, std::vector<std::tuple<uint8_t, uint32_t, std::string>> &overrides) const;
|
||||
bool get_cc_script_state(uint32_t account, uint32_t script, uint32_t state, uint32_t city, std::string &script_name, std::string &ui, std::string &text, std::string &image, std::vector<std::tuple<uint32_t, std::string, std::string>> &choices, std::string &choices_ui, std::vector<std::tuple<uint8_t, uint32_t, std::string>> &overrides) const;
|
||||
bool get_cc_global_variable(const std::string &name, uint64_t &value) const;
|
||||
bool get_cc_runestone(uint32_t flag, uint8_t x, uint8_t y, uint16_t h, cc::runestone_t &runestone) const;
|
||||
bool get_cc_blob_info(const std::vector<crypto::hash> &hashes, std::vector<uint32_t> &refs) const;
|
||||
|
@ -267,6 +267,8 @@ void UIScriptsDialog::FillScriptList(const std::shared_ptr<GameWallet> &w)
|
||||
ScriptItem *item = new ScriptItem(this, id, name.c_str(), icon.c_str(), desc.c_str(), available || mode == mode_select, requirements, mode);
|
||||
builder.AddItem(item);
|
||||
}
|
||||
|
||||
SetText("Scripts");
|
||||
}
|
||||
|
||||
void UIScriptsDialog::ProcessOverrides(std::string &s, const std::vector<std::tuple<uint8_t, uint32_t, std::string>> &overrides)
|
||||
@ -325,9 +327,9 @@ void UIScriptsDialog::FillChoiceList(const std::shared_ptr<GameWallet> &w)
|
||||
const uint32_t current_script_state = game->playerState.script_state;
|
||||
const uint32_t current_script_city = game->playerState.script_city;
|
||||
|
||||
std::string ui, text, image, choices_ui;
|
||||
std::string script_name, ui, text, image, choices_ui;
|
||||
std::vector<std::tuple<uint8_t, uint32_t, std::string>> overrides;
|
||||
if (!w->get_cc_script_state(game->playerState.id, current_script, current_script_state, current_script_city, ui, text, image, choices, choices_ui, overrides))
|
||||
if (!w->get_cc_script_state(game->playerState.id, current_script, current_script_state, current_script_city, script_name, ui, text, image, choices, choices_ui, overrides))
|
||||
{
|
||||
new MessageBox(context_, "Failed to get script");
|
||||
return;
|
||||
@ -402,6 +404,8 @@ void UIScriptsDialog::FillChoiceList(const std::shared_ptr<GameWallet> &w)
|
||||
|
||||
ProcessControlCodes(choicesLayout);
|
||||
ProcessWidgetValues(choicesLayout);
|
||||
|
||||
SetText(script_name);
|
||||
}
|
||||
|
||||
void UIScriptsDialog::Update(const std::shared_ptr<GameWallet> &w)
|
||||
|
@ -5167,6 +5167,8 @@ namespace cryptonote
|
||||
return false;
|
||||
}
|
||||
|
||||
res.script_name = cc::script::get_script_name(script);
|
||||
|
||||
cc::BlockchainStateProxy proxy(db);
|
||||
std::vector<std::tuple<uint32_t, std::string, std::string>> choices;
|
||||
std::string image, ui, choices_ui;
|
||||
|
@ -4446,6 +4446,7 @@ namespace cryptonote
|
||||
|
||||
struct response_t
|
||||
{
|
||||
std::string script_name;
|
||||
std::string ui;
|
||||
std::string text;
|
||||
std::string image;
|
||||
@ -4455,6 +4456,7 @@ namespace cryptonote
|
||||
std::string status;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(script_name)
|
||||
KV_SERIALIZE(ui)
|
||||
KV_SERIALIZE(text)
|
||||
KV_SERIALIZE(image)
|
||||
|
@ -1087,7 +1087,7 @@ private:
|
||||
bool get_cc_nonces(uint32_t num_nonces, std::vector<uint64_t> &nonces);
|
||||
bool get_cc_scripts(uint32_t account, uint32_t city, bool include_requirements, std::vector<std::tuple<uint32_t, uint32_t, bool, std::string, std::string, std::string, bool, std::vector<std::pair<std::string, bool>>>> &scripts, uint32_t script = 0, uint32_t owner = 0);
|
||||
bool get_cc_script_data(uint32_t script, std::string &name, std::string &icon, std::string &desc, std::string &blob);
|
||||
bool get_cc_script_state(uint32_t account, uint32_t script, uint32_t state, uint32_t city, std::string &ui, std::string &text, std::string &image, std::vector<std::tuple<uint32_t, std::string, std::string>> &choices, std::string &choices_ui, std::vector<std::tuple<uint8_t, uint32_t, std::string>> &overrides);
|
||||
bool get_cc_script_state(uint32_t account, uint32_t script, uint32_t state, uint32_t city, std::string &script_name, std::string &ui, std::string &text, std::string &image, std::vector<std::tuple<uint32_t, std::string, std::string>> &choices, std::string &choices_ui, std::vector<std::tuple<uint8_t, uint32_t, std::string>> &overrides);
|
||||
bool get_cc_global_variable(const std::string &name, uint64_t &value);
|
||||
bool get_cc_runestone(uint32_t flag, uint8_t x, uint8_t y, uint16_t h, cc::runestone_t &runestone);
|
||||
bool get_cc_blob_info(const std::vector<crypto::hash> &hashes, std::vector<uint32_t> &info);
|
||||
|
@ -822,7 +822,7 @@ bool wallet2::get_cc_script_data(uint32_t script, std::string &name, std::string
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wallet2::get_cc_script_state(uint32_t account, uint32_t script, uint32_t state, uint32_t city, std::string &ui, std::string &text, std::string &image, std::vector<std::tuple<uint32_t, std::string, std::string>> &choices, std::string &choices_ui, std::vector<std::tuple<uint8_t, uint32_t, std::string>> &overrides)
|
||||
bool wallet2::get_cc_script_state(uint32_t account, uint32_t script, uint32_t state, uint32_t city, std::string &script_name, std::string &ui, std::string &text, std::string &image, std::vector<std::tuple<uint32_t, std::string, std::string>> &choices, std::string &choices_ui, std::vector<std::tuple<uint8_t, uint32_t, std::string>> &overrides)
|
||||
{
|
||||
cryptonote::COMMAND_RPC_CC_GET_SCRIPT_STATE::request req = AUTO_VAL_INIT(req);
|
||||
cryptonote::COMMAND_RPC_CC_GET_SCRIPT_STATE::response res;
|
||||
@ -838,6 +838,7 @@ bool wallet2::get_cc_script_state(uint32_t account, uint32_t script, uint32_t st
|
||||
if (!r || res.status != CORE_RPC_STATUS_OK)
|
||||
return false;
|
||||
|
||||
script_name = std::move(res.script_name);
|
||||
if (!res.ui.empty() && !epee::string_tools::parse_hexstr_to_binbuff(res.ui, ui))
|
||||
return false;
|
||||
if (!res.choices_ui.empty() && !epee::string_tools::parse_hexstr_to_binbuff(res.choices_ui, choices_ui))
|
||||
|
Loading…
Reference in New Issue
Block a user