ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/Frodo4/Src/dlgOptions.cpp
Revision: 1.1
Committed: 2007-01-28T19:00:01Z (17 years, 2 months ago) by berlac
Branch: MAIN
CVS Tags: HEAD
Log Message:
Initial revision.

File Contents

# User Rev Content
1 berlac 1.1 /*
2     * dlgOptions.cpp - SDL GUI dialog for C64 emulator options
3     *
4     * (C) 2006 Bernd Lachner
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     #include "sysdeps.h"
22     #include "sdlgui.h"
23    
24     #include "Prefs.h"
25    
26     enum OPTIONSDDLG {
27     box_main,
28     box_speedcontrol,
29     text_speedcontrol,
30     text_draweverynthframe,
31     DRAW_EVERYNTH_FRAME,
32     DRAW_EVERYNTH_FRAME_UP,
33     DRAW_EVERYNTH_FRAME_DOWN,
34     LIMIT_SPEED_TO100PERCENT,
35     FAST_RESET,
36     box_memoryexpansion,
37     text_memoryexpansion,
38     text_reu_size,
39     RADIO_REU_NONE,
40     RADIO_REU_128K,
41     RADIO_REU_256K,
42     RADIO_REU_512K,
43     OK,
44     CANCEL
45     };
46    
47     /* The keyboard dialog: */
48     /* Spalte, Zeile, Länge, Höhe*/
49     static SGOBJ optionsdlg[] =
50     {
51     { SGBOX, SG_BACKGROUND, 0, 0,0, 35,20, NULL },
52     { SGBOX, 0, 0, 1,2, 33,9, NULL },
53     { SGTEXT, 0, 0, 2, 1, 15, 1, " Speed Control"},
54    
55     { SGTEXT, 0, 0, 2, 3, 16, 1, "Draw every n-th frame:"},
56     { SGEDITFIELD, 0, 0, 26, 3, 3, 1, " "},
57     {SGBUTTON, SG_SELECTABLE | SG_TOUCHEXIT, 0, 30, 3, 1, 1, "\x01"},
58     /* Arrow up */
59     {SGBUTTON, SG_SELECTABLE | SG_TOUCHEXIT, 0, 32, 3, 1, 1, "\x02"},
60     /* Arrow down */
61     { SGCHECKBOX, SG_SELECTABLE, 0, 2, 5, 30, 1, "Limit Speed to 100%"},
62     { SGCHECKBOX, SG_SELECTABLE, 0, 2, 7, 30, 1, "Fast Reset"},
63    
64     { SGBOX, 0, 0, 1,13, 33,3, NULL },
65     { SGTEXT, 0, 0, 2, 12, 18, 1, " Memory Expansion"},
66     { SGTEXT, 0, 0, 2, 14, 30, 1, "REU Size:"},
67     { SGCHECKBOX, SG_SELECTABLE|SG_RADIO, 0, 2, 15, 4, 1, "None" },
68     { SGCHECKBOX, SG_SELECTABLE|SG_RADIO, 0, 10, 15, 20,1, "128K" },
69     { SGCHECKBOX, SG_SELECTABLE|SG_RADIO, 0, 18, 15, 20,1, "256K" },
70     { SGCHECKBOX, SG_SELECTABLE|SG_RADIO, 0, 26, 15, 20,1, "512K" },
71    
72     {SGBUTTON, SG_SELECTABLE|SG_EXIT|SG_DEFAULT, 0, 1, 18, 6, 1, "OK"},
73     {SGBUTTON, SG_SELECTABLE|SG_EXIT, 0, 9, 18, 6, 1, "Cancel"},
74    
75     { -1, 0, 0, 0,0, 0,0, NULL }
76     };
77    
78     void Dialog_Options(Prefs &prefs)
79     {
80     // Set values from prefs
81     // TODO optionsdlg[DRAW_EVERYNTH_FRAME].txt = prefs.SkipFrames;
82     optionsdlg[LIMIT_SPEED_TO100PERCENT].state |= prefs.LimitSpeed == true ? SG_SELECTED : 0;
83     optionsdlg[FAST_RESET].state |= prefs.FastReset == true ? SG_SELECTED : 0;
84     switch (prefs.REUSize)
85     {
86     case REU_NONE:
87     optionsdlg[RADIO_REU_NONE].state |= SG_SELECTED;
88     break;
89     case REU_128K:
90     optionsdlg[RADIO_REU_128K].state |= SG_SELECTED;
91     break;
92     case REU_256K:
93     optionsdlg[RADIO_REU_256K].state |= SG_SELECTED;
94     break;
95     case REU_512K:
96     optionsdlg[RADIO_REU_512K].state |= SG_SELECTED;
97     break;
98     }
99     switch (SDLGui_DoDialog(optionsdlg))
100     {
101     case OK:
102     // Set values to prefs
103     prefs.LimitSpeed = optionsdlg[LIMIT_SPEED_TO100PERCENT].state &= SG_SELECTED ? true : false;
104     prefs.FastReset = optionsdlg[FAST_RESET].state &= SG_SELECTED ? true : false;
105     for (int i = RADIO_REU_NONE; i <= RADIO_REU_512K; i++)
106     {
107     if (optionsdlg[i].state &= SG_SELECTED)
108     {
109     prefs.REUSize = i - RADIO_REU_NONE;
110     break;
111     }
112     }
113     break;
114     }
115     }
116