#define ED_SETTINGS2_YPOS (ED_SETTINGS1_YPOS + 12 * TILEY - 2)
/* values for counter gadgets */
-#define ED_COUNT_PUSH_DELAY_RND_XPOS (ED_SETTINGS_XPOS(1) + 16 * MINI_TILEX)
-#define ED_COUNT_MOVE_DELAY_RND_XPOS ED_COUNT_PUSH_DELAY_RND_XPOS
-#define ED_COUNT_CHANGE_DELAY_RND_XPOS (ED_SETTINGS_XPOS(1) + 13 * MINI_TILEX)
-
#define ED_COUNTER_YSTART (ED_SETTINGS1_YPOS + 2 * TILEY)
#define ED_COUNTER_YDISTANCE (3 * MINI_TILEY)
#define ED_COUNTER_YPOS(n) (ED_COUNTER_YSTART + \
6 * (n / 4) * MINI_TILEY)
/* custom change target */
-#define ED_AREA_ELEM_CONTENT2_XPOS (20 * MINI_TILEX)
#define ED_AREA_ELEM_CONTENT2_YPOS (ED_SETTINGS_YPOS(2) + \
ED_GADGET_DISTANCE)
/* optional custom graphic */
-#define ED_AREA_ELEM_CONTENT3_XPOS (24 * MINI_TILEX)
#define ED_AREA_ELEM_CONTENT3_YPOS (ED_SETTINGS_YPOS(1) + \
ED_GADGET_DISTANCE)
/* custom element content */
#define ED_AREA_ELEM_CONTENT4_YPOS (ED_SETTINGS_YPOS(12) + \
ED_GADGET_DISTANCE - MINI_TILEY)
/* custom change trigger element */
-#define ED_AREA_ELEM_CONTENT5_XPOS (28 * MINI_TILEX)
#define ED_AREA_ELEM_CONTENT5_YPOS (ED_SETTINGS_YPOS(7) + \
ED_GADGET_DISTANCE)
/* extended custom change target */
ED_GADGET_DISTANCE - MINI_TILEY)
/* values for random placement background drawing area */
-#define ED_AREA_RANDOM_BACKGROUND_XPOS (29 * MINI_TILEX)
#define ED_AREA_RANDOM_BACKGROUND_YPOS (31 * MINI_TILEY)
/* values for scrolling gadgets for drawing area */
#define GADGET_ID_ELEMENT_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 24)
#define GADGET_ID_ELEMENT_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 25)
#define GADGET_ID_ELEMENT_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 26)
-#define GADGET_ID_CUSTOM_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 27)
-#define GADGET_ID_CUSTOM_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 28)
-#define GADGET_ID_CUSTOM_SCORE_UP (GADGET_ID_COUNTER_FIRST + 29)
-#define GADGET_ID_CUSTOM_GEMCOUNT_DOWN (GADGET_ID_COUNTER_FIRST + 30)
-#define GADGET_ID_CUSTOM_GEMCOUNT_TEXT (GADGET_ID_COUNTER_FIRST + 31)
-#define GADGET_ID_CUSTOM_GEMCOUNT_UP (GADGET_ID_COUNTER_FIRST + 32)
-#define GADGET_ID_PUSH_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 33)
-#define GADGET_ID_PUSH_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 34)
-#define GADGET_ID_PUSH_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 35)
-#define GADGET_ID_PUSH_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 36)
-#define GADGET_ID_PUSH_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 37)
-#define GADGET_ID_PUSH_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 38)
-#define GADGET_ID_MOVE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 39)
-#define GADGET_ID_MOVE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 40)
-#define GADGET_ID_MOVE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 41)
-#define GADGET_ID_MOVE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 42)
-#define GADGET_ID_MOVE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 43)
-#define GADGET_ID_MOVE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 44)
-#define GADGET_ID_CHANGE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 45)
-#define GADGET_ID_CHANGE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 46)
-#define GADGET_ID_CHANGE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 47)
-#define GADGET_ID_CHANGE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 48)
-#define GADGET_ID_CHANGE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 49)
-#define GADGET_ID_CHANGE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 50)
-#define GADGET_ID_CHANGE_CONT_RND_DOWN (GADGET_ID_COUNTER_FIRST + 51)
-#define GADGET_ID_CHANGE_CONT_RND_TEXT (GADGET_ID_COUNTER_FIRST + 52)
-#define GADGET_ID_CHANGE_CONT_RND_UP (GADGET_ID_COUNTER_FIRST + 53)
+#define GADGET_ID_ENVELOPE_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 27)
+#define GADGET_ID_ENVELOPE_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 28)
+#define GADGET_ID_ENVELOPE_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 29)
+#define GADGET_ID_ENVELOPE_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 30)
+#define GADGET_ID_ENVELOPE_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 31)
+#define GADGET_ID_ENVELOPE_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 32)
+#define GADGET_ID_CUSTOM_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 33)
+#define GADGET_ID_CUSTOM_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 34)
+#define GADGET_ID_CUSTOM_SCORE_UP (GADGET_ID_COUNTER_FIRST + 35)
+#define GADGET_ID_CUSTOM_GEMCOUNT_DOWN (GADGET_ID_COUNTER_FIRST + 36)
+#define GADGET_ID_CUSTOM_GEMCOUNT_TEXT (GADGET_ID_COUNTER_FIRST + 37)
+#define GADGET_ID_CUSTOM_GEMCOUNT_UP (GADGET_ID_COUNTER_FIRST + 38)
+#define GADGET_ID_PUSH_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 39)
+#define GADGET_ID_PUSH_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 40)
+#define GADGET_ID_PUSH_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 41)
+#define GADGET_ID_PUSH_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 42)
+#define GADGET_ID_PUSH_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 43)
+#define GADGET_ID_PUSH_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 44)
+#define GADGET_ID_MOVE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 45)
+#define GADGET_ID_MOVE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 46)
+#define GADGET_ID_MOVE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 47)
+#define GADGET_ID_MOVE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 48)
+#define GADGET_ID_MOVE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 49)
+#define GADGET_ID_MOVE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 50)
+#define GADGET_ID_CHANGE_DELAY_FIX_DOWN (GADGET_ID_COUNTER_FIRST + 51)
+#define GADGET_ID_CHANGE_DELAY_FIX_TEXT (GADGET_ID_COUNTER_FIRST + 52)
+#define GADGET_ID_CHANGE_DELAY_FIX_UP (GADGET_ID_COUNTER_FIRST + 53)
+#define GADGET_ID_CHANGE_DELAY_RND_DOWN (GADGET_ID_COUNTER_FIRST + 54)
+#define GADGET_ID_CHANGE_DELAY_RND_TEXT (GADGET_ID_COUNTER_FIRST + 55)
+#define GADGET_ID_CHANGE_DELAY_RND_UP (GADGET_ID_COUNTER_FIRST + 56)
+#define GADGET_ID_CHANGE_CONT_RND_DOWN (GADGET_ID_COUNTER_FIRST + 57)
+#define GADGET_ID_CHANGE_CONT_RND_TEXT (GADGET_ID_COUNTER_FIRST + 58)
+#define GADGET_ID_CHANGE_CONT_RND_UP (GADGET_ID_COUNTER_FIRST + 59)
/* drawing area identifiers */
-#define GADGET_ID_DRAWING_AREA_FIRST (GADGET_ID_COUNTER_FIRST + 54)
+#define GADGET_ID_DRAWING_AREA_FIRST (GADGET_ID_COUNTER_FIRST + 60)
#define GADGET_ID_DRAWING_LEVEL (GADGET_ID_DRAWING_AREA_FIRST + 0)
#define GADGET_ID_ELEMENT_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 1)
#define GADGET_ID_LEVEL_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 1)
#define GADGET_ID_ELEMENT_NAME (GADGET_ID_TEXT_INPUT_FIRST + 2)
+/* text area identifiers */
+#define GADGET_ID_TEXT_AREA_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 3)
+
+#define GADGET_ID_ENVELOPE_INFO (GADGET_ID_TEXT_AREA_FIRST + 0)
+
/* selectbox identifiers */
-#define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 3)
+#define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_AREA_FIRST + 1)
#define GADGET_ID_CUSTOM_WALK_TO_ACTION (GADGET_ID_SELECTBOX_FIRST + 0)
#define GADGET_ID_CUSTOM_CONSISTENCY (GADGET_ID_SELECTBOX_FIRST + 1)
#define GADGET_ID_CHANGE_COLLIDE_ACTION (GADGET_ID_SELECTBOX_FIRST + 12)
#define GADGET_ID_CHANGE_OTHER_ACTION (GADGET_ID_SELECTBOX_FIRST + 13)
#define GADGET_ID_CHANGE_POWER (GADGET_ID_SELECTBOX_FIRST + 14)
+#define GADGET_ID_SELECT_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 15)
/* textbutton identifiers */
-#define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 15)
+#define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 16)
#define GADGET_ID_PROPERTIES_INFO (GADGET_ID_TEXTBUTTON_FIRST + 0)
#define GADGET_ID_PROPERTIES_CONFIG (GADGET_ID_TEXTBUTTON_FIRST + 1)
#define GADGET_ID_PROPERTIES_ADVANCED (GADGET_ID_TEXTBUTTON_FIRST + 2)
#define GADGET_ID_SAVE_AS_TEMPLATE (GADGET_ID_TEXTBUTTON_FIRST + 3)
+#define GADGET_ID_ADD_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 4)
+#define GADGET_ID_DEL_CHANGE_PAGE (GADGET_ID_TEXTBUTTON_FIRST + 5)
+
+/* graphicbutton identifiers */
+#define GADGET_ID_GRAPHICBUTTON_FIRST (GADGET_ID_TEXTBUTTON_FIRST + 6)
+
+#define GADGET_ID_PREV_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 0)
+#define GADGET_ID_NEXT_CHANGE_PAGE (GADGET_ID_GRAPHICBUTTON_FIRST + 1)
/* gadgets for scrolling of drawing area */
-#define GADGET_ID_SCROLLING_FIRST (GADGET_ID_TEXTBUTTON_FIRST + 4)
+#define GADGET_ID_SCROLLING_FIRST (GADGET_ID_GRAPHICBUTTON_FIRST + 2)
#define GADGET_ID_SCROLL_UP (GADGET_ID_SCROLLING_FIRST + 0)
#define GADGET_ID_SCROLL_DOWN (GADGET_ID_SCROLLING_FIRST + 1)
#define ED_COUNTER_ID_LEVEL_RANDOM 6
#define ED_COUNTER_ID_ELEMENT_SCORE 7
#define ED_COUNTER_ID_ELEMENT_CONTENT 8
-#define ED_COUNTER_ID_CUSTOM_SCORE 9
-#define ED_COUNTER_ID_CUSTOM_GEMCOUNT 10
-#define ED_COUNTER_ID_PUSH_DELAY_FIX 11
-#define ED_COUNTER_ID_PUSH_DELAY_RND 12
-#define ED_COUNTER_ID_MOVE_DELAY_FIX 13
-#define ED_COUNTER_ID_MOVE_DELAY_RND 14
-#define ED_COUNTER_ID_CHANGE_DELAY_FIX 15
-#define ED_COUNTER_ID_CHANGE_DELAY_RND 16
-#define ED_COUNTER_ID_CHANGE_CONT_RND 17
-
-#define ED_NUM_COUNTERBUTTONS 18
+#define ED_COUNTER_ID_ENVELOPE_XSIZE 9
+#define ED_COUNTER_ID_ENVELOPE_YSIZE 10
+#define ED_COUNTER_ID_CUSTOM_SCORE 11
+#define ED_COUNTER_ID_CUSTOM_GEMCOUNT 12
+#define ED_COUNTER_ID_PUSH_DELAY_FIX 13
+#define ED_COUNTER_ID_PUSH_DELAY_RND 14
+#define ED_COUNTER_ID_MOVE_DELAY_FIX 15
+#define ED_COUNTER_ID_MOVE_DELAY_RND 16
+#define ED_COUNTER_ID_CHANGE_DELAY_FIX 17
+#define ED_COUNTER_ID_CHANGE_DELAY_RND 18
+#define ED_COUNTER_ID_CHANGE_CONT_RND 19
+
+#define ED_NUM_COUNTERBUTTONS 20
#define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE
#define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM
#define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME
#define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
+/* values for text area gadgets */
+#define ED_TEXTAREA_ID_ENVELOPE_INFO 0
+
+#define ED_NUM_TEXTAREAS 1
+
+#define ED_TEXTAREA_ID_LEVEL_FIRST ED_TEXTAREA_ID_ENVELOPE
+#define ED_TEXTAREA_ID_LEVEL_LAST ED_TEXTAREA_ID_ENVELOPE
+
/* values for selectbox gadgets */
#define ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE 0
#define ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER 1
#define ED_SELECTBOX_ID_CHANGE_COLLIDE_ACTION 12
#define ED_SELECTBOX_ID_CHANGE_OTHER_ACTION 13
#define ED_SELECTBOX_ID_CHANGE_POWER 14
+#define ED_SELECTBOX_ID_SELECT_CHANGE_PAGE 15
-#define ED_NUM_SELECTBOX 15
+#define ED_NUM_SELECTBOX 16
#define ED_SELECTBOX_ID_CUSTOM_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE
#define ED_SELECTBOX_ID_CUSTOM_LAST ED_SELECTBOX_ID_CUSTOM_CONSISTENCY
#define ED_SELECTBOX_ID_CHANGE_FIRST ED_SELECTBOX_ID_CHANGE_TIME_UNITS
-#define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_CHANGE_POWER
+#define ED_SELECTBOX_ID_CHANGE_LAST ED_SELECTBOX_ID_SELECT_CHANGE_PAGE
/* values for textbutton gadgets */
#define ED_TEXTBUTTON_ID_PROPERTIES_INFO 0
#define ED_TEXTBUTTON_ID_PROPERTIES_CONFIG 1
#define ED_TEXTBUTTON_ID_PROPERTIES_ADVANCED 2
#define ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE 3
+#define ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE 4
+#define ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE 5
-#define ED_NUM_TEXTBUTTON 4
+#define ED_NUM_TEXTBUTTONS 6
+
+#define ED_TEXTBUTTON_ID_PROPERTIES_FIRST ED_TEXTBUTTON_ID_PROPERTIES_INFO
+#define ED_TEXTBUTTON_ID_PROPERTIES_LAST ED_TEXTBUTTON_ID_PROPERTIES_ADVANCED
+
+#define ED_TEXTBUTTON_ID_CHANGE_FIRST ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE
+#define ED_TEXTBUTTON_ID_CHANGE_LAST ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE
+
+/* values for graphicbutton gadgets */
+#define ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE 0
+#define ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE 1
+
+#define ED_NUM_GRAPHICBUTTONS 2
+
+#define ED_GRAPHICBUTTON_ID_CHANGE_FIRST ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE
+#define ED_GRAPHICBUTTON_ID_CHANGE_LAST ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE
/* values for checkbutton gadgets */
#define ED_CHECKBUTTON_ID_DOUBLE_SPEED 0
static boolean stick_element_properties_window = FALSE;
static boolean custom_element_properties[NUM_ELEMENT_PROPERTIES];
static boolean custom_element_change_events[NUM_CHANGE_EVENTS];
+static struct ElementChangeInfo custom_element_change;
static struct ElementInfo custom_element;
static struct
"playfield size:", NULL, "width",
},
{
- ED_SETTINGS_XPOS(0) + 2 * DXSIZE, ED_COUNTER_YPOS(2),
+ -1, ED_COUNTER_YPOS(2),
MIN_LEV_FIELDY, MAX_LEV_FIELDY,
GADGET_ID_LEVEL_YSIZE_DOWN, GADGET_ID_LEVEL_YSIZE_UP,
GADGET_ID_LEVEL_YSIZE_TEXT, GADGET_ID_LEVEL_XSIZE_UP,
&level.num_yamyam_contents,
NULL, NULL, "number of content areas"
},
+ {
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(0),
+ MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE,
+ GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP,
+ GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE,
+ &level.envelope_xsize,
+ NULL, NULL, "width",
+ },
+ {
+ -1, ED_SETTINGS_YPOS(0),
+ MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE,
+ GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP,
+ GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP,
+ &level.envelope_ysize,
+ NULL, " ", "height",
+ },
/* ---------- element settings: configure (custom elements) ------------- */
GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP,
GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE,
&custom_element.collect_score,
- NULL, "score", NULL
+ NULL, "score", " "
},
{
- ED_SETTINGS_XPOS(13) + 10, ED_SETTINGS_YPOS(3),
+ -1, ED_SETTINGS_YPOS(3),
MIN_COLLECT_COUNT, MAX_COLLECT_COUNT,
GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP,
GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP,
NULL, "push delay", NULL
},
{
- ED_COUNT_PUSH_DELAY_RND_XPOS, ED_SETTINGS_YPOS(4),
+ -1, ED_SETTINGS_YPOS(4),
0, 999,
GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP,
GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP,
NULL, "move delay", NULL
},
{
- ED_COUNT_MOVE_DELAY_RND_XPOS, ED_SETTINGS_YPOS(7),
+ -1, ED_SETTINGS_YPOS(7),
0, 999,
GADGET_ID_MOVE_DELAY_RND_DOWN, GADGET_ID_MOVE_DELAY_RND_UP,
GADGET_ID_MOVE_DELAY_RND_TEXT, GADGET_ID_MOVE_DELAY_FIX_UP,
0, 999,
GADGET_ID_CHANGE_DELAY_FIX_DOWN, GADGET_ID_CHANGE_DELAY_FIX_UP,
GADGET_ID_CHANGE_DELAY_FIX_TEXT, GADGET_ID_NONE,
- &custom_element.change.delay_fixed,
+ &custom_element_change.delay_fixed,
NULL, "delay", NULL,
},
{
- ED_COUNT_CHANGE_DELAY_RND_XPOS+20, ED_SETTINGS_YPOS(3),
+ -1, ED_SETTINGS_YPOS(3),
0, 999,
GADGET_ID_CHANGE_DELAY_RND_DOWN, GADGET_ID_CHANGE_DELAY_RND_UP,
GADGET_ID_CHANGE_DELAY_RND_TEXT, GADGET_ID_CHANGE_DELAY_FIX_UP,
- &custom_element.change.delay_random,
+ &custom_element_change.delay_random,
NULL, "+random", NULL
},
{
0, 100,
GADGET_ID_CHANGE_CONT_RND_DOWN, GADGET_ID_CHANGE_CONT_RND_UP,
GADGET_ID_CHANGE_CONT_RND_TEXT, GADGET_ID_NONE,
- &custom_element.change.random,
+ &custom_element_change.random,
NULL, "use random change:", "(%)"
},
};
int gadget_id;
int size;
char *value;
- char *infotext;
+ char *text_above, *infotext;
} textinput_info[ED_NUM_TEXTINPUT] =
{
{
GADGET_ID_LEVEL_NAME,
MAX_LEVEL_NAME_LEN,
level.name,
- "Title"
+ "Title:", "Title"
},
{
ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(1),
GADGET_ID_LEVEL_AUTHOR,
MAX_LEVEL_AUTHOR_LEN,
level.author,
- "Author"
+ "Author:", "Author"
},
{
5 * MINI_TILEX, 5 * MINI_TILEY - ED_BORDER_SIZE,
GADGET_ID_ELEMENT_NAME,
MAX_ELEMENT_NAME_LEN - 2, /* currently 2 chars less editable */
custom_element.description,
- "Element name"
+ NULL, "Element name"
+ }
+};
+
+static struct
+{
+ int x, y;
+ int gadget_id;
+ int xsize, ysize;
+ char *value;
+ char *text_above, *infotext;
+} textarea_info[ED_NUM_TEXTAREAS] =
+{
+ {
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(2),
+ GADGET_ID_ENVELOPE_INFO,
+ MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE,
+ level.envelope,
+ "Envelope Info:", "Envelope Info"
}
};
static struct ValueTextInfo options_time_units[] =
{
- { 50, "seconds" },
+ { FRAMES_PER_SECOND, "seconds" },
{ 1, "frames" },
{ -1, NULL }
};
{ -1, NULL }
};
+static char options_change_page_strings[MAX_CHANGE_PAGES][10];
+static struct ValueTextInfo options_change_page[MAX_CHANGE_PAGES + 1] =
+{
+ { -1, NULL }
+};
+
static struct
{
int x, y;
"player can", NULL, "type of access to this field"
},
{
- ED_SETTINGS_XPOS(11), ED_SETTINGS_YPOS(1),
+ -1, ED_SETTINGS_YPOS(1),
GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE,
-1,
options_access_layer,
"move/fall speed", NULL, "speed of element movement"
},
{
- ED_SETTINGS_XPOS(7), ED_SETTINGS_YPOS(9),
+ -1, ED_SETTINGS_YPOS(9),
GADGET_ID_CUSTOM_SMASH_TARGETS, GADGET_ID_CUSTOM_CAN_SMASH,
-1,
options_smash_targets,
GADGET_ID_CHANGE_TIME_UNITS, GADGET_ID_NONE,
-1,
options_time_units,
- &custom_element.change.delay_frames,
+ &custom_element_change.delay_frames,
"delay time given in", NULL, "delay time units for change"
},
{
GADGET_ID_CHANGE_PLAYER_ACTION, GADGET_ID_NONE,
-1,
options_change_player_action,
- &custom_element.change_player_action,
+ &custom_element_change.player_action,
NULL, "by player", "type of player contact"
},
{
GADGET_ID_CHANGE_COLLIDE_ACTION, GADGET_ID_NONE,
-1,
options_change_collide_action,
- &custom_element.change_collide_action,
+ &custom_element_change.collide_action,
NULL, NULL, "change after impact or smash"
},
{
GADGET_ID_CHANGE_OTHER_ACTION, GADGET_ID_NONE,
-1,
options_change_other_action,
- &custom_element.change_other_action,
+ &custom_element_change.other_action,
NULL, "element:", "type of other element action"
},
{
GADGET_ID_CHANGE_POWER, GADGET_ID_NONE,
-1,
options_change_power,
- &custom_element.change.power,
+ &custom_element_change.power,
"power:", NULL, "power of extended change"
},
+ {
+ ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(14),
+ GADGET_ID_SELECT_CHANGE_PAGE, GADGET_ID_NONE,
+ 3,
+ options_change_page,
+ &custom_element.current_change_page,
+ NULL, NULL, "element config page"
+ },
};
static struct
int gadget_id;
int gadget_id_align;
int size;
- char *text, *infotext;
-} textbutton_info[ED_NUM_TEXTBUTTON] =
+ char *text;
+ char *text_left, *text_right, *infotext;
+} textbutton_info[ED_NUM_TEXTBUTTONS] =
{
{
ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(1),
GADGET_ID_PROPERTIES_INFO, GADGET_ID_NONE,
- 11, "Information", "Show information about element"
+ 11, "Information",
+ NULL, NULL, "Show information about element"
},
{
ED_SETTINGS_XPOS(0) + 166, ED_COUNTER_YPOS(1),
GADGET_ID_PROPERTIES_CONFIG, GADGET_ID_NONE,
- 11, "Configure", "Configure element properties"
+ 11, "Configure",
+ NULL, NULL, "Configure element properties"
},
{
ED_SETTINGS_XPOS(0) + 332, ED_COUNTER_YPOS(1),
GADGET_ID_PROPERTIES_ADVANCED, GADGET_ID_NONE,
- 11, "Advanced", "Advanced element configuration"
+ 11, "Advanced",
+ NULL, NULL, "Advanced element configuration"
},
{
- ED_SETTINGS_XPOS(0) + 262, ED_SETTINGS_YPOS(13),
+ -1, ED_SETTINGS_YPOS(13),
GADGET_ID_SAVE_AS_TEMPLATE, GADGET_ID_CUSTOM_USE_TEMPLATE,
- -1, "Save as template", "Save current settings as new template"
+ -1, "Save as template",
+ " ", NULL, "Save current settings as new template"
+ },
+ {
+ -1, ED_SETTINGS_YPOS(14),
+ GADGET_ID_ADD_CHANGE_PAGE, GADGET_ID_NEXT_CHANGE_PAGE,
+ -1, "New",
+ " ", NULL, "Add new config page"
+ },
+ {
+ -1, ED_SETTINGS_YPOS(14),
+ GADGET_ID_DEL_CHANGE_PAGE, GADGET_ID_ADD_CHANGE_PAGE,
+ -1, "Delete",
+ NULL, NULL, "Delete current config page"
+ },
+};
+
+static struct
+{
+ int gd_x, gd_y;
+ int x, y;
+ int width, height;
+ int gadget_id;
+ int gadget_id_align;
+ char *text_left, *text_right, *infotext;
+} graphicbutton_info[ED_NUM_GRAPHICBUTTONS] =
+{
+ {
+ ED_BUTTON_MINUS_XPOS, ED_BUTTON_COUNT_YPOS,
+ ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(14),
+ ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
+ GADGET_ID_PREV_CHANGE_PAGE, GADGET_ID_NONE,
+ NULL, NULL, "select previous config page"
+ },
+ {
+ ED_BUTTON_PLUS_XPOS, ED_BUTTON_COUNT_YPOS,
+ -1, ED_SETTINGS_YPOS(14),
+ ED_BUTTON_COUNT_XSIZE, ED_BUTTON_COUNT_YSIZE,
+ GADGET_ID_NEXT_CHANGE_PAGE, GADGET_ID_SELECT_CHANGE_PAGE,
+ NULL, "config page", "select next config page"
},
};
},
{
ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 1 * ED_SCROLLBUTTON2_YSIZE,
- ED_SCROLL2_DOWN_XPOS, ED_SCROLL2_DOWN_YPOS,
+ ED_SCROLL2_DOWN_XPOS, ED_SCROLL2_DOWN_YPOS,
GADGET_ID_SCROLL_LIST_DOWN,
"scroll element list down ('Page Down')"
- }
+ },
};
static struct
} radiobutton_info[ED_NUM_RADIOBUTTONS] =
{
{
- ED_SETTINGS_XPOS(0) + 160, ED_COUNTER2_YPOS(8),
+ -1, ED_COUNTER2_YPOS(8),
GADGET_ID_RANDOM_PERCENTAGE, GADGET_ID_LEVEL_RANDOM_UP,
RADIO_NR_RANDOM_ELEMENTS,
&random_placement_method, RANDOM_USE_PERCENTAGE,
" ", "percentage", "use percentage for random elements"
},
{
- ED_SETTINGS_XPOS(0) + 340, ED_COUNTER2_YPOS(8),
+ -1, ED_COUNTER2_YPOS(8),
GADGET_ID_RANDOM_QUANTITY, GADGET_ID_RANDOM_PERCENTAGE,
RADIO_NR_RANDOM_ELEMENTS,
&random_placement_method, RANDOM_USE_QUANTITY,
NULL, "double speed movement", "set movement speed of player"
},
{
- ED_SETTINGS_XPOS(0) + 340, ED_COUNTER_YPOS(6) - MINI_TILEY,
+ -1, ED_COUNTER_YPOS(6) - MINI_TILEY,
GADGET_ID_GRAVITY, GADGET_ID_DOUBLE_SPEED,
&level.gravity,
" ", "gravity", "set level gravity"
NULL, "can fall", "element can fall down"
},
{
- ED_SETTINGS_XPOS(6), ED_SETTINGS_YPOS(9),
+ -1, ED_SETTINGS_YPOS(9),
GADGET_ID_CUSTOM_CAN_SMASH, GADGET_ID_CUSTOM_CAN_FALL,
&custom_element_properties[EP_CAN_SMASH],
" ", NULL, "element can smash other elements"
NULL, "by fire", "element can explode by fire/explosion"
},
{
- ED_SETTINGS_XPOS(7), ED_SETTINGS_YPOS(13),
+ -1, ED_SETTINGS_YPOS(13),
GADGET_ID_CUSTOM_EXPLODE_SMASH, GADGET_ID_CUSTOM_EXPLODE_FIRE,
&custom_element.can_explode_smashed,
" ", "smashed", "element can explode when smashed"
},
{
- ED_SETTINGS_XPOS(13), ED_SETTINGS_YPOS(13),
+ -1, ED_SETTINGS_YPOS(13),
GADGET_ID_CUSTOM_EXPLODE_IMPACT, GADGET_ID_CUSTOM_EXPLODE_SMASH,
&custom_element.can_explode_impact,
" ", "impact", "element can explode on impact"
{
ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(8),
GADGET_ID_CHANGE_USE_EXPLOSION, GADGET_ID_NONE,
- &custom_element.change.explode,
+ &custom_element_change.explode,
NULL, "explode instead of change", "element explodes instead of change"
},
{
ED_SETTINGS_XPOS(1), ED_SETTINGS_YPOS(9),
GADGET_ID_CHANGE_USE_CONTENT, GADGET_ID_NONE,
- &custom_element.change.use_content,
+ &custom_element_change.use_content,
NULL, "use extended change target:","element changes to more elements"
},
{
ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(11),
GADGET_ID_CHANGE_ONLY_COMPLETE, GADGET_ID_NONE,
- &custom_element.change.only_complete,
+ &custom_element_change.only_complete,
NULL, "only use complete change", "only use complete extended content"
},
{
ED_SETTINGS_XPOS(2), ED_SETTINGS_YPOS(12),
GADGET_ID_CHANGE_USE_RANDOM, GADGET_ID_NONE,
- &custom_element.change.use_random_change,
+ &custom_element_change.use_random_change,
NULL, NULL, "use random value for new content"
},
{
/* ---------- custom graphic --------------------------------------------- */
{
- ED_AREA_ELEM_CONTENT3_XPOS, ED_AREA_ELEM_CONTENT3_YPOS,
+ -1, ED_AREA_ELEM_CONTENT3_YPOS,
1, 1,
GADGET_ID_CUSTOM_GRAPHIC, GADGET_ID_CUSTOM_USE_GRAPHIC,
NULL, NULL, NULL
/* ---------- custom change target --------------------------------------- */
{
- ED_AREA_ELEM_CONTENT2_XPOS, ED_AREA_ELEM_CONTENT2_YPOS,
+ -1, ED_AREA_ELEM_CONTENT2_YPOS,
1, 1,
GADGET_ID_CUSTOM_CHANGE_TARGET, GADGET_ID_CUSTOM_CAN_CHANGE,
NULL, "after/when:", NULL
/* ---------- custom change trigger (element causing change) ------------- */
{
- ED_AREA_ELEM_CONTENT5_XPOS, ED_AREA_ELEM_CONTENT5_YPOS,
+ -1, ED_AREA_ELEM_CONTENT5_YPOS,
1, 1,
GADGET_ID_CUSTOM_CHANGE_TRIGGER, GADGET_ID_CHANGE_OTHER_ACTION,
NULL, NULL, NULL
/* ---------- random background (for random painting) -------------------- */
{
- ED_AREA_RANDOM_BACKGROUND_XPOS, ED_AREA_RANDOM_BACKGROUND_YPOS,
+ -1, ED_AREA_RANDOM_BACKGROUND_YPOS,
1, 1,
GADGET_ID_RANDOM_BACKGROUND, GADGET_ID_RANDOM_RESTRICTED,
NULL, NULL, NULL
static void HandleDrawingAreas(struct GadgetInfo *);
static void HandleCounterButtons(struct GadgetInfo *);
static void HandleTextInputGadgets(struct GadgetInfo *);
+static void HandleTextAreaGadgets(struct GadgetInfo *);
static void HandleSelectboxGadgets(struct GadgetInfo *);
static void HandleTextbuttonGadgets(struct GadgetInfo *);
+static void HandleGraphicbuttonGadgets(struct GadgetInfo *);
static void HandleRadiobuttons(struct GadgetInfo *);
static void HandleCheckbuttons(struct GadgetInfo *);
static void HandleControlButtons(struct GadgetInfo *);
el2edimg(custom_element.content[x][y]));
else if (id == ED_DRAWING_ID_CUSTOM_CHANGE_TARGET)
DrawMiniGraphicExt(drawto, gi->x, gi->y,
- el2edimg(custom_element.change.target_element));
+ el2edimg(custom_element_change.target_element));
else if (id == ED_DRAWING_ID_CUSTOM_CHANGE_CONTENT)
for (y=0; y < 3; y++)
for (x=0; x < 3; x++)
DrawMiniGraphicExt(drawto,
gi->x + x * MINI_TILEX, gi->y + y * MINI_TILEY,
- el2edimg(custom_element.change.content[x][y]));
+ el2edimg(custom_element_change.content[x][y]));
else if (id == ED_DRAWING_ID_CUSTOM_CHANGE_TRIGGER)
DrawMiniGraphicExt(drawto, gi->x, gi->y,
- el2edimg(custom_element.change.trigger_element));
+ el2edimg(custom_element_change.trigger_element));
else if (id >= ED_DRAWING_ID_ELEMENT_CONTENT_0 &&
id <= ED_DRAWING_ID_ELEMENT_CONTENT_7)
{
GDI_INFO_TEXT, "enter counter value",
GDI_X, x,
GDI_Y, y,
- GDI_TYPE, GD_TYPE_TEXTINPUT_NUMERIC,
+ GDI_TYPE, GD_TYPE_TEXT_INPUT_NUMERIC,
GDI_NUMBER_VALUE, 0,
GDI_NUMBER_MIN, counterbutton_info[i].min_value,
GDI_NUMBER_MAX, counterbutton_info[i].max_value,
GDI_INFO_TEXT, infotext,
GDI_X, SX + textinput_info[i].x,
GDI_Y, SY + textinput_info[i].y,
- GDI_TYPE, GD_TYPE_TEXTINPUT_ALPHANUMERIC,
+ GDI_TYPE, GD_TYPE_TEXT_INPUT_ALPHANUMERIC,
GDI_TEXT_VALUE, textinput_info[i].value,
GDI_TEXT_SIZE, textinput_info[i].size,
GDI_TEXT_FONT, FONT_INPUT_1,
}
}
+static void CreateTextAreaGadgets()
+{
+ int max_infotext_len = getMaxInfoTextLength();
+ int i;
+
+ for (i=0; i<ED_NUM_TEXTAREAS; i++)
+ {
+ Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
+ int gd_x, gd_y;
+ struct GadgetInfo *gi;
+ unsigned long event_mask;
+ char infotext[MAX_OUTPUT_LINESIZE + 1];
+ int id = textarea_info[i].gadget_id;
+ int area_xsize = textarea_info[i].xsize;
+ int area_ysize = textarea_info[i].ysize;
+
+ event_mask = GD_EVENT_TEXT_LEAVING;
+
+ gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
+ gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
+
+ sprintf(infotext, "Enter %s", textarea_info[i].infotext);
+ infotext[max_infotext_len] = '\0';
+
+ gi = CreateGadget(GDI_CUSTOM_ID, id,
+ GDI_CUSTOM_TYPE_ID, i,
+ GDI_INFO_TEXT, infotext,
+ GDI_X, SX + textarea_info[i].x,
+ GDI_Y, SY + textarea_info[i].y,
+ GDI_TYPE, GD_TYPE_TEXT_AREA,
+ GDI_AREA_SIZE, area_xsize, area_ysize,
+ GDI_TEXT_FONT, FONT_INPUT_1,
+ GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
+ GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
+ GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
+ GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
+ GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
+ GDI_EVENT_MASK, event_mask,
+ GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
+ GDI_CALLBACK_ACTION, HandleTextAreaGadgets,
+ GDI_END);
+
+ if (gi == NULL)
+ Error(ERR_EXIT, "cannot create gadget");
+
+ level_editor_gadget[id] = gi;
+ }
+}
+
static void CreateSelectboxGadgets()
{
int max_infotext_len = getMaxInfoTextLength();
int max_infotext_len = getMaxInfoTextLength();
int i;
- for (i=0; i<ED_NUM_TEXTBUTTON; i++)
+ for (i=0; i<ED_NUM_TEXTBUTTONS; i++)
{
Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
int gd_x1, gd_x2, gd_y1, gd_y2;
x = (right_gadget_border[textbutton_info[i].gadget_id_align] +
ED_GADGET_TEXT_DISTANCE);
+ /* determine horizontal offset for leading text */
+ if (textbutton_info[i].text_left != NULL)
+ x += getTextWidthForGadget(textbutton_info[i].text_left);
+
gi = CreateGadget(GDI_CUSTOM_ID, id,
GDI_CUSTOM_TYPE_ID, i,
GDI_INFO_TEXT, infotext,
Error(ERR_EXIT, "cannot create gadget");
level_editor_gadget[id] = gi;
+ right_gadget_border[id] =
+ getRightGadgetBorder(gi, textbutton_info[i].text_right);
+ }
+}
+
+static void CreateGraphicbuttonGadgets()
+{
+ Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
+ struct GadgetInfo *gi;
+ unsigned long event_mask;
+ int i;
+
+ /* create buttons for scrolling of drawing area and element list */
+ for (i=0; i < ED_NUM_GRAPHICBUTTONS; i++)
+ {
+ int id = graphicbutton_info[i].gadget_id;
+ int gd_x1, gd_x2, gd_y1, gd_y2;
+ int x = SX + graphicbutton_info[i].x;
+ int y = SY + graphicbutton_info[i].y;
+
+ event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
+
+ gd_x1 = DOOR_GFX_PAGEX4 + graphicbutton_info[i].gd_x;
+ gd_x2 = DOOR_GFX_PAGEX3 + graphicbutton_info[i].gd_x;
+ gd_y1 = DOOR_GFX_PAGEY1 + graphicbutton_info[i].gd_y;
+ gd_y2 = gd_y1;
+
+ /* determine horizontal position to the right of specified gadget */
+ if (graphicbutton_info[i].gadget_id_align != GADGET_ID_NONE)
+ x = (right_gadget_border[graphicbutton_info[i].gadget_id_align] +
+ ED_GADGET_TEXT_DISTANCE);
+
+ /* determine horizontal offset for leading text */
+ if (graphicbutton_info[i].text_left != NULL)
+ x += getTextWidthForGadget(graphicbutton_info[i].text_left);
+
+ gi = CreateGadget(GDI_CUSTOM_ID, id,
+ GDI_CUSTOM_TYPE_ID, i,
+ GDI_INFO_TEXT, graphicbutton_info[i].infotext,
+ GDI_X, x,
+ GDI_Y, y,
+ GDI_WIDTH, graphicbutton_info[i].width,
+ GDI_HEIGHT, graphicbutton_info[i].height,
+ GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
+ GDI_STATE, GD_BUTTON_UNPRESSED,
+ GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
+ GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
+ GDI_EVENT_MASK, event_mask,
+ GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
+ GDI_CALLBACK_ACTION, HandleGraphicbuttonGadgets,
+ GDI_END);
+
+ if (gi == NULL)
+ Error(ERR_EXIT, "cannot create gadget");
+
+ level_editor_gadget[id] = gi;
+ right_gadget_border[id] =
+ getRightGadgetBorder(gi, graphicbutton_info[i].text_right);
}
}
CreateCounterButtons();
CreateRadiobuttonGadgets();
CreateTextInputGadgets();
- CreateTextbuttonGadgets();
+ CreateTextAreaGadgets();
CreateSelectboxGadgets();
+ CreateGraphicbuttonGadgets();
+ CreateTextbuttonGadgets();
CreateDrawingAreas();
game_status = old_game_status;
static void MapTextInputGadget(int id)
{
struct GadgetInfo *gi = level_editor_gadget[textinput_info[id].gadget_id];
- char infotext[MAX_OUTPUT_LINESIZE + 1];
- int max_infotext_len = getMaxInfoTextLength();
int xoffset_above = 0;
int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
- int x = textinput_info[id].x + xoffset_above;
- int y = textinput_info[id].y + yoffset_above;
+ int x_above = textinput_info[id].x + xoffset_above;
+ int y_above = textinput_info[id].y + yoffset_above;
- if (textinput_info[id].infotext)
- {
- sprintf(infotext, "%s:", textinput_info[id].infotext);
- infotext[max_infotext_len] = '\0';
- DrawTextF(x, y, FONT_TEXT_1, infotext);
- }
+ if (textinput_info[id].text_above)
+ DrawTextF(x_above, y_above, FONT_TEXT_1, textinput_info[id].text_above);
ModifyGadget(gi, GDI_TEXT_VALUE, textinput_info[id].value, GDI_END);
MapGadget(gi);
}
+static void MapTextAreaGadget(int id)
+{
+ struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
+ int xoffset_above = 0;
+ int yoffset_above = -(MINI_TILEX + ED_GADGET_DISTANCE);
+ int x_above = textarea_info[id].x + xoffset_above;
+ int y_above = textarea_info[id].y + yoffset_above;
+
+ if (textarea_info[id].text_above)
+ DrawTextF(x_above, y_above, FONT_TEXT_1, textarea_info[id].text_above);
+
+ ModifyGadget(gi, GDI_TEXT_VALUE, textarea_info[id].value, GDI_END);
+
+ MapGadget(gi);
+}
+
static void MapSelectboxGadget(int id)
{
struct GadgetInfo *gi = level_editor_gadget[selectbox_info[id].gadget_id];
static void MapTextbuttonGadget(int id)
{
struct GadgetInfo *gi = level_editor_gadget[textbutton_info[id].gadget_id];
+ int xoffset_left = getTextWidthForGadget(textbutton_info[id].text_left);
+ int xoffset_right = ED_GADGET_TEXT_DISTANCE;
+ int yoffset = ED_BORDER_SIZE;
+ int x_left = gi->x - xoffset_left;
+ int x_right = gi->x + gi->width + xoffset_right;
+ int y = gi->y + yoffset;
+
+ /* only show button to delete change pages when more than minimum pages */
+ if (id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
+ custom_element.num_change_pages == MIN_CHANGE_PAGES)
+ return;
+
+ if (textbutton_info[id].text_left)
+ DrawText(x_left, y, textbutton_info[id].text_left, FONT_TEXT_1);
+
+ if (textbutton_info[id].text_right)
+ DrawText(x_right, y, textbutton_info[id].text_right, FONT_TEXT_1);
+
+ MapGadget(gi);
+}
+
+static void MapGraphicbuttonGadget(int id)
+{
+ struct GadgetInfo *gi= level_editor_gadget[graphicbutton_info[id].gadget_id];
+ int xoffset_left = getTextWidthForGadget(graphicbutton_info[id].text_left);
+ int xoffset_right = ED_GADGET_TEXT_DISTANCE;
+ int yoffset = ED_BORDER_SIZE;
+ int x_left = gi->x - xoffset_left;
+ int x_right = gi->x + gi->width + xoffset_right;
+ int y = gi->y + yoffset;
+
+ if (graphicbutton_info[id].text_left)
+ DrawText(x_left, y, graphicbutton_info[id].text_left, FONT_TEXT_1);
+
+ if (graphicbutton_info[id].text_right)
+ DrawText(x_right, y, graphicbutton_info[id].text_right, FONT_TEXT_1);
MapGadget(gi);
}
static void MapRadiobuttonGadget(int id)
{
struct GadgetInfo *gi = level_editor_gadget[radiobutton_info[id].gadget_id];
-#if 0
- int xoffset_right = ED_XOFFSET_CHECKBOX;
- int yoffset_right = ED_BORDER_SIZE;
- int x = radiobutton_info[id].x + xoffset_right;
- int y = radiobutton_info[id].y + yoffset_right;
-#else
int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
int xoffset_right = ED_GADGET_TEXT_DISTANCE;
int yoffset = ED_BORDER_SIZE;
int x_left = gi->x - xoffset_left;
int x_right = gi->x + gi->width + xoffset_right;
int y = gi->y + yoffset;
-#endif
boolean checked =
(*radiobutton_info[id].value == radiobutton_info[id].checked_value);
static void MapCheckbuttonGadget(int id)
{
struct GadgetInfo *gi = level_editor_gadget[checkbutton_info[id].gadget_id];
-#if 0
- int xoffset_right = ED_XOFFSET_CHECKBOX;
- int yoffset_right = ED_BORDER_SIZE;
- int x = checkbutton_info[id].x + xoffset_right;
- int y = checkbutton_info[id].y + yoffset_right;
-#else
int xoffset_left = getTextWidthForGadget(checkbutton_info[id].text_left);
int xoffset_right = ED_GADGET_TEXT_DISTANCE;
int yoffset = ED_BORDER_SIZE;
int x_left = gi->x - xoffset_left;
int x_right = gi->x + gi->width + xoffset_right;
int y = gi->y + yoffset;
-#endif
/* special case needed for "sticky" gadget */
ModifyGadget(gi, GDI_CHECKED, *checkbutton_info[id].value,
dst[x][y] = src[x][y];
}
-static int SetSelectboxValue(int selectbox_id, int new_value)
+static int setSelectboxValue(int selectbox_id, int new_value)
{
int new_index_value = 0;
int i;
static void CopyCustomElementPropertiesToEditor(int element)
{
int i;
+ int current_change_page = element_info[element].current_change_page;
+
+ /* dynamically (re)build selectbox for selecting change page */
+ for (i=0; i < element_info[element].num_change_pages; i++)
+ {
+ sprintf(options_change_page_strings[i], "%d", i + 1);
+
+ options_change_page[i].value = i;
+ options_change_page[i].text = options_change_page_strings[i];
+ }
+
+ options_change_page[i].value = -1;
+ options_change_page[i].text = NULL;
/* needed here to initialize combined element properties */
InitElementPropertiesEngine(level.game_version);
+ element_info[element].change =
+ &element_info[element].change_page[current_change_page];
+
custom_element = element_info[element];
+ custom_element_change = *element_info[element].change;
/* needed to initially set selectbox value variables to reliable defaults */
for (i=0; i < ED_NUM_SELECTBOX; i++)
- SetSelectboxValue(i, *selectbox_info[i].value);
+ setSelectboxValue(i, *selectbox_info[i].value);
for (i=0; i < NUM_ELEMENT_PROPERTIES; i++)
custom_element_properties[i] = HAS_PROPERTY(element, i);
/* ---------- element settings: advanced (custom elements) --------------- */
/* set change by player selectbox help value */
- custom_element.change_player_action =
+ custom_element_change.player_action =
(HAS_CHANGE_EVENT(element, CE_DROPPED_BY_PLAYER) ? CE_DROPPED_BY_PLAYER :
HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
- custom_element.change_player_action);
+ custom_element_change.player_action);
/* set change by collision selectbox help value */
- custom_element.change_collide_action =
+ custom_element_change.collide_action =
(HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED :
HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT :
HAS_CHANGE_EVENT(element, CE_COLLISION) ? CE_COLLISION :
- custom_element.change_collide_action);
+ custom_element_change.collide_action);
/* set change by other element action selectbox help value */
- custom_element.change_other_action =
+ custom_element_change.other_action =
(HAS_CHANGE_EVENT(element, CE_OTHER_GETS_DROPPED) ? CE_OTHER_GETS_DROPPED :
HAS_CHANGE_EVENT(element, CE_OTHER_GETS_COLLECTED) ? CE_OTHER_GETS_COLLECTED :
HAS_CHANGE_EVENT(element, CE_OTHER_GETS_PUSHED) ? CE_OTHER_GETS_PUSHED :
HAS_CHANGE_EVENT(element, CE_OTHER_IS_EXPLODING) ? CE_OTHER_IS_EXPLODING :
HAS_CHANGE_EVENT(element, CE_OTHER_IS_CHANGING) ? CE_OTHER_IS_CHANGING :
HAS_CHANGE_EVENT(element, CE_OTHER_IS_TOUCHING) ? CE_OTHER_IS_TOUCHING :
- custom_element.change_other_action);
+ custom_element_change.other_action);
}
static void CopyCustomElementPropertiesToGame(int element)
}
element_info[element] = custom_element;
+ *element_info[element].change = custom_element_change;
/* ---------- element settings: configure (custom elements) ------------- */
custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE;
custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE;
custom_element_change_events[CE_DROPPED_BY_PLAYER] = FALSE;
- custom_element_change_events[custom_element.change_player_action] =
+ custom_element_change_events[custom_element_change.player_action] =
custom_element_change_events[CE_BY_PLAYER];
/* set collision change event from checkbox and selectbox */
custom_element_change_events[CE_COLLISION] = FALSE;
custom_element_change_events[CE_IMPACT] = FALSE;
custom_element_change_events[CE_SMASHED] = FALSE;
- custom_element_change_events[custom_element.change_collide_action] =
+ custom_element_change_events[custom_element_change.collide_action] =
custom_element_change_events[CE_BY_COLLISION];
/* set other element action change event from checkbox and selectbox */
custom_element_change_events[CE_OTHER_GETS_PUSHED] = FALSE;
custom_element_change_events[CE_OTHER_GETS_COLLECTED] = FALSE;
custom_element_change_events[CE_OTHER_GETS_DROPPED] = FALSE;
- custom_element_change_events[custom_element.change_other_action] =
+ custom_element_change_events[custom_element_change.other_action] =
custom_element_change_events[CE_BY_OTHER];
for (i=0; i < NUM_ELEMENT_PROPERTIES; i++)
/* copy change events also to special level editor variable */
custom_element = element_info[element];
+ custom_element_change = *element_info[element].change;
}
void DrawLevelEd()
ModifyGadget(gi, GDI_NUMBER_VALUE, new_value, GDI_END);
if (counter_value != NULL)
- *counter_value = gi->text.number_value;
+ *counter_value = gi->textinput.number_value;
}
static void ModifyEditorCounterLimits(int counter_id, int min, int max)
{
int gadget_id = selectbox_info[selectbox_id].gadget_id;
struct GadgetInfo *gi = level_editor_gadget[gadget_id];
- int new_index_value = SetSelectboxValue(selectbox_id, new_value);
+ int new_index_value = setSelectboxValue(selectbox_id, new_value);
ModifyGadget(gi, GDI_SELECTBOX_INDEX, new_index_value, GDI_END);
}
DrawText(x, y + 2 * MINI_TILEY, "smashed", FONT_TEXT_1);
}
+static void DrawEnvelopeTextArea()
+{
+ int id = ED_TEXTAREA_ID_ENVELOPE_INFO;
+ struct GadgetInfo *gi = level_editor_gadget[textarea_info[id].gadget_id];
+
+ UnmapGadget(gi);
+ DrawBackground(gi->x, gi->y, gi->width, gi->height);
+
+ ModifyGadget(gi, GDI_AREA_SIZE, level.envelope_xsize, level.envelope_ysize,
+ GDI_END);
+ MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO);
+}
+
char *getElementDescriptionFilename(int element)
{
char *docs_dir = options.docs_directory;
if (IS_GEM(properties_element) ||
IS_CUSTOM_ELEMENT(properties_element) ||
- HAS_CONTENT(properties_element))
+ HAS_CONTENT(properties_element) ||
+ properties_element == EL_ENVELOPE)
return TRUE;
else
for (i=0; elements_with_counter[i].element != -1; i++)
if (IS_GEM(properties_element))
MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS);
+ if (properties_element == EL_ENVELOPE)
+ {
+ /* display counter to choose size of envelope text area */
+ MapCounterButtons(ED_COUNTER_ID_ENVELOPE_XSIZE);
+ MapCounterButtons(ED_COUNTER_ID_ENVELOPE_YSIZE);
+
+ DrawEnvelopeTextArea();
+ }
+
if (IS_CUSTOM_ELEMENT(properties_element))
{
/* draw stickybutton gadget */
MapSelectboxGadget(i);
/* draw textbutton gadgets */
- MapTextbuttonGadget(ED_TEXTBUTTON_ID_SAVE_AS_TEMPLATE);
+ for (i=ED_TEXTBUTTON_ID_CHANGE_FIRST; i<=ED_TEXTBUTTON_ID_CHANGE_LAST; i++)
+ MapTextbuttonGadget(i);
+
+ /* draw graphicbutton gadgets */
+ for (i = ED_GRAPHICBUTTON_ID_CHANGE_FIRST;
+ i <= ED_GRAPHICBUTTON_ID_CHANGE_LAST; i++)
+ MapGraphicbuttonGadget(i);
/* draw drawing area gadgets */
DrawPropertiesAdvancedDrawingAreas();
}
else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
{
- custom_element.change.target_element = new_element;
+ custom_element_change.target_element = new_element;
CopyCustomElementPropertiesToGame(properties_element);
}
else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
{
- custom_element.change.content[sx][sy] = new_element;
+ custom_element_change.content[sx][sy] = new_element;
CopyCustomElementPropertiesToGame(properties_element);
}
else if (id == GADGET_ID_CUSTOM_CHANGE_TRIGGER)
{
- custom_element.change.trigger_element = new_element;
+ custom_element_change.trigger_element = new_element;
CopyCustomElementPropertiesToGame(properties_element);
}
else if (id == GADGET_ID_CUSTOM_CONTENT)
PickDrawingElement(button, custom_element.content[sx][sy]);
else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
- PickDrawingElement(button, custom_element.change.target_element);
+ PickDrawingElement(button, custom_element_change.target_element);
else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
- PickDrawingElement(button, custom_element.change.content[sx][sy]);
+ PickDrawingElement(button, custom_element_change.content[sx][sy]);
else if (id == GADGET_ID_CUSTOM_CHANGE_TRIGGER)
- PickDrawingElement(button, custom_element.change.trigger_element);
+ PickDrawingElement(button, custom_element_change.trigger_element);
else if (id == GADGET_ID_RANDOM_BACKGROUND)
PickDrawingElement(button, random_placement_background_element);
else if (id >= GADGET_ID_ELEMENT_CONTENT_0 &&
}
if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
- *counter_value = gi->text.number_value;
+ *counter_value = gi->textinput.number_value;
else
ModifyEditorCounter(counter_id, *counter_value + step);
DrawElementContentAreas();
break;
+ case ED_COUNTER_ID_ENVELOPE_XSIZE:
+ case ED_COUNTER_ID_ENVELOPE_YSIZE:
+ DrawEnvelopeTextArea();
+ break;
+
case ED_COUNTER_ID_LEVEL_XSIZE:
case ED_COUNTER_ID_LEVEL_YSIZE:
lev_fieldx = level.fieldx;
{
int type_id = gi->custom_type_id;
- strcpy(textinput_info[type_id].value, gi->text.value);
+ strcpy(textinput_info[type_id].value, gi->textinput.value);
if (type_id == ED_TEXTINPUT_ID_ELEMENT_NAME)
{
}
}
+static void HandleTextAreaGadgets(struct GadgetInfo *gi)
+{
+ int type_id = gi->custom_type_id;
+
+ strcpy(textarea_info[type_id].value, gi->textarea.value);
+}
+
static void HandleSelectboxGadgets(struct GadgetInfo *gi)
{
int type_id = gi->custom_type_id;
*selectbox_info[type_id].value =
selectbox_info[type_id].options[gi->selectbox.index].value;
- if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
- type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
- (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
- type_id <= ED_SELECTBOX_ID_CHANGE_LAST))
+ if (type_id == ED_SELECTBOX_ID_SELECT_CHANGE_PAGE)
+ {
+ element_info[properties_element].current_change_page = gi->selectbox.index;
+
+ DrawPropertiesWindow();
+ }
+ else if ((type_id >= ED_SELECTBOX_ID_CUSTOM_FIRST &&
+ type_id <= ED_SELECTBOX_ID_CUSTOM_LAST) ||
+ (type_id >= ED_SELECTBOX_ID_CHANGE_FIRST &&
+ type_id <= ED_SELECTBOX_ID_CHANGE_LAST))
CopyCustomElementPropertiesToGame(properties_element);
}
static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
{
int type_id = gi->custom_type_id;
+ int i;
- if (type_id >= ED_TEXTBUTTON_ID_PROPERTIES_INFO &&
- type_id <= ED_TEXTBUTTON_ID_PROPERTIES_ADVANCED)
+ if (type_id >= ED_TEXTBUTTON_ID_PROPERTIES_FIRST &&
+ type_id <= ED_TEXTBUTTON_ID_PROPERTIES_LAST)
{
edit_mode_properties = gi->custom_type_id;
if (new_template)
Request("Tem- plate saved !", REQ_CONFIRM);
}
+ else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE &&
+ custom_element.num_change_pages < MAX_CHANGE_PAGES)
+ {
+ struct ElementInfo *ei = &element_info[properties_element];
+
+ setElementChangePages(ei, ei->num_change_pages + 1);
+
+ /* set new change page to be new current change page */
+ ei->current_change_page = ei->num_change_pages - 1;
+ ei->change = &ei->change_page[ei->current_change_page];
+
+ setElementChangeInfoToDefaults(ei->change);
+
+ DrawPropertiesWindow();
+ }
+ else if (type_id == ED_TEXTBUTTON_ID_DEL_CHANGE_PAGE &&
+ custom_element.num_change_pages > MIN_CHANGE_PAGES)
+ {
+ struct ElementInfo *ei = &element_info[properties_element];
+
+ /* copy all change pages after change page to be deleted */
+ for (i = ei->current_change_page; i < ei->num_change_pages - 1; i++)
+ ei->change_page[i] = ei->change_page[i + 1];
+
+ setElementChangePages(ei, ei->num_change_pages - 1);
+
+ DrawPropertiesWindow();
+ }
+}
+
+static void HandleGraphicbuttonGadgets(struct GadgetInfo *gi)
+{
+ int type_id = gi->custom_type_id;
+
+ if (type_id == ED_GRAPHICBUTTON_ID_PREV_CHANGE_PAGE)
+ {
+ if (element_info[properties_element].current_change_page > 0)
+ element_info[properties_element].current_change_page--;
+
+ DrawPropertiesWindow();
+ }
+ else if (type_id == ED_GRAPHICBUTTON_ID_NEXT_CHANGE_PAGE)
+ {
+ if (element_info[properties_element].current_change_page <
+ element_info[properties_element].num_change_pages - 1)
+ element_info[properties_element].current_change_page++;
+
+ DrawPropertiesWindow();
+ }
}
static void HandleRadiobuttons(struct GadgetInfo *gi)
getElementInfoText(custom_element.content[sx][sy]));
else if (id == GADGET_ID_CUSTOM_CHANGE_TARGET)
DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, "%s",
- getElementInfoText(custom_element.change.target_element));
+ getElementInfoText(custom_element_change.target_element));
else if (id == GADGET_ID_CUSTOM_CHANGE_CONTENT)
DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, "%s",
- getElementInfoText(custom_element.change.content[sx][sy]));
+ getElementInfoText(custom_element_change.content[sx][sy]));
else if (id == GADGET_ID_CUSTOM_CHANGE_TRIGGER)
DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, "%s",
- getElementInfoText(custom_element.change.trigger_element));
+ getElementInfoText(custom_element_change.trigger_element));
else if (id == GADGET_ID_RANDOM_BACKGROUND)
DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, "%s",
getElementInfoText(random_placement_background_element));
return NULL;
}
+#if 1
+
+static void setTextAreaCursorExt(struct GadgetInfo *gi, boolean set_cursor_pos)
+{
+ char *text = gi->textarea.value;
+ int area_xsize = gi->textarea.xsize;
+ int area_ysize = gi->textarea.ysize;
+ int cursor_position = gi->textarea.cursor_position;
+ int cursor_x = gi->textarea.cursor_x;
+ int cursor_y = gi->textarea.cursor_y;
+ int pos = 0;
+ int x = 0;
+ int y = 0;
+
+ while (*text)
+ {
+ if (set_cursor_pos) /* x/y => position */
+ {
+ if (y == cursor_y && (x == cursor_x || (x < cursor_x && *text == '\n')))
+ break;
+ }
+ else /* position => x/y */
+ {
+ if (pos == cursor_position)
+ break;
+ }
+
+ if (x + 1 >= area_xsize || *text == '\n')
+ {
+ if (y + 1 >= area_ysize)
+ break;
+
+ x = 0;
+ y++;
+ }
+ else
+ x++;
+
+ text++;
+ pos++;
+ }
+
+ if (y >= area_ysize)
+ {
+ x = area_xsize - 1;
+ }
+
+#if 0
+ printf("::: %d, %d [%d]\n", cursor_x, cursor_y, cursor_position);
+#endif
+
+ gi->textarea.cursor_x = x;
+ gi->textarea.cursor_y = y;
+ gi->textarea.cursor_x_preferred = x;
+ gi->textarea.cursor_position = pos;
+}
+
+static void setTextAreaCursorXY(struct GadgetInfo *gi, int x, int y)
+{
+ gi->textarea.cursor_x = x;
+ gi->textarea.cursor_y = y;
+
+ setTextAreaCursorExt(gi, TRUE);
+}
+
+static void setTextAreaCursorPosition(struct GadgetInfo *gi, int pos)
+{
+ gi->textarea.cursor_position = pos;
+
+ setTextAreaCursorExt(gi, FALSE);
+}
+
+#else
+
+static void setTextAreaCursorPosition(struct GadgetInfo *gi, int x, int y)
+{
+ char *text = gi->textarea.value;
+ int area_xsize = gi->textarea.xsize;
+ int area_ysize = gi->textarea.ysize;
+ int cursor_x = 0;
+ int cursor_y = 0;
+ int cursor_position = 0;
+
+ while (*text && cursor_y < area_ysize)
+ {
+ char buffer[MAX_OUTPUT_LINESIZE + 1];
+ int i;
+
+ for (i=0; i < area_xsize && *text && *text != '\n'; i++)
+ buffer[i] = *text++;
+ buffer[i] = '\0';
+
+#if 1
+ if (i == 0 && *text == '\n')
+ {
+ text++;
+ cursor_position++;
+ }
+#endif
+
+ if (x == -1 && y == -1) /* get x/y from cursor position */
+ {
+ if (cursor_position + i >= gi->textarea.cursor_position)
+ {
+#if 0
+ printf("::: cursor: %d + %d >= %d\n", cursor_position, i,
+ gi->textarea.cursor_position);
+#endif
+
+ cursor_x = gi->textarea.cursor_position - cursor_position;
+ cursor_position = gi->textarea.cursor_position;
+
+ break;
+ }
+ }
+
+ if (cursor_y == y || !*text) /* correct y position found */
+ {
+ cursor_x = MIN(i, x);
+ cursor_position += cursor_x;
+
+ break;
+ }
+ else
+ cursor_position += i;
+
+#if 0
+ if (*text == '\n')
+ {
+ text++;
+ cursor_position++;
+
+ if (i == area_xsize)
+ cursor_y++;
+ }
+#endif
+
+ cursor_y++;
+ }
+
+ if (cursor_x >= area_xsize)
+ {
+ cursor_x = 0;
+ cursor_y++;
+ }
+
+ if (cursor_y >= area_ysize)
+ {
+ cursor_x = area_xsize - 1;
+ cursor_y = area_ysize - 1;
+ }
+
+#if 0
+ printf("::: %d, %d [%d]\n", cursor_x, cursor_y, cursor_position);
+#endif
+
+ gi->textarea.cursor_x = cursor_x;
+ gi->textarea.cursor_y = cursor_y;
+ gi->textarea.cursor_x_preferred = cursor_x;
+ gi->textarea.cursor_position = cursor_position;
+}
+
+#endif
+
static void default_callback_info(void *ptr)
{
return;
}
break;
- case GD_TYPE_TEXTINPUT_ALPHANUMERIC:
- case GD_TYPE_TEXTINPUT_NUMERIC:
+ case GD_TYPE_TEXT_INPUT_ALPHANUMERIC:
+ case GD_TYPE_TEXT_INPUT_NUMERIC:
{
int i;
char cursor_letter;
border_x, gi->height, gi->x, gi->y);
/* middle part of gadget */
- for (i=0; i < gi->text.size + 1; i++)
+ for (i=0; i < gi->textinput.size + 1; i++)
BlitBitmapOnBackground(gd->bitmap, drawto, gd->x + border_x, gd->y,
font_width, gi->height,
gi->x + border_x + i * font_width, gi->y);
gi->x + gi->width - border_x, gi->y);
/* set text value */
- strcpy(text, gi->text.value);
+ strcpy(text, gi->textinput.value);
strcat(text, " ");
/* gadget text value */
gi->x + border_x, gi->y + border_y, text,
font_nr, BLIT_MASKED);
- cursor_letter = gi->text.value[gi->text.cursor_position];
+ cursor_letter = gi->textinput.value[gi->textinput.cursor_position];
cursor_string[0] = (cursor_letter != '\0' ? cursor_letter : ' ');
cursor_string[1] = '\0';
+#if 0
+ if (pressed)
+ printf("::: PRESSED!\n");
+#endif
+
/* draw cursor, if active */
if (pressed)
DrawTextExt(drawto,
- gi->x + border_x + gi->text.cursor_position * font_width,
+ gi->x + border_x +
+ gi->textinput.cursor_position * font_width,
gi->y + border_y, cursor_string,
font_nr, BLIT_INVERSE);
}
break;
+ case GD_TYPE_TEXT_AREA:
+ {
+ int i;
+ char cursor_letter;
+ char cursor_string[2];
+ int font_nr = (pressed ? gi->font_active : gi->font);
+ int font_width = getFontWidth(font_nr);
+ int font_height = getFontHeight(font_nr);
+ int border_x = gi->border.xsize;
+ int border_y = gi->border.ysize;
+ int gd_height = 2 * border_y + font_height;
+
+ /* top left part of gadget border */
+ BlitBitmapOnBackground(gd->bitmap, drawto, gd->x, gd->y,
+ border_x, border_y, gi->x, gi->y);
+
+ /* top middle part of gadget border */
+ for (i=0; i < gi->textarea.xsize; i++)
+ BlitBitmapOnBackground(gd->bitmap, drawto, gd->x + border_x, gd->y,
+ font_width, border_y,
+ gi->x + border_x + i * font_width, gi->y);
+
+ /* top right part of gadget border */
+ BlitBitmapOnBackground(gd->bitmap, drawto,
+ gd->x + gi->border.width - border_x, gd->y,
+ border_x, border_y,
+ gi->x + gi->width - border_x, gi->y);
+
+ /* left and right part of gadget border for each row */
+ for (i=0; i < gi->textarea.ysize; i++)
+ {
+ BlitBitmapOnBackground(gd->bitmap, drawto, gd->x, gd->y + border_y,
+ border_x, font_height,
+ gi->x, gi->y + border_y + i * font_height);
+ BlitBitmapOnBackground(gd->bitmap, drawto,
+ gd->x + gi->border.width - border_x,
+ gd->y + border_y,
+ border_x, font_height,
+ gi->x + gi->width - border_x,
+ gi->y + border_y + i * font_height);
+ }
+
+ /* bottom left part of gadget border */
+ BlitBitmapOnBackground(gd->bitmap, drawto,
+ gd->x, gd->y + gd_height - border_y,
+ border_x, border_y,
+ gi->x, gi->y + gi->height - border_y);
+
+ /* bottom middle part of gadget border */
+ for (i=0; i < gi->textarea.xsize; i++)
+ BlitBitmapOnBackground(gd->bitmap, drawto,
+ gd->x + border_x,
+ gd->y + gd_height - border_y,
+ font_width, border_y,
+ gi->x + border_x + i * font_width,
+ gi->y + gi->height - border_y);
+
+ /* bottom right part of gadget border */
+ BlitBitmapOnBackground(gd->bitmap, drawto,
+ gd->x + gi->border.width - border_x,
+ gd->y + gd_height - border_y,
+ border_x, border_y,
+ gi->x + gi->width - border_x,
+ gi->y + gi->height - border_y);
+
+ ClearRectangleOnBackground(drawto,
+ gi->x + border_x,
+ gi->y + border_y,
+ gi->width - 2 * border_x,
+ gi->height - 2 * border_y);
+
+ /* gadget text value */
+ DrawTextToTextArea(gi->x + border_x, gi->y + border_y,
+ gi->textarea.value, font_nr,
+ gi->textarea.xsize, gi->textarea.ysize);
+
+ cursor_letter = gi->textarea.value[gi->textarea.cursor_position];
+ cursor_string[0] = (cursor_letter != '\0' ? cursor_letter : ' ');
+ cursor_string[1] = '\0';
+
+#if 0
+ printf("::: '%s' [%d, %d] [%d] [%d -> '%s']\n",
+ gi->textarea.value,
+ gi->textarea.cursor_x, gi->textarea.cursor_y,
+ gi->textarea.cursor_position,
+ pressed, cursor_string);
+#endif
+
+ /* draw cursor, if active */
+ if (pressed)
+ DrawTextExt(drawto,
+ gi->x + border_x + gi->textarea.cursor_x * font_width,
+ gi->y + border_y + gi->textarea.cursor_y * font_height,
+ cursor_string,
+ font_nr, BLIT_INVERSE);
+ }
+ break;
+
case GD_TYPE_SELECTBOX:
{
int i;
break;
case GDI_NUMBER_VALUE:
- gi->text.number_value = va_arg(ap, long);
- sprintf(gi->text.value, "%d", gi->text.number_value);
- gi->text.cursor_position = strlen(gi->text.value);
+ gi->textinput.number_value = va_arg(ap, long);
+ sprintf(gi->textinput.value, "%d", gi->textinput.number_value);
+ gi->textinput.cursor_position = strlen(gi->textinput.value);
break;
case GDI_NUMBER_MIN:
- gi->text.number_min = va_arg(ap, long);
- if (gi->text.number_value < gi->text.number_min)
+ gi->textinput.number_min = va_arg(ap, long);
+ if (gi->textinput.number_value < gi->textinput.number_min)
{
- gi->text.number_value = gi->text.number_min;
- sprintf(gi->text.value, "%d", gi->text.number_value);
+ gi->textinput.number_value = gi->textinput.number_min;
+ sprintf(gi->textinput.value, "%d", gi->textinput.number_value);
}
break;
case GDI_NUMBER_MAX:
- gi->text.number_max = va_arg(ap, long);
- if (gi->text.number_value > gi->text.number_max)
+ gi->textinput.number_max = va_arg(ap, long);
+ if (gi->textinput.number_value > gi->textinput.number_max)
{
- gi->text.number_value = gi->text.number_max;
- sprintf(gi->text.value, "%d", gi->text.number_value);
+ gi->textinput.number_value = gi->textinput.number_max;
+ sprintf(gi->textinput.value, "%d", gi->textinput.number_value);
}
break;
{
int max_textsize = MAX_GADGET_TEXTSIZE;
- if (gi->text.size)
- max_textsize = MIN(gi->text.size, MAX_GADGET_TEXTSIZE - 1);
+ if (gi->textinput.size)
+ max_textsize = MIN(gi->textinput.size, MAX_GADGET_TEXTSIZE - 1);
- strncpy(gi->text.value, va_arg(ap, char *), max_textsize);
- gi->text.value[max_textsize] = '\0';
- gi->text.cursor_position = strlen(gi->text.value);
+ strncpy(gi->textinput.value, va_arg(ap, char *), max_textsize);
+ gi->textinput.value[max_textsize] = '\0';
+ gi->textinput.cursor_position = strlen(gi->textinput.value);
- /* same tag also used for textbutton definition */
- strcpy(gi->textbutton.value, gi->text.value);
+ /* same tag also used for other gadget definitions */
+ strcpy(gi->textbutton.value, gi->textinput.value);
+ strcpy(gi->textarea.value, gi->textinput.value);
}
break;
int tag_value = va_arg(ap, int);
int max_textsize = MIN(tag_value, MAX_GADGET_TEXTSIZE - 1);
- gi->text.size = max_textsize;
- gi->text.value[max_textsize] = '\0';
+ gi->textinput.size = max_textsize;
+ gi->textinput.value[max_textsize] = '\0';
- /* same tag also used for textbutton and selectbox definition */
- strcpy(gi->textbutton.value, gi->text.value);
- gi->textbutton.size = gi->text.size;
- gi->selectbox.size = gi->text.size;
+ /* same tag also used for other gadget definitions */
+ strcpy(gi->textbutton.value, gi->textinput.value);
+ gi->textbutton.size = gi->textinput.size;
+ gi->selectbox.size = gi->textinput.size;
}
break;
gi->drawing.item_xsize = gi->width / gi->drawing.area_xsize;
gi->drawing.item_ysize = gi->height / gi->drawing.area_ysize;
}
+
+ /* same tag also used for other gadget definitions */
+ gi->textarea.xsize = gi->drawing.area_xsize;
+ gi->textarea.ysize = gi->drawing.area_ysize;
+
+ if (gi->type & GD_TYPE_TEXT_AREA) /* force recalculation */
+ {
+ gi->width = 0;
+ gi->height = 0;
+ }
+
break;
case GDI_ITEM_SIZE:
/* adjust gadget values in relation to other gadget values */
- if (gi->type & GD_TYPE_TEXTINPUT)
+ if (gi->type & GD_TYPE_TEXT_INPUT)
{
int font_nr = gi->font_active;
int font_width = getFontWidth(font_nr);
int border_xsize = gi->border.xsize;
int border_ysize = gi->border.ysize;
- gi->width = 2 * border_xsize + (gi->text.size + 1) * font_width;
+ gi->width = 2 * border_xsize + (gi->textinput.size + 1) * font_width;
gi->height = 2 * border_ysize + font_height;
}
Bitmap *src_bitmap;
int src_x, src_y;
- gi->width = 2 * border_xsize + gi->text.size * font_width + button_size;
+ gi->width = 2 * border_xsize + gi->textinput.size*font_width +button_size;
gi->height = 2 * border_ysize + font_height;
if (gi->selectbox.options == NULL)
gi->selectbox.open = FALSE;
}
- if (gi->type & GD_TYPE_TEXTINPUT_NUMERIC)
+ if (gi->type & GD_TYPE_TEXT_INPUT_NUMERIC)
{
- struct GadgetTextInput *text = &gi->text;
+ struct GadgetTextInput *text = &gi->textinput;
int value = text->number_value;
text->number_value = (value < text->number_min ? text->number_min :
if (gs->item_position == gs->items_max - gs->items_visible)
gs->position = gs->position_max;
}
+
+ if (gi->type & GD_TYPE_TEXT_AREA)
+ {
+ int font_nr = gi->font_active;
+ int font_width = getFontWidth(font_nr);
+ int font_height = getFontHeight(font_nr);
+ int border_xsize = gi->border.xsize;
+ int border_ysize = gi->border.ysize;
+
+ if (gi->width == 0 || gi->height == 0)
+ {
+ gi->width = 2 * border_xsize + gi->textarea.xsize * font_width;
+ gi->height = 2 * border_ysize + gi->textarea.ysize * font_height;
+ }
+ else
+ {
+ gi->textarea.xsize = (gi->width - 2 * border_xsize) / font_width;
+ gi->textarea.ysize = (gi->height - 2 * border_ysize) / font_height;
+ }
+ }
}
void ModifyGadget(struct GadgetInfo *gi, int first_tag, ...)
static void CheckRangeOfNumericInputGadget(struct GadgetInfo *gi)
{
- if (gi->type != GD_TYPE_TEXTINPUT_NUMERIC)
+ if (gi->type != GD_TYPE_TEXT_INPUT_NUMERIC)
return;
- gi->text.number_value = atoi(gi->text.value);
+ gi->textinput.number_value = atoi(gi->textinput.value);
- if (gi->text.number_value < gi->text.number_min)
- gi->text.number_value = gi->text.number_min;
- if (gi->text.number_value > gi->text.number_max)
- gi->text.number_value = gi->text.number_max;
+ if (gi->textinput.number_value < gi->textinput.number_min)
+ gi->textinput.number_value = gi->textinput.number_min;
+ if (gi->textinput.number_value > gi->textinput.number_max)
+ gi->textinput.number_value = gi->textinput.number_max;
- sprintf(gi->text.value, "%d", gi->text.number_value);
+ sprintf(gi->textinput.value, "%d", gi->textinput.number_value);
- if (gi->text.cursor_position < 0)
- gi->text.cursor_position = 0;
- else if (gi->text.cursor_position > strlen(gi->text.value))
- gi->text.cursor_position = strlen(gi->text.value);
+ if (gi->textinput.cursor_position < 0)
+ gi->textinput.cursor_position = 0;
+ else if (gi->textinput.cursor_position > strlen(gi->textinput.value))
+ gi->textinput.cursor_position = strlen(gi->textinput.value);
}
/* global pointer to gadget actually in use (when mouse button pressed) */
MultiMapGadgets(MULTIMAP_ALL | MULTIMAP_REMAP);
}
-boolean anyTextInputGadgetActive()
+static boolean anyTextInputGadgetActive()
{
- return (last_gi && (last_gi->type & GD_TYPE_TEXTINPUT) && last_gi->mapped);
+ return (last_gi && (last_gi->type & GD_TYPE_TEXT_INPUT) && last_gi->mapped);
}
-boolean anySelectboxGadgetActive()
+static boolean anyTextAreaGadgetActive()
+{
+ return (last_gi && (last_gi->type & GD_TYPE_TEXT_AREA) && last_gi->mapped);
+}
+
+static boolean anySelectboxGadgetActive()
{
return (last_gi && (last_gi->type & GD_TYPE_SELECTBOX) && last_gi->mapped);
}
boolean anyTextGadgetActive()
{
- return (anyTextInputGadgetActive() || anySelectboxGadgetActive());
+ return (anyTextInputGadgetActive() ||
+ anyTextAreaGadgetActive() ||
+ anySelectboxGadgetActive());
}
void ClickOnGadget(struct GadgetInfo *gi, int button)
last_mx = mx;
last_my = my;
+#if 1
+
+#if 1
+
+ /* if mouse button pressed outside text or selectbox gadget, deactivate it */
+ if (anyTextGadgetActive() &&
+ button != 0 && !motion_status && new_gi != last_gi)
+ {
+ CheckRangeOfNumericInputGadget(last_gi); /* in case of numeric gadget */
+
+ DrawGadget(last_gi, DG_UNPRESSED, last_gi->direct_draw);
+
+ last_gi->event.type = GD_EVENT_TEXT_LEAVING;
+
+ if (last_gi->event_mask & GD_EVENT_TEXT_LEAVING)
+ last_gi->callback_action(last_gi);
+
+ last_gi = NULL;
+ }
+
+#else
+
+ /* special treatment for leaving text and number input gadgets */
+ if (anyTextInputGadgetActive() &&
+ button != 0 && !motion_status && new_gi != last_gi)
+ {
+ /* if mouse button pressed outside text input gadget, deactivate it */
+ CheckRangeOfNumericInputGadget(last_gi);
+ DrawGadget(last_gi, DG_UNPRESSED, last_gi->direct_draw);
+
+ last_gi->event.type = GD_EVENT_TEXT_LEAVING;
+
+ if (last_gi->event_mask & GD_EVENT_TEXT_LEAVING)
+ last_gi->callback_action(last_gi);
+
+ last_gi = NULL;
+ }
+
+ /* special treatment for leaving text area gadgets */
+ if (anyTextAreaGadgetActive() &&
+ button != 0 && !motion_status && new_gi != last_gi)
+ {
+ /* if mouse button pressed outside text input gadget, deactivate it */
+ DrawGadget(last_gi, DG_UNPRESSED, last_gi->direct_draw);
+
+ last_gi->event.type = GD_EVENT_TEXT_LEAVING;
+
+ if (last_gi->event_mask & GD_EVENT_TEXT_LEAVING)
+ last_gi->callback_action(last_gi);
+
+ last_gi = NULL;
+ }
+
+ /* special treatment for leaving selectbox gadgets */
+ if (anySelectboxGadgetActive() &&
+ button != 0 && !motion_status && new_gi != last_gi)
+ {
+ /* if mouse button pressed outside selectbox gadget, deactivate it */
+ DrawGadget(last_gi, DG_UNPRESSED, last_gi->direct_draw);
+
+ last_gi->event.type = GD_EVENT_TEXT_LEAVING;
+
+ if (last_gi->event_mask & GD_EVENT_TEXT_LEAVING)
+ last_gi->callback_action(last_gi);
+
+ last_gi = NULL;
+ }
+
+#endif
+
+#else
+
/* special treatment for text and number input gadgets */
if (anyTextInputGadgetActive() && button != 0 && !motion_status)
{
if (new_gi == last_gi)
{
- int old_cursor_position = gi->text.cursor_position;
+ int old_cursor_position = gi->textinput.cursor_position;
/* if mouse button pressed inside activated text gadget, set cursor */
- gi->text.cursor_position =
+ gi->textinput.cursor_position =
(mx - gi->x - gi->border.xsize) / getFontWidth(gi->font);
- if (gi->text.cursor_position < 0)
- gi->text.cursor_position = 0;
- else if (gi->text.cursor_position > strlen(gi->text.value))
- gi->text.cursor_position = strlen(gi->text.value);
+ if (gi->textinput.cursor_position < 0)
+ gi->textinput.cursor_position = 0;
+ else if (gi->textinput.cursor_position > strlen(gi->textinput.value))
+ gi->textinput.cursor_position = strlen(gi->textinput.value);
- if (gi->text.cursor_position != old_cursor_position)
+ if (gi->textinput.cursor_position != old_cursor_position)
DrawGadget(gi, DG_PRESSED, gi->direct_draw);
}
else
}
}
+ /* special treatment for text area gadgets */
+ if (anyTextAreaGadgetActive() && button != 0 && !motion_status)
+ {
+ struct GadgetInfo *gi = last_gi;
+
+ if (new_gi == last_gi)
+ {
+ int old_cursor_position = gi->textarea.cursor_position;
+ int x = (mx - gi->x - gi->border.xsize) / getFontWidth(gi->font);
+ int y = (my - gi->y - gi->border.ysize) / getFontHeight(gi->font);
+
+ x = (x < 0 ? 0 : x >= gi->textarea.xsize ? gi->textarea.xsize - 1 : x);
+ y = (y < 0 ? 0 : y >= gi->textarea.ysize ? gi->textarea.ysize - 1 : y);
+
+ setTextAreaCursorXY(gi, x, y);
+
+#if 0
+ printf("::: %d -----> %d\n",
+ old_cursor_position,
+ gi->textarea.cursor_position);
+#endif
+
+ if (gi->textarea.cursor_position != old_cursor_position)
+ DrawGadget(gi, DG_PRESSED, gi->direct_draw);
+ }
+ else
+ {
+ /* if mouse button pressed outside text input gadget, deactivate it */
+ DrawGadget(gi, DG_UNPRESSED, gi->direct_draw);
+
+ gi->event.type = GD_EVENT_TEXT_LEAVING;
+
+ if (gi->event_mask & GD_EVENT_TEXT_LEAVING)
+ gi->callback_action(gi);
+
+ last_gi = NULL;
+ }
+ }
+
/* special treatment for selectbox gadgets */
if (anySelectboxGadgetActive() && button != 0 && !motion_status)
{
}
}
+#endif
+
gadget_pressed =
(button != 0 && last_gi == NULL && new_gi != NULL && press_event);
gadget_pressed_repeated =
/* if mouse button released, no gadget needs to be handled anymore */
if (gadget_released)
{
- if ((last_gi->type & GD_TYPE_SELECTBOX) &&
+ if (last_gi->type & GD_TYPE_SELECTBOX &&
(gadget_released_inside_select_line ||
- gadget_released_off_borders)) /* selectbox stays open */
+ gadget_released_off_borders)) /* selectbox stays open */
gi->selectbox.stay_open = TRUE;
- else if (!(last_gi->type & GD_TYPE_TEXTINPUT)) /* text input stays open */
+ else if (!(last_gi->type & GD_TYPE_TEXT_INPUT ||
+ last_gi->type & GD_TYPE_TEXT_AREA)) /* text input stays open */
last_gi = NULL;
}
if (last_x != gi->event.x || last_y != gi->event.y)
changed_position = TRUE;
}
+ else if (gi->type & GD_TYPE_TEXT_INPUT && button != 0 && !motion_status)
+ {
+ int old_cursor_position = gi->textinput.cursor_position;
+
+ /* if mouse button pressed inside activated text gadget, set cursor */
+ gi->textinput.cursor_position =
+ (mx - gi->x - gi->border.xsize) / getFontWidth(gi->font);
+
+ if (gi->textinput.cursor_position < 0)
+ gi->textinput.cursor_position = 0;
+ else if (gi->textinput.cursor_position > strlen(gi->textinput.value))
+ gi->textinput.cursor_position = strlen(gi->textinput.value);
+
+ if (gi->textinput.cursor_position != old_cursor_position)
+ DrawGadget(gi, DG_PRESSED, gi->direct_draw);
+ }
+ else if (gi->type & GD_TYPE_TEXT_AREA && button != 0 && !motion_status)
+ {
+ int old_cursor_position = gi->textarea.cursor_position;
+ int x = (mx - gi->x - gi->border.xsize) / getFontWidth(gi->font);
+ int y = (my - gi->y - gi->border.ysize) / getFontHeight(gi->font);
+
+ x = (x < 0 ? 0 : x >= gi->textarea.xsize ? gi->textarea.xsize - 1 : x);
+ y = (y < 0 ? 0 : y >= gi->textarea.ysize ? gi->textarea.ysize - 1 : y);
+
+ setTextAreaCursorXY(gi, x, y);
+
+ if (gi->textarea.cursor_position != old_cursor_position)
+ DrawGadget(gi, DG_PRESSED, gi->direct_draw);
+ }
else if (gi->type & GD_TYPE_SELECTBOX)
{
int old_index = gi->selectbox.current_index;
}
}
+ /* !!! bad for TEXT_INPUT ... !!! */
DrawGadget(gi, DG_PRESSED, gi->direct_draw);
gi->state = GD_BUTTON_PRESSED;
gi->callback_action(gi);
}
+#if 0
+ if (!mouse_moving)
+ printf("::: PRESSED...?\n");
+#endif
+
if (gadget_pressed_repeated)
{
gi->event.type = GD_EVENT_PRESSED;
}
if (deactivate_gadget &&
- !(gi->type & GD_TYPE_TEXTINPUT)) /* text input stays open */
+ !(gi->type & GD_TYPE_TEXT_INPUT ||
+ gi->type & GD_TYPE_TEXT_AREA)) /* text input stays open */
DrawGadget(gi, DG_UNPRESSED, gi->direct_draw);
gi->state = GD_BUTTON_UNPRESSED;
new_gi->state = GD_BUTTON_UNPRESSED;
}
+static void insertCharIntoTextArea(struct GadgetInfo *gi, char c)
+{
+ char text[MAX_GADGET_TEXTSIZE];
+ int cursor_position = gi->textarea.cursor_position;
+
+ if (strlen(gi->textarea.value) == MAX_GADGET_TEXTSIZE) /* no space left */
+ return;
+
+#if 0
+ printf("::: '%s' + '%c'", gi->textarea.value, c);
+#endif
+
+ strcpy(text, gi->textarea.value);
+ strcpy(&gi->textarea.value[cursor_position + 1], &text[cursor_position]);
+ gi->textarea.value[cursor_position] = c;
+
+#if 0
+ printf(" => '%s'\n", gi->textarea.value);
+#endif
+
+ setTextAreaCursorPosition(gi, gi->textarea.cursor_position + 1);
+}
+
void HandleGadgetsKeyInput(Key key)
{
struct GadgetInfo *gi = last_gi;
if (gi == NULL || !gi->mapped ||
- !((gi->type & GD_TYPE_TEXTINPUT) || (gi->type & GD_TYPE_SELECTBOX)))
+ !(gi->type & GD_TYPE_TEXT_INPUT ||
+ gi->type & GD_TYPE_TEXT_AREA ||
+ gi->type & GD_TYPE_SELECTBOX))
return;
if (key == KSYM_Return) /* valid for both text input and selectbox */
{
- if (gi->type & GD_TYPE_TEXTINPUT)
+ if (gi->type & GD_TYPE_TEXT_INPUT)
CheckRangeOfNumericInputGadget(gi);
else if (gi->type & GD_TYPE_SELECTBOX)
gi->selectbox.index = gi->selectbox.current_index;
- DrawGadget(gi, DG_UNPRESSED, gi->direct_draw);
+ if (gi->type & GD_TYPE_TEXT_AREA)
+ {
+ insertCharIntoTextArea(gi, '\n');
+
+ DrawGadget(gi, DG_PRESSED, gi->direct_draw);
+ }
+ else
+ {
+ DrawGadget(gi, DG_UNPRESSED, gi->direct_draw);
- gi->event.type = GD_EVENT_TEXT_RETURN;
+ gi->event.type = GD_EVENT_TEXT_RETURN;
+
+ last_gi = NULL;
+ }
if (gi->event_mask & GD_EVENT_TEXT_RETURN)
gi->callback_action(gi);
-
- last_gi = NULL;
}
- else if (gi->type & GD_TYPE_TEXTINPUT) /* only valid for text input */
+ else if (gi->type & GD_TYPE_TEXT_INPUT) /* only valid for text input */
{
char text[MAX_GADGET_TEXTSIZE];
- int text_length = strlen(gi->text.value);
- int cursor_pos = gi->text.cursor_position;
+ int text_length = strlen(gi->textinput.value);
+ int cursor_pos = gi->textinput.cursor_position;
char letter = getCharFromKey(key);
- boolean legal_letter = (gi->type == GD_TYPE_TEXTINPUT_NUMERIC ?
+ boolean legal_letter = (gi->type == GD_TYPE_TEXT_INPUT_NUMERIC ?
letter >= '0' && letter <= '9' :
letter != 0);
- if (legal_letter && text_length < gi->text.size)
+ if (legal_letter && text_length < gi->textinput.size)
+ {
+ strcpy(text, gi->textinput.value);
+ strcpy(&gi->textinput.value[cursor_pos + 1], &text[cursor_pos]);
+ gi->textinput.value[cursor_pos] = letter;
+ gi->textinput.cursor_position++;
+
+ DrawGadget(gi, DG_PRESSED, gi->direct_draw);
+ }
+ else if (key == KSYM_Left && cursor_pos > 0)
+ {
+ gi->textinput.cursor_position--;
+
+ DrawGadget(gi, DG_PRESSED, gi->direct_draw);
+ }
+ else if (key == KSYM_Right && cursor_pos < text_length)
+ {
+ gi->textinput.cursor_position++;
+
+ DrawGadget(gi, DG_PRESSED, gi->direct_draw);
+ }
+ else if (key == KSYM_BackSpace && cursor_pos > 0)
+ {
+ strcpy(text, gi->textinput.value);
+ strcpy(&gi->textinput.value[cursor_pos - 1], &text[cursor_pos]);
+ gi->textinput.cursor_position--;
+
+ DrawGadget(gi, DG_PRESSED, gi->direct_draw);
+ }
+ else if (key == KSYM_Delete && cursor_pos < text_length)
+ {
+ strcpy(text, gi->textinput.value);
+ strcpy(&gi->textinput.value[cursor_pos], &text[cursor_pos + 1]);
+
+ DrawGadget(gi, DG_PRESSED, gi->direct_draw);
+ }
+ }
+ else if (gi->type & GD_TYPE_TEXT_AREA) /* only valid for text area */
+ {
+ char text[MAX_GADGET_TEXTSIZE];
+ int text_length = strlen(gi->textarea.value);
+ int area_ysize = gi->textarea.ysize;
+ int cursor_x_pref = gi->textarea.cursor_x_preferred;
+ int cursor_y = gi->textarea.cursor_y;
+ int cursor_pos = gi->textarea.cursor_position;
+ char letter = getCharFromKey(key);
+ boolean legal_letter = (letter != 0);
+
+#if 0
+ printf("::: KEY: %x!\n", key);
+#endif
+
+ if (legal_letter)
{
- strcpy(text, gi->text.value);
- strcpy(&gi->text.value[cursor_pos + 1], &text[cursor_pos]);
- gi->text.value[cursor_pos] = letter;
- gi->text.cursor_position++;
+ insertCharIntoTextArea(gi, letter);
DrawGadget(gi, DG_PRESSED, gi->direct_draw);
}
else if (key == KSYM_Left && cursor_pos > 0)
{
- gi->text.cursor_position--;
+ setTextAreaCursorPosition(gi, gi->textarea.cursor_position - 1);
+
DrawGadget(gi, DG_PRESSED, gi->direct_draw);
}
else if (key == KSYM_Right && cursor_pos < text_length)
{
- gi->text.cursor_position++;
+ setTextAreaCursorPosition(gi, gi->textarea.cursor_position + 1);
+
+ DrawGadget(gi, DG_PRESSED, gi->direct_draw);
+ }
+ else if (key == KSYM_Up && cursor_y > 0)
+ {
+ setTextAreaCursorXY(gi, cursor_x_pref, cursor_y - 1);
+ gi->textarea.cursor_x_preferred = cursor_x_pref;
+
+ DrawGadget(gi, DG_PRESSED, gi->direct_draw);
+ }
+ else if (key == KSYM_Down && cursor_y < area_ysize - 1)
+ {
+ setTextAreaCursorXY(gi, cursor_x_pref, cursor_y + 1);
+ gi->textarea.cursor_x_preferred = cursor_x_pref;
+
DrawGadget(gi, DG_PRESSED, gi->direct_draw);
}
else if (key == KSYM_BackSpace && cursor_pos > 0)
{
- strcpy(text, gi->text.value);
- strcpy(&gi->text.value[cursor_pos - 1], &text[cursor_pos]);
- gi->text.cursor_position--;
+ strcpy(text, gi->textarea.value);
+ strcpy(&gi->textarea.value[cursor_pos - 1], &text[cursor_pos]);
+
+ setTextAreaCursorPosition(gi, gi->textarea.cursor_position - 1);
+
DrawGadget(gi, DG_PRESSED, gi->direct_draw);
}
else if (key == KSYM_Delete && cursor_pos < text_length)
{
- strcpy(text, gi->text.value);
- strcpy(&gi->text.value[cursor_pos], &text[cursor_pos + 1]);
+ strcpy(text, gi->textarea.value);
+ strcpy(&gi->textarea.value[cursor_pos], &text[cursor_pos + 1]);
+
DrawGadget(gi, DG_PRESSED, gi->direct_draw);
}
}
if (key == KSYM_Up && index > 0)
{
gi->selectbox.current_index--;
+
DrawGadget(gi, DG_PRESSED, gi->direct_draw);
}
else if (key == KSYM_Down && index < num_values - 1)
{
gi->selectbox.current_index++;
+
DrawGadget(gi, DG_PRESSED, gi->direct_draw);
}
}