Previous 15994 Revisions Next

r7992 Friday 7th May, 2010 at 18:39:16 UTC by Firewave
[NEWUI] More input customization code cleanups
[src/mess/osd/windows]dialog.c dialog.h menu.c

src/mess/osd/windows/dialog.c
r7991r7992
12981298//  win_dialog_add_seqselect
12991299//============================================================
13001300
1301int win_dialog_add_portselect(dialog_box *dialog, const input_field_config *field, const RECT *r)
1301int win_dialog_add_portselect(dialog_box *dialog, const input_field_config *field)
13021302{
13031303   dialog_box *di = dialog;
13041304   short x;
r7991r7992
13561356         strcpy(s + len, port_suffix[seq]);
13571357      this_port_name = s;
13581358
1359      if (!r)
1360      {
1361         // no positions specified
1362         dialog_new_control(di, &x, &y);
1359      // no positions specified
1360      dialog_new_control(di, &x, &y);
13631361
1364         if (dialog_write_item(di, WS_CHILD | WS_VISIBLE | SS_LEFT | SS_NOPREFIX, x, y,
1365               dialog->layout->label_width, DIM_NORMAL_ROW_HEIGHT, this_port_name, DLGITEM_STATIC, NULL))
1366            return 1;
1367         x += dialog->layout->label_width + DIM_HORIZONTAL_SPACING;
1362      if (dialog_write_item(di, WS_CHILD | WS_VISIBLE | SS_LEFT | SS_NOPREFIX, x, y,
1363            dialog->layout->label_width, DIM_NORMAL_ROW_HEIGHT, this_port_name, DLGITEM_STATIC, NULL))
1364         return 1;
1365      x += dialog->layout->label_width + DIM_HORIZONTAL_SPACING;
13681366
1369         if (dialog_add_single_seqselect(di, x, y, DIM_EDIT_WIDTH, DIM_NORMAL_ROW_HEIGHT,
1370               field, is_analog[seq], seq_types[seq]))
1371            return 1;
1372         y += DIM_VERTICAL_SPACING + DIM_NORMAL_ROW_HEIGHT;
1373         x += DIM_EDIT_WIDTH + DIM_HORIZONTAL_SPACING;
1367      if (dialog_add_single_seqselect(di, x, y, DIM_EDIT_WIDTH, DIM_NORMAL_ROW_HEIGHT,
1368            field, is_analog[seq], seq_types[seq]))
1369         return 1;
1370      y += DIM_VERTICAL_SPACING + DIM_NORMAL_ROW_HEIGHT;
1371      x += DIM_EDIT_WIDTH + DIM_HORIZONTAL_SPACING;
13741372
1375         dialog_finish_control(di, x, y);
1376      }
1377      else
1378      {
1379         // positions specified
1380         x = r[seq].left;
1381         y = r[seq].top;
1382         width = r[seq].right - r[seq].left;
1383         height = r[seq].bottom - r[seq].top;
1384
1385         calc_dlgunits_multiple();
1386         x      /= pixels_to_xdlgunits;
1387         y      /= pixels_to_ydlgunits;
1388         width   /= pixels_to_xdlgunits;
1389         height   /= pixels_to_ydlgunits;
1390
1391         if (dialog_add_single_seqselect(di, x, y, width, height,
1392               field, is_analog[seq], seq_types[seq]))
1393            return 1;
1394      }
1373      dialog_finish_control(di, x, y);
13951374   }
13961375   return 0;
13971376}
src/mess/osd/windows/dialog.h
r7991r7992
5757   int min_value, int max_value,
5858   dialog_itemstoreval storeval, void *storeval_param);
5959
60int win_dialog_add_portselect(dialog_box *dialog, const input_field_config *field, const RECT *r);
60int win_dialog_add_portselect(dialog_box *dialog, const input_field_config *field);
6161
6262int win_dialog_add_standard_buttons(dialog_box *dialog);
6363int win_dialog_add_image(dialog_box *dialog, const png_info *png);
src/mess/osd/windows/menu.c
r7991r7992
100100
101101static int add_filter_entry(char *dest, size_t dest_len, const char *description, const char *extensions);
102102
103/***************************************************************************
104103
105    Constants
106104
107***************************************************************************/
108
109typedef enum
110{
111   ARTWORK_CUSTTYPE_JOYSTICK = 0,
112   ARTWORK_CUSTTYPE_KEYBOARD,
113   ARTWORK_CUSTTYPE_MISC,
114   ARTWORK_CUSTTYPE_INVALID
115} artwork_cust_type;
116
117
118
119/***************************************************************************
120
121    Type definitions
122
123***************************************************************************/
124
125struct inputform_customization
126{
127   UINT32 ipt;
128   int x, y;
129   int width, height;
130};
131
132
133105//============================================================
134//  artwork_get_inputscreen_customizations
135//============================================================
136
137int artwork_get_inputscreen_customizations(struct inputform_customization *customizations,   int customizations_length)
138{
139   /* terminate list */
140   customizations->ipt = IPT_END;
141   customizations->x = -1;
142   customizations->y = -1;
143   customizations->width = -1;
144   customizations->height = -1;
145
146   return 0;
147}
148
149
150//============================================================
151106//  input_item_from_serial_number
152107//============================================================
153108
r7991r7992
237192   dialog_box *dlg;
238193   const input_port_config *port;
239194   const input_field_config *field;
240   struct inputform_customization customizations[128];
241   RECT *pr;
242   int this_inputclass, this_player, portslot_count, i;
195   int this_inputclass, this_player, portslot_count = 0, i;
243196
244197   struct
245198   {
246199      const input_field_config *field;
247      const RECT *pr;
248200   } portslots[256];
249201
250   /* check to see if there is any custom artwork for this configure dialog,
251     * and if so, retrieve the info */
252   portslot_count = artwork_get_inputscreen_customizations(customizations, ARRAY_LENGTH(customizations));
253
254   /* zero out the portslots that correspond to customizations */
255   memset(portslots, 0, sizeof(portslots[0]) * portslot_count);
256
257202   /* create the dialog */
258203   dlg = win_dialog_init(title, NULL);
259204   if (!dlg)
r7991r7992
276221
277222            if (this_player == player)
278223            {
279               /* check to see if the custom artwork for this configure dialog
280                     * says anything about this input */
281               pr = NULL;
282               for (i = 0; customizations[i].ipt != IPT_END; i++)
283               {
284                  if (field->type == customizations[i].ipt)
285                  {
286                     pr = (RECT *) alloca(sizeof(*pr));
287                     pr->left = customizations[i].x;
288                     pr->top = customizations[i].y;
289                     pr->right = pr->left + customizations[i].width;
290                     pr->bottom = pr->top + customizations[i].height;
291                     break;
292                  }
293               }
294
295224               /* store this InputPort/RECT combo in our list.  we do not
296225                     * necessarily want to add it yet because we the INI might
297226                     * want to reorder the tab order */
298               if (customizations[i].ipt == IPT_END)
299                  i = portslot_count++;
300               if (i < ARRAY_LENGTH(portslots))
227               if (portslot_count < ARRAY_LENGTH(portslots))
301228               {
302                  portslots[i].field = field;
303                  portslots[i].pr = pr;
229                  portslots[portslot_count].field = field;
304230               }
231               portslot_count++;
305232            }
306233         }
307234      }
r7991r7992
314241   {
315242      if (portslots[i].field)
316243      {
317         if (win_dialog_add_portselect(dlg, portslots[i].field, portslots[i].pr))
244         if (win_dialog_add_portselect(dlg, portslots[i].field))
318245            goto done;
319246      }
320247   }

Previous 15994 Revisions Next


© 1998-2018 The MESS Team