Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
/*******************************************************************************
2
 
3
    MenuetOS MineSweeper
4
    Copyright (C) 2003  Ivan Poddubny
5
 
6
    This program is free software; you can redistribute it and/or modify
7
    it under the terms of the GNU General Public License as published by
8
    the Free Software Foundation; either version 2 of the License, or
9
    (at your option) any later version.
10
 
11
    This program is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
    GNU General Public License for more details.
15
 
16
    You should have received a copy of the GNU General Public License
17
    along with this program; if not, write to the Free Software
18
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 
20
*******************************************************************************/
21
 
22
// USER FIELD WINDOW
23
 
24
byte px,py,pm;
25
 
26
byte uf_open = FALSE;
27
byte uf_stack[2048];
28
 
29
byte str1[5];
30
byte str2[5];
31
byte str3[5];
32
 
33
dword uf_x,
34
      uf_y;
35
 
36
void draw_uf_window()
37
{
38
  sys_get_colors(#colors, 40);
39
  sys_window_redraw(1);
40
 
41
  EDX = colors.w_work;
42
  $bts edx,25
43
  sys_draw_window(uf_x, uf_y, EDX, colors.w_grab | 0x80000000, colors.w_frames);
44
  ECX = colors.w_grab_text | 0x10000000;
45
  sys_write_text(8<<16+8, colors.w_grab_text | 0x10000000, "USER FIELD", 10);
46
  sys_draw_button(81<<16+12, 5<<16+12, 1, colors.w_grab_button);
47
 
48
  ECX = colors.w_work_text | 0x10000000;
49
  sys_write_text(8<<16+31, ECX, "WIDTH",  5);
50
  sys_write_text(8<<16+49, ECX, "HEIGHT", 6);
51
  sys_write_text(8<<16+67, ECX, "MINES",  5);
52
 
53
  // three buttons:
54
  //  1) WIDTH  10
55
  //  2) HEIGHT 11
56
  //  3) MINES  12
57
  // and also:
58
  //  OK, Cancel - 20,21
59
 
60
  sys_draw_button(54<<16+38,  30<<16+10, 10,  0xe0e0e0); // WIDTH
61
  EDX++; sys_draw_button(EBX, 48<<16+10, EDX, ESI);      // HEIGHT
62
  EDX++; sys_draw_button(EBX, 66<<16+10, EDX, ESI);      // MINES
63
 
64
  ESI = colors.w_work_button;
65
  ECX = 84<<16+10;
66
  sys_draw_button( 8<<16+38, ECX, 20,  ESI); EDX++;
67
  sys_draw_button(54<<16+38, ECX, EDX, ESI);
68
 
69
  sys_write_text(21<<16+85, colors.w_work_button_text, "OK    Cancel", 12);
70
 
71
  sys_window_redraw(2);
72
}
73
 
74
void uf_main()
75
{
76
  uf_x <<= 16; uf_x += 100;
77
  uf_y <<= 16; uf_y += 104;
78
  draw_uf_window();
79
 
80
  WHILE()
81
  {
82
    SWITCH (sys_wait_event())
83
    {
84
      case 1: draw_uf_window();
85
              break;
86
 
87
      case 2: IF (sys_get_key() == 27)
88
              {
89
                uf_open = FALSE;
90
                sys_exit_process();
91
              }
92
              break;
93
 
94
      case 3: uf_button();
95
    }
96
  }
97
}
98
 
99
uf_button()
100
{
101
  switch (sys_get_button_id())
102
  {
103
    //case 10:
104
    //case 11:
105
    //case 12:
106
 
107
    case 20:
108
    case 21:
109
 
110
    case 1:
111
    uf_open = FALSE;
112
    sys_exit_process();
113
  }
114
}
115
 
116
void start_uf()
117
{
118
  sys_process_info(#procinfo, -1);
119
  uf_x = procinfo.xstart + XST;
120
  uf_y = procinfo.ystart + YST;
121
 
122
  sys_create_thread(#uf_main, #uf_stack + 2048);
123
  uf_open = TRUE;
124
  mouse_disable();
125
  WHILE (uf_open == TRUE)
126
  {
127
    SWITCH (sys_wait_event_timeout(5))
128
    {
129
      CASE 1: draw_window();       CONTINUE;
130
      CASE 2: sys_get_key();       CONTINUE;
131
      CASE 3: sys_get_button_id(); CONTINUE;
132
    }
133
  }
134
  mouse_enable();
135
}