[Freeciv-Dev] Re: client string options: choosing from a list (v3) (PR#1
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Baumans writes:
> > Baumans wrote:
> >
> > > Here's an implementation for the gtk and gtk-2.0 clients that I like
> better
> > > (it's actually raimar's patch + the new gtk stuff). It's quite a bit
> > > shorter, at least.
> >
> > Yes, much nicer than my patch. Obviously, I don't know much GTK.
> >
> > > I've noticed a problem I get when I run this patch: sound doesn't play.
> I'm
> > > not sure why though, as everything is set up right, I think. I made sure
> to
> > > change the soundspec to remove the ending.
> >
> > I cannot test this, as I have no sound...
> Fixed. It was just a typo. Here's a new version of the patch.
And here is the stuff for the win32 client.
If the interface does not change it can be commited when the other
stuff is commited.
Greetings
Andreas Kemnade
Index: client/gui-win32/optiondlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/optiondlg.c,v
retrieving revision 1.8
diff -u -r1.8 optiondlg.c
--- client/gui-win32/optiondlg.c 2002/07/23 02:47:38 1.8
+++ client/gui-win32/optiondlg.c 2002/08/13 18:46:01
@@ -55,8 +55,11 @@
sscanf(dp, "%d", o->p_int_value);
break;
case COT_STR:
- GetWindowText((HWND)(o->p_gui_data),dp,sizeof(dp));
- mystrlcpy(o->p_string_value, dp, o->string_length);
+ if (!o->p_gui_data) {
+ break;
+ }
+ GetWindowText((HWND)(o->p_gui_data),o->p_string_value,
+ o->string_length);
break;
}
}
@@ -109,9 +112,28 @@
case COT_STR:
fcwin_box_add_static(vbox_labels,_(o->description),
0,SS_LEFT,TRUE,TRUE,0);
- o->p_gui_data=(void *)
- fcwin_box_add_edit(vbox,"",40,0,0,TRUE,TRUE,0);
- break;
+ if (o->p_string_vals) {
+ const char **vals = (*o->p_string_vals)();
+ if (!vals[0]) {
+ fcwin_box_add_static(vbox, o->p_string_value, 0, SS_LEFT,
+ TRUE, TRUE, 0);
+ o->p_gui_data = NULL;
+ } else {
+ int j;
+ o->p_gui_data =
+ fcwin_box_add_combo(vbox, 5,
+ 0,
+ WS_VSCROLL | CBS_DROPDOWNLIST | CBS_SORT,
+ TRUE, TRUE, 0);
+ for(j = 0; vals[j]; j++) {
+ ComboBox_AddString(o->p_gui_data, vals[j]);
+ }
+ }
+ } else {
+ o->p_gui_data=(void *)
+ fcwin_box_add_edit(vbox,"",40,0,0,TRUE,TRUE,0);
+ break;
+ }
}
}
fcwin_box_add_box(hbox,vbox_labels,TRUE,TRUE,0);
@@ -144,7 +166,17 @@
SetWindowText((HWND)(o->p_gui_data), valstr);
break;
case COT_STR:
- SetWindowText((HWND)(o->p_gui_data), o->p_string_value);
+ if (!o->p_gui_data)
+ break;
+ if (o->p_string_vals) {
+ int i;
+ i = ComboBox_FindStringExact(o->p_gui_data, 0, o->p_string_value);
+ if (i == CB_ERR)
+ i = ComboBox_AddString(o->p_gui_data, o->p_string_value);
+ ComboBox_SetCurSel(o->p_gui_data, i);
+ } else {
+ SetWindowText((HWND)(o->p_gui_data), o->p_string_value);
+ }
break;
}
}
|
|