game: add information buttons in get-items dialog.
This commit is contained in:
@@ -59,11 +59,19 @@
|
||||
</text>
|
||||
<text name='prompt' top='347' left='1' width='66' height='79'/>
|
||||
<text name='item1-weight' top='37' left='319' width='78' height='18'/>
|
||||
<button name='item1-info' type='help' top='37' left='386'/>
|
||||
<text name='item2-weight' top='74' left='319' width='78' height='18'/>
|
||||
<button name='item2-info' type='help' top='74' left='386'/>
|
||||
<text name='item3-weight' top='111' left='319' width='78' height='18'/>
|
||||
<button name='item3-info' type='help' top='111' left='386'/>
|
||||
<text name='item4-weight' top='148' left='319' width='78' height='18'/>
|
||||
<button name='item4-info' type='help' top='148' left='386'/>
|
||||
<text name='item5-weight' top='185' left='319' width='78' height='18'/>
|
||||
<button name='item5-info' type='help' top='185' left='386'/>
|
||||
<text name='item6-weight' top='222' left='319' width='78' height='18'/>
|
||||
<button name='item6-info' type='help' top='222' left='386'/>
|
||||
<text name='item7-weight' top='259' left='319' width='78' height='18'/>
|
||||
<button name='item7-info' type='help' top='259' left='386'/>
|
||||
<text name='item8-weight' top='297' left='319' width='78' height='18'/>
|
||||
<button name='item8-info' type='help' top='297' left='386'/>
|
||||
</dialog>
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include "message.hpp"
|
||||
#include "prefs.hpp"
|
||||
#include <array>
|
||||
#include "view_dialogs.hpp"
|
||||
#include "winutil.hpp"
|
||||
#include "cursors.hpp"
|
||||
|
||||
@@ -401,6 +402,7 @@ static void put_item_graphics(cDialog& me, size_t& first_item_shown, short& curr
|
||||
std::string pict = sout.str() + "-g", name = sout.str() + "-name";
|
||||
std::string detail = sout.str() + "-detail", weight = sout.str() + "-weight";
|
||||
std::string key = sout.str() + "-key";
|
||||
std::string info = sout.str() + "-info";
|
||||
key_stash[0] = 'a' + i;
|
||||
|
||||
// TODO: Rework this so that no exceptions are required
|
||||
@@ -414,12 +416,14 @@ static void put_item_graphics(cDialog& me, size_t& first_item_shown, short& curr
|
||||
me[detail].setText(get_item_interesting_string(item));
|
||||
me[weight].setText("Weight: " + std::to_string(item.item_weight()));
|
||||
me[key].setText(key_stash);
|
||||
me[info].show();
|
||||
} else { // erase the spot
|
||||
me[pict].hide();
|
||||
me[name].setText("");
|
||||
me[detail].setText("");
|
||||
me[weight].setText("");
|
||||
me[key].setText("");
|
||||
me[info].hide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,6 +461,17 @@ static bool display_item_event_filter(cDialog& me, std::string id, size_t& first
|
||||
} else if(id.substr(0,2) == "pc") {
|
||||
current_getting_pc = id[2] - '1';
|
||||
put_item_graphics(me, first_item_shown, current_getting_pc, item_array);
|
||||
} else if(id.substr(0,4) == "item" && id.length()==10 && id.substr(5,5)=="-info") {
|
||||
size_t item_hit;
|
||||
item_hit = id[4] - '1';
|
||||
item_hit += first_item_shown;
|
||||
if(item_hit >= item_array.size()) return true;
|
||||
cDialog itemInfo("item-info",&me);
|
||||
itemInfo.attachClickHandlers([](cDialog&me, std::string const &id,eKeyMod){if (id=="done") me.toast(true); return true;}, {"done","left","right","id","magic"});
|
||||
itemInfo["left"].hide();
|
||||
itemInfo["right"].hide();
|
||||
put_item_info(itemInfo,*item_array[item_hit],univ.scenario);
|
||||
itemInfo.run();
|
||||
} else {
|
||||
if(current_getting_pc == 6) return true;
|
||||
size_t item_hit;
|
||||
@@ -567,6 +582,9 @@ bool show_get_items(std::string titleText, std::vector<cItem*>& itemRefs, short
|
||||
sout << "item" << i << "-key";
|
||||
itemDialog[sout.str()].attachKey({false, static_cast<unsigned char>('`' + i), mod_none});
|
||||
itemDialog[sout.str()].attachClickHandler(handler);
|
||||
sout.str("");
|
||||
sout << "item" << i << "-info";
|
||||
itemDialog[sout.str()].attachClickHandler(handler);
|
||||
}
|
||||
put_item_graphics(itemDialog, first_item, pc_getting, itemRefs);
|
||||
|
||||
|
Reference in New Issue
Block a user