MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / BuddyDisplay

Function BuddyDisplay

Descent3/buddymenu.cpp:102–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100static void BuddyProcessCommand(int res);
101
102void BuddyDisplay(void) {
103 newuiTiledWindow gbcommand_wnd;
104 newuiSheet *sheet;
105 bool exit_menu = false;
106 int strs_to_print, index, height;
107
108 if (Game_mode & GM_MULTI && (!(Netgame.flags & NF_ALLOWGUIDEBOT))) {
109 // only in single player games, and multiplayer games that allow guidebot
110 return;
111 }
112
113 strs_to_print = 0;
114
115 if (BuddyBotDownloadData() != 1)
116 return;
117
118 gbcommand_wnd.Create(Guidebot_menu_data.title, 0, 0, WND_HELP_W, WND_HELP_H);
119 sheet = gbcommand_wnd.GetSheet();
120
121 // add commands
122 sheet->NewGroup(NULL, 10, 10);
123 gbcommand_wnd.AddAcceleratorKey(KEY_F4, UID_CANCEL);
124
125 for (index = 0; index < Guidebot_menu_data.num_commands; index++) {
126 char buf[256 + 32], buf2[256 + 32];
127 if (index < 9) {
128 snprintf(buf, sizeof(buf), "%d. %s", index + 1, Guidebot_menu_data.command_text[index]);
129 } else {
130 snprintf(buf, sizeof(buf), "%c. %s", 'A' + (index - 9), Guidebot_menu_data.command_text[index]);
131 }
132
133 textaux_WordWrap(buf, buf2, BUDDYMENU_ITEM_W, MONITOR9_NEWUI_FONT);
134 grtext_SetFont(MONITOR9_NEWUI_FONT);
135 height = grtext_GetTextHeight(buf2);
136
137 sheet->AddHotspot(buf, BUDDYMENU_ITEM_W, height, index + UID_BUDDYCMD,
138 (index == 0 || index == (Guidebot_menu_data.num_commands - 1)) ? true : false);
139 if (index < (N_WINDOW_ACCELS - 1)) {
140 if (index < 9) {
141 int key = ddio_AsciiToKey('1' + index);
142 gbcommand_wnd.AddAcceleratorKey(key, index + UID_BUDDYCMD);
143 } else {
144 int key = ddio_AsciiToKey('a' + (index - 9));
145 gbcommand_wnd.AddAcceleratorKey(key, index + UID_BUDDYCMD);
146 }
147 }
148 }
149
150 // Double space
151 sheet->NewGroup(NULL, WND_HELP_W - 240, WND_HELP_H - 96, NEWUI_ALIGN_HORIZ);
152 sheet->AddLongButton(TXT_PRESSESCRET, UID_CANCEL);
153 gbcommand_wnd.AddAcceleratorKey(KEY_ESC, UID_OK);
154
155 gbcommand_wnd.Open();
156
157 // Mouse clicks from gameplay will be read by the dialog without this flush
158 ddio_MouseQueueFlush();
159

Callers 1

RunGameMenuFunction · 0.85

Calls 15

BuddyBotDownloadDataFunction · 0.85
textaux_WordWrapFunction · 0.85
grtext_SetFontFunction · 0.85
grtext_GetTextHeightFunction · 0.85
ddio_AsciiToKeyFunction · 0.85
ddio_MouseQueueFlushFunction · 0.85
BuddyProcessCommandFunction · 0.85
GetSheetMethod · 0.80
NewGroupMethod · 0.80
AddAcceleratorKeyMethod · 0.80
AddHotspotMethod · 0.80
AddLongButtonMethod · 0.80

Tested by

no test coverage detected