File: dialog.c

package info (click to toggle)
gfpoken 1-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,944 kB
  • sloc: ansic: 2,984; sh: 1,446; makefile: 125
file content (526 lines) | stat: -rw-r--r-- 18,169 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
/* dialog.c - GFingerPoken Configuration Dialog
 * Copyright 1999-2000  Martin Hock
 * Copyright 2005  Bas Wijnen <wijnen@debian.org>
 *
 * This file is part of Gfingerpoken.
 *
 * Gfingerpoken is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Gfingerpoken is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <stdlib.h> /* For initlevel */
#include <stdio.h> /* For error messages */
#include <string.h> /* For config file string manipulation */
#include "gfp.h"
#include "common.h"
#include "graphics.h"



GtkWidget *dialogwin, *dialoggrid;

GtkWidget *dialogbar;
GtkWidget *dialogbarbut[NumDialogIcons];

GtkWidget *proppack, *propscale[4], *proplabel[4]; /* X, Y, density, fuzz */
GtkObject *propadjustment[4];

GtkWidget *classpack[NumClasses], *classlabel[NumClasses], *classpicpack[NumClasses], 
  *classpicleft[NumClasses], *classpicright[NumClasses], *classcale[NumClasses]; /* Simple mirrors, rotators, etc. */
GtkObject *classadjustment[NumClasses];

GtkWidget *buttonpack, *okbutton, *cancelbutton;


/*
obj testgrid[] = {1, 0, 2, 0, 0, 0,
		  0, 0, 2, 1, 2, 1,
		  0, 1, 0, 1, 1, 0,
		  0, 2, 0, 0, 0, 1,
		  1, 0, 2, 0, 0, 0,
		  0, 1, 0, 0, 0, 0};

obj testinvisigrid[] = {0, 0, 0, 1, 2, 0,
			0, 1, 0, 1, 1, 1,
			0, 1, 0, 0, 0, 2,
			0, 2, 0, 0, 0, 1,
			1, 0, 2, 0, 0, 0,
			0, 1, 0, 0, 0, 2};
*/
void initlevel() { /* Create new level, put it in grid, etc. */
  int counter=0, upperbound=0, sum=0, randinc=gridx*gridy+1, randland=0, randpop=0, randchoice=0;
  obj tempobj=ObNone;
  pos x=0, y=0;
  for (; counter < DrNum; counter++) dragbuf[counter] = 0;
  arrhistptr = 0;
  for (counter = 0; counter < histsize; counter++) {
    arrinused[counter] = 0;
    arroutused[counter] = 0;
  }
  bufsize = 0; 
  checked = 0;
  for (counter=0; counter < NumClasses; counter++) sum += classweight[counter];
  /* empty = (int)((double)sum/(double)(fill/100)) + sum; */


  if (grid) free(grid); grid = (obj *)calloc(gridx*gridy, sizeof(obj));
  if (invisigrid) free(invisigrid); invisigrid = (obj *)calloc(gridx*gridy, sizeof(obj));
  if (markgrid) free(markgrid); markgrid = (obj *)calloc(gridx*gridy, sizeof(obj));
  if (!(grid && invisigrid && markgrid)) {
    fprintf(stderr, "Insufficient memory for allocating level; needed %zd bytes\n",
	    3*gridx*gridy*sizeof(obj));
    exit(1);
  }  

  randpop = (int)(density*gridx*gridy/100 + 1);
  randpop += (random() % (int)(randpop*densityfuzz*2/100 + 1)) - (int)(randpop*densityfuzz/100);
  if (randpop > gridx*gridy) randpop = gridx*gridy;
  if (randpop < 0) randpop = 0;
  for (; randpop > 0; randpop--) {
    randland = random() % randinc;
    randinc--;
    x=0; y=0;
    while (y < gridy) {
      if (!(invisigrid[x+gridx*y] || --randland)) {
	randchoice = random() % sum;
	upperbound = 0;
	for (counter=0; counter < NumClasses; counter++) {
	  upperbound += classweight[counter];
	  if (upperbound == 0) continue; /* Base case */
	  if (randchoice < upperbound) {
	    switch (counter) {
	    case ClSimple:
	      tempobj = (random() % 2)+ObSULDRMirror;
	      break;
	    case ClFlipper:
	      tempobj = (random() % 6)+ObFULDR_URDLMirror;
	      break;
	    case ClBoxSink:
	      tempobj = (random() % 2)+ObBBox;
	      break;
	    case ClAxis:
	      tempobj = (random() % 4)+ObAVertMirror;
	      break;
	    case ClRotator:
	      tempobj = (random() % 4)+ObRClock;
	      break;
	    case ClOneWay:
	      tempobj = (random() % 4)+ObOTULDRMirror;
	      break;
	    case ClEvil:
	      tempobj = (random() % 10)+ObEOFCTULDRMirror;
	      break;
	    default:
	      exit(1);
	    }
	    invisigrid[x+gridx*y] = tempobj;
	    dragbuf[objtodr(tempobj)]++;
	    bufsize++;
	    break;
	  }
	  
	}
      }
      x++; 
      if (x == gridx) {
	x = 0;
	y++;
      }
    }
  }
  if (dragbuf[DrOTULDRMirror] || dragbuf[DrOBULDRMirror] || dragbuf[DrOTURDLMirror] || dragbuf[DrOBURDLMirror] || dragbuf[DrEOFC4CycleMirror] || dragbuf[DrEOFCC4CycleMirror]) /* All the oneways */
    histkeeper = (histhash *)(!NULL); /* Any non-zero value OK - This is not a sentinel! */
  else histkeeper = NULL;
  gtk_widget_hide(mainbarbut[IFlipBoards]);
  gtk_widget_hide(mainbarbut[IFlipBack]);
}


  /* Old code for testing game with level mix similar to default.
  int x, y = 0;
  obj tempobj;
  if (grid) free(grid); grid = (obj *)calloc(gridx*gridy, sizeof(obj));
  if (invisigrid) free(invisigrid); invisigrid = (obj *)calloc(gridx*gridy, sizeof(obj));
  if (!(grid && invisigrid)) exit(0);
  for (; y < DrNum; y++) dragbuf[y] = 0;
  for (y = 0; y < gridy; y++) {
    for (x = 0; x < gridx; x++) { 
      if ((tempobj = (random() % 48)) < 12) {
        if (tempobj < 4) tempobj = tempobj/2 + 1;
        else if (tempobj < 8) tempobj = tempobj/2 + 1;
	else tempobj = tempobj - 4 + 1;
	invisigrid[x+gridx*y] = tempobj;
	dragbuf[objtodr(tempobj)]++;
	bufsize++;
      }
    }
  }
  originalbuf = bufsize;
}
  */

int savelevel(const char *filename) {
  FILE *savefile = NULL;
  int x, y=0;
  if ((savefile = fopen(filename,"w"))) { 
    fprintf(savefile, "GFPSave %d\n", GFPSaveVer); /* Assumes that everything is properly laid out */
    fprintf(savefile, "%d %d\n", gridx, gridy); /* Don't forget the sizes */
    for (; y < gridy; y++) { /* First your grid */
      for (x = 0; x < gridx; x++)
	fprintf(savefile, "%d ", grid[x+y*gridx]);
      fprintf(savefile, "\n");
    }
    for (y=0; y < gridy; y++) { /* Next the mark grid */
      for (x = 0; x < gridx; x++)
	fprintf(savefile, "%d ", markgrid[x+y*gridx]);
      fprintf(savefile, "\n");
    }
    for (y=0; y < gridy; y++) { /* Then the invisible grid */
      for (x = 0; x < gridx; x++)
	fprintf(savefile, "%d ", invisigrid[x+y*gridx]);
      fprintf(savefile, "\n");
    }
    for (y=0; y < DrNum; y++) /* Finally the drag buffer's contents */
      fprintf(savefile, "%d ", dragbuf[y]); /* Provably under 80 characters */
    fprintf(savefile, "\n");
    fclose(savefile);
    return 0;
  }
  return 1; /* Error */
}

int loadlevel(const char *filename) { /* Max 80 char width: Max 20 width levels, so A-OK */
  FILE *savefile = NULL;
  char readbuf[80];
  char header[80];
  char *p;
  int x, y=0;
  sprintf(header, "GFPSave %d\n", GFPSaveVer);
  if ((savefile = fopen(filename,"r"))) {
    if (fgets(readbuf, 79, savefile)) {
      if (!strcmp(readbuf, header)) {
	fgets(readbuf, 79, savefile);
	p = readbuf;
	gridx = strtol(p, &p, 10);
	gridy = strtol(p, &p, 10);
	if (grid) free(grid); grid = (obj *)malloc(gridx*gridy*sizeof(obj));
	if (invisigrid) free(invisigrid); invisigrid = (obj *)malloc(gridx*gridy*sizeof(obj));
	if (markgrid) free(markgrid); markgrid = (obj *)malloc(gridx*gridy*sizeof(obj));
	if (!(grid && invisigrid && markgrid)) {
	  fprintf(stderr, "Insufficient memory for allocating level; needed %zd bytes\n",
		  3*gridx*gridy*sizeof(obj));
	  exit(1);
	}  

	bufsize = checked = netmode = 0;	
	
	for (; y < gridy; y++) { /* First your grid */
	  fgets(readbuf, 79, savefile);
	  p = readbuf;
	  for (x = 0; x < gridx; x++)
	    grid[x+y*gridx] = strtol(p, &p, 10);
	}

	for (y = 0; y < gridy; y++) {  /* Next the mark grid */
	  fgets(readbuf, 79, savefile);
	  p = readbuf;
	  for (x = 0; x < gridx; x++)
	    markgrid[x+y*gridx] = strtol(p, &p, 10);
	}

	for (y = 0; y < gridy; y++) {  /* Then the invisible grid */
	  fgets(readbuf, 79, savefile);
	  p = readbuf;
	  for (x = 0; x < gridx; x++)
	    invisigrid[x+y*gridx] = strtol(p, &p, 10);
	}

	fgets(readbuf, 79, savefile);
	p = readbuf;
	for (y = 0; y < DrNum; y++) { /* Finally the drag buffer's contents */
	  dragbuf[y] = strtol(p, &p, 10);
	  bufsize += dragbuf[y];
	}

	fclose(savefile);
	return 0;
      }
    }
    fclose(savefile);
  }
  return 1; /* Error */
}

void filesel_destroy_event(GtkWidget *widget, G_GNUC_UNUSED gpointer data) {
  gtk_grab_remove(widget);
}


/*
static gint filecancelbutton_clicked(GtkWidget *widget, gpointer data) {
  gtk_widget_destroy(data);
}
*/

static gint openfileok_button_clicked(G_GNUC_UNUSED GtkWidget *widget, gpointer data) {
  if (loadlevel(gtk_file_selection_get_filename(GTK_FILE_SELECTION(data)))) {
    gamebox("Error", "Could not load file");
    gtk_widget_destroy(data);
  }
  resizelevel();
  gtk_widget_show(mainwin);
  fullgriddraw();
  bardraw();
  gtk_widget_hide(dialogwin);
  gtk_widget_show(dialogbarbut[ISave-NumMainIcons]);
  gamestatus = 1;
  checked = 0;
  netmode = 0;
  gtk_widget_destroy(data);
  return FALSE;
}

static gint savefileok_button_clicked(G_GNUC_UNUSED GtkWidget *widget, gpointer data) {
  if (savelevel(gtk_file_selection_get_filename(GTK_FILE_SELECTION(data)))) 
    gamebox("Error", "Could not save level");
  gtk_widget_destroy(data);
  return FALSE;
}


static gint openbarbut_event(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED gpointer data) {
  GtkWidget *filesel = gtk_file_selection_new("Open GFP Game");
  gtk_signal_connect(GTK_OBJECT(filesel), "destroy", (GtkSignalFunc)filesel_destroy_event, filesel);
  gtk_window_set_modal(GTK_WINDOW(filesel), TRUE);
  gtk_file_selection_complete(GTK_FILE_SELECTION(filesel), "*.gfp");
  gtk_signal_connect_object(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->cancel_button), "clicked", 
			    (GtkSignalFunc)gtk_widget_destroy, GTK_OBJECT(filesel));
  gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button), "clicked", 
		     (GtkSignalFunc)openfileok_button_clicked, filesel);
  gtk_widget_show(filesel);
  return FALSE;
}

static gint savebarbut_event(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED gpointer data) {
  GtkWidget *filesel = gtk_file_selection_new("Save GFP Game");
  gtk_signal_connect(GTK_OBJECT(filesel), "destroy", (GtkSignalFunc)filesel_destroy_event, filesel);
  gtk_window_set_modal(GTK_WINDOW(filesel), TRUE);
  gtk_file_selection_complete(GTK_FILE_SELECTION(filesel), "*.gfp");
  gtk_signal_connect_object(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->cancel_button), "clicked", 
			    (GtkSignalFunc)gtk_widget_destroy, GTK_OBJECT(filesel));
  gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button), "clicked", 
		     (GtkSignalFunc)savefileok_button_clicked, filesel);
  gtk_widget_show(filesel);
  return FALSE;
}

static gint dialogwin_delete_event(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED GdkEvent *event, G_GNUC_UNUSED gpointer data) {
  if (netmode) return FALSE;
  if (gamestatus == 0) {
    gtk_main_quit();
    return FALSE;
  }
  gtk_widget_hide(dialogwin);
  gtk_widget_show(mainwin);
  return TRUE;
}

static gint cancelbutton_clicked(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED gpointer data) {
  if (netmode) return FALSE;
    if (gamestatus == 0) {
    gtk_main_quit();
    return FALSE;
  }
  gtk_widget_hide(dialogwin);
  /* if (setmainpos) gtk_widget_set_uposition(mainwin, mainxpos, mainypos); */
  gtk_widget_show(mainwin);
  gdk_window_show(mainwin->window);
  return TRUE;
}

static gint okbutton_clicked(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED gpointer data) {
  int i=0, tempsum=0;
  FILE *configfile;
  char configloc[80]; /* Good Enough */
  for (; i < NumClasses; i++) {
    classweight[i] = GTK_ADJUSTMENT(classadjustment[i])->value;
    tempsum += classweight[i];
  }
  if (tempsum == 0 ) return FALSE; /* Nothing selected */
  gridx = GTK_ADJUSTMENT(propadjustment[0])->value; 
  gridy = GTK_ADJUSTMENT(propadjustment[1])->value;
  density = GTK_ADJUSTMENT(propadjustment[2])->value; 
  densityfuzz = GTK_ADJUSTMENT(propadjustment[3])->value;
  strncpy(configloc,getenv("HOME"),65);
  strcat(configloc,"/.gfpoken");
  if ((configfile = fopen(configloc,"w"))) {
    fprintf(configfile, "%d\n",GFPVersion);
    fprintf(configfile, "%d %d %d %d %d %d %d %d %d %d %d\n", gridx, gridy, density, densityfuzz,
	    classweight[0], classweight[1], classweight[2], classweight[3], classweight[4],
	    classweight[5], classweight[6]);
    fclose(configfile);
  }
  /*
    toolscroll->requisition.width = 0;
    toolscroll->requisition.height = 0;
    levelscroll->requisition.width = 0;
    levelscroll->requisition.height = 0;
  */

  resizelevel();

  /* if (setmainpos) gtk_widget_set_uposition(mainwin, mainxpos, mainypos);  */
  
  if (netmode) { 
    initlevel();
    gtk_widget_hide(dialogwin);
    netsend('S', gridx, gridy);
    return FALSE;
  } else {
    gtk_widget_show(mainwin);
    initlevel();
  }
  fullgriddraw();
  bardraw();
  gtk_widget_hide(dialogwin);
  gtk_widget_show(dialogbarbut[ISave-NumMainIcons]);
  gamestatus = 1;
  return FALSE;
}



void initdialog() {
  int i=0, x=1, y=0;
  FILE *configfile=NULL;
  char readbuf[80];
  int version;
  strncpy(readbuf,getenv("HOME"),65);
  strcat(readbuf,"/.gfpoken");
  if ((configfile = fopen(readbuf,"r"))) {
    if (fgets(readbuf, 80, configfile)) {
      if (sscanf(readbuf, "%d", &version)) {
	if (version == GFPVersion) {
	  if (fgets(readbuf, 80, configfile)) {
	    char *p = readbuf;

	    gridx          = strtol(p, &p, 10);
	    gridy          = strtol(p, &p, 10);
	    density        = strtol(p, &p, 10);
	    densityfuzz    = strtol(p, &p, 10);
	    classweight[0] = strtol(p, &p, 10);
	    classweight[1] = strtol(p, &p, 10);
	    classweight[2] = strtol(p, &p, 10);
	    classweight[3] = strtol(p, &p, 10);
	    classweight[4] = strtol(p, &p, 10);
	    classweight[5] = strtol(p, &p, 10);
	    classweight[6] = strtol(p, &p, 10);
	  }
	}
      }
    }
  }
  if (configfile) fclose(configfile);
  dialogwin = gtk_dialog_new();
  gtk_window_set_title(GTK_WINDOW(dialogwin),"GFP Configuration");
  gtk_signal_connect(GTK_OBJECT(dialogwin), "delete_event", (GtkSignalFunc)dialogwin_delete_event, NULL);

  dialogbar = gtk_toolbar_new();
  gtk_toolbar_set_orientation(GTK_TOOLBAR(dialogbar), GTK_ORIENTATION_HORIZONTAL);
  gtk_toolbar_set_style(GTK_TOOLBAR(dialogbar), GTK_TOOLBAR_ICONS);
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogwin)->vbox), dialogbar, FALSE, FALSE, 0);
  gtk_widget_show(dialogbar);

  dialoggrid = gtk_table_new(2, 5, TRUE);
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogwin)->vbox), dialoggrid, FALSE, FALSE, 0);
  gtk_widget_show(dialoggrid);
  while (i < NumClasses) {
    classpack[i] = gtk_vbox_new(TRUE, 0);
    gtk_table_attach_defaults(GTK_TABLE(dialoggrid), classpack[i], x, x+1, y, y+1);
    classlabel[i] = gtk_label_new(classname(i));
    gtk_box_pack_start(GTK_BOX(classpack[i]), classlabel[i], TRUE, FALSE, 0);
    classpicpack[i] = gtk_hbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(classpack[i]), classpicpack[i], TRUE, TRUE, 0);
    classpicleft[i] = gtk_pixmap_new(tilepic[classleftpic(i)], NULL);
    gtk_box_pack_start(GTK_BOX(classpicpack[i]), classpicleft[i], TRUE, FALSE, 0);
    classpicright[i] = gtk_pixmap_new(tilepic[classrightpic(i)], NULL);
    gtk_box_pack_start(GTK_BOX(classpicpack[i]), classpicright[i], TRUE, FALSE, 0);    
    classadjustment[i]=gtk_adjustment_new(classweight[i], 0, 100, 1, 10, 0);
    classcale[i] = gtk_hscale_new(GTK_ADJUSTMENT(classadjustment[i]));
    gtk_scale_set_digits(GTK_SCALE(classcale[i]), 0);
    gtk_box_pack_start(GTK_BOX(classpack[i]), classcale[i], TRUE, FALSE, 0);
    gtk_widget_show(classcale[i]);
    gtk_widget_show(classlabel[i]);
    gtk_widget_show(classpack[i]);
    gtk_widget_show(classpicpack[i]);
    gtk_widget_show(classpicleft[i]);
    gtk_widget_show(classpicright[i]);
    x++; 
    if (i == 3) {
      x=1; y++;
    }
    i++;
  }

  buttonpack = gtk_vbox_new(FALSE, 0);
  gtk_table_attach_defaults(GTK_TABLE(dialoggrid), buttonpack, 4, 5, 1, 2);
  okbutton = gtk_button_new_with_label("OK");
  /* Problematic - We'll just have it look normal.
  GTK_WIDGET_SET_FLAGS(okbutton, GTK_CAN_DEFAULT | GTK_HAS_DEFAULT | GTK_HAS_GRAB | GTK_RECEIVES_DEFAULT);
  gtk_widget_grab_default(okbutton);
  */
  cancelbutton = gtk_button_new_with_label("Cancel");
  gtk_box_pack_start(GTK_BOX(buttonpack), okbutton, TRUE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(buttonpack), cancelbutton, TRUE, FALSE, 0);
  gtk_widget_show(buttonpack);
  gtk_widget_show(okbutton);
  gtk_widget_show(cancelbutton);

  i=0;
  proppack = gtk_vbox_new(TRUE, 0);
  gtk_table_attach_defaults(GTK_TABLE(dialoggrid), proppack, 0, 1, 0, 2);
  gtk_widget_show(proppack);

  propadjustment[0] = gtk_adjustment_new(gridx, 1, 20, 1, 10, 0);
  propadjustment[1] = gtk_adjustment_new(gridy, 1, 20, 1, 10, 0);
  propadjustment[2] = gtk_adjustment_new(density, 0, 100, 1, 10, 0);
  propadjustment[3] = gtk_adjustment_new(densityfuzz, 0, 100, 1, 10, 0);

  while (i < 4) {
    proplabel[i]=gtk_label_new(propname(i));
    gtk_box_pack_start(GTK_BOX(proppack), proplabel[i], FALSE, FALSE, 0);
    propscale[i] = gtk_hscale_new(GTK_ADJUSTMENT(propadjustment[i]));
    gtk_scale_set_digits(GTK_SCALE(propscale[i]),0);
    gtk_box_pack_start(GTK_BOX(proppack), propscale[i], FALSE, FALSE, 0);
    gtk_widget_show(proplabel[i]);
    gtk_widget_show(propscale[i]);
    i++;
  }

  barpixwid[IOpen] = gtk_pixmap_new(barpix[IOpen], barmask[IOpen]);
  gtk_widget_show(barpixwid[IOpen]);
  dialogbarbut[IOpen-NumMainIcons] = gtk_toolbar_append_item(GTK_TOOLBAR(dialogbar), NULL, "Open level file", NULL, barpixwid[IOpen], (GtkSignalFunc)openbarbut_event, NULL);
  gtk_widget_show(dialogbarbut[IOpen-NumMainIcons]);

  barpixwid[ISave] = gtk_pixmap_new(barpix[ISave], barmask[ISave]);
  gtk_widget_show(barpixwid[ISave]);
  dialogbarbut[ISave-NumMainIcons] = gtk_toolbar_append_item(GTK_TOOLBAR(dialogbar), NULL, "Save level", NULL, barpixwid[ISave], (GtkSignalFunc)savebarbut_event, NULL);
  gtk_widget_hide(dialogbarbut[ISave-NumMainIcons]);


  gtk_signal_connect(GTK_OBJECT(okbutton), "clicked", (GtkSignalFunc)okbutton_clicked, NULL);
  gtk_signal_connect(GTK_OBJECT(cancelbutton), "clicked", (GtkSignalFunc)cancelbutton_clicked, NULL);
  gtk_widget_show(dialogwin);
}