26 #include "../common/p_cmd.h"
31 gtk_text_set_point(GTK_TEXT(
chelptext), 0);
32 gtk_text_forward_delete(GTK_TEXT(
chelptext), gtk_text_get_length(GTK_TEXT(
chelptext)) );
33 gtk_text_insert(GTK_TEXT(
chelptext), NULL, &
chelptext->style->black, NULL, new_text, -1);
36 #define CLIENTHELP_LONG_LIST
38 #define assumed_wrap 120
39 #define COLOSSAL_BUF 8192
49 #ifndef CLIENTHELP_LONG_LIST
59 #define LINE(x) strncpy(tmp_buf, out_buf, COLOSSAL_BUF - 1); snprintf(out_buf, COLOSSAL_BUF - 1, "%s%s\n", tmp_buf, x);
62 "To get help on one of the commands listed below, enter the name in the text entry "
63 "box below, and press Enter. To get back to this list, clear the text box and press "
66 " === Client Side Command List === \n"
73 if (cc->
cat != current_cat) {
76 #ifndef CLIENTHELP_LONG_LIST
86 current_cat = cc->
cat;
89 #ifdef CLIENTHELP_LONG_LIST
90 if (cc->
desc != NULL) {
98 name_len = strlen(cc->
name);
108 strncpy(line_buf, cc->
name, name_len + 1);
112 strncat(line_buf,
" ", 2);
115 strncat(line_buf, cc->
name, name_len + 1);
116 line_len += name_len;
121 #ifndef CLIENTHELP_LONG_LIST
138 topic = gtk_entry_get_text(GTK_ENTRY(topic_entry));
141 if (topic == NULL || strlen(topic) <= 0) {
149 snprintf(buf,
MAX_BUF - 1,
"No command '%s' found.", topic);
153 const char * extended;
155 if (cc->
desc != NULL) {
156 snprintf(buf,
MAX_BUF - 1,
"%s - %s",
164 extended =
"This command is undocumented.";
167 if (extended == NULL) {
168 extended =
"This command is not yet documented.";
172 snprintf(out_buf,
COLOSSAL_BUF - 1,
"%s Command:\n%s\n\n%s",
185 GtkWidget *helpbutton;
186 GtkWidget *vscrollbar;
187 GtkWidget * topic_entry;
188 GtkWidget * lblCommand;
195 gtk_window_position (GTK_WINDOW (
gtkwin_chelp), GTK_WIN_POS_CENTER);
197 gtk_window_set_title (GTK_WINDOW (
gtkwin_chelp),
"Crossfire Client-Side Command Help");
202 gtk_container_border_width (GTK_CONTAINER (
gtkwin_chelp), 1);
203 vbox = gtk_vbox_new(
FALSE, 2);
205 hbox = gtk_hbox_new(
FALSE, 2);
206 gtk_box_pack_start (GTK_BOX (vbox), hbox,
TRUE,
TRUE, 0);
213 vscrollbar = gtk_vscrollbar_new (GTK_TEXT (
chelptext)->vadj);
214 gtk_box_pack_start (GTK_BOX (hbox),vscrollbar,
FALSE,
FALSE, 0);
216 gtk_widget_show (vscrollbar);
217 gtk_widget_show (hbox);
219 hbox = gtk_hbox_new(
FALSE, 2);
220 lblCommand = gtk_label_new(
"Command: ");
221 gtk_box_pack_start(GTK_BOX(hbox), lblCommand,
FALSE,
FALSE, 0);
223 topic_entry = gtk_entry_new ();
224 gtk_box_pack_start (GTK_BOX (hbox), topic_entry,
TRUE,
TRUE, 0);
225 gtk_signal_connect(GTK_OBJECT(topic_entry),
"activate",
230 helpbutton = gtk_button_new_with_label (
"Close");
231 gtk_signal_connect_object (GTK_OBJECT (helpbutton),
"clicked",
232 GTK_SIGNAL_FUNC(gtk_widget_destroy),
234 gtk_box_pack_end (GTK_BOX (hbox), helpbutton,
FALSE,
FALSE, 0);
235 gtk_box_pack_start (GTK_BOX (vbox), hbox,
FALSE,
FALSE, 0);
236 gtk_widget_show (lblCommand);
237 gtk_widget_show (topic_entry);
238 gtk_widget_show (helpbutton);
239 gtk_widget_show (hbox);
241 gtk_widget_show (vbox);
void chelpdialog(GtkWidget *widget)
static void set_default_text(void)
const char * get_category_name(CommCat cat)
int get_num_commands(void)
const ConsoleCommand * find_command(const char *cmd)
static GtkWidget * chelptext
static void chelp_entry_callback(GtkWidget *cargo_cult_ignored, GtkWidget *topic_entry)
static GtkWidget * gtkwin_chelp
static void replace_text(const char *new_text)
ConsoleCommand ** get_cat_sorted_commands(void)