{ "editor.input.textarea.active_xoffset", "-100" },
{ "editor.input.textarea.border_size", "3" },
+ { "editor.input.colorpicker", "RocksDoor.png" },
+ { "editor.input.colorpicker.x", "324" },
+ { "editor.input.colorpicker.y", "60" },
+ { "editor.input.colorpicker.width", "52" },
+ { "editor.input.colorpicker.height", "20" },
+ { "editor.input.colorpicker.active_xoffset", "-100" },
+ { "editor.input.colorpicker.border_size", "3" },
+
{ "editor.cascade_list", "RocksMore.png" },
{ "editor.cascade_list.xpos", "9" },
{ "editor.cascade_list.ypos", "8" },
GADGET_ID_CHANGE_BY_DIRECT_ACT,
GADGET_ID_CHANGE_BY_OTHER_ACT,
+ // color picker identifiers
+
+ GADGET_ID_COLOR_PICKER,
+
NUM_STATIC_GADGET_IDS
};
#define ED_DRAWING_ID_EDITOR_FIRST ED_DRAWING_ID_RANDOM_BACKGROUND
#define ED_DRAWING_ID_EDITOR_LAST ED_DRAWING_ID_RANDOM_BACKGROUND
+// values for color picker gadgets
+enum
+{
+ ED_COLORPICKER_ID_PICK_COLOR,
+
+ ED_NUM_COLORPICKERS
+};
+
+#define ED_COLORPICKER_ID_FIRST ED_COLORPICKER_ID_PICK_COLOR
+#define ED_COLORPICKER_ID_LAST ED_COLORPICKER_ID_PICK_COLOR
+
// ----------------------------------------------------------------------------
// some internally used definitions
},
};
+static struct
+{
+ int gadget_type_id;
+ int x, y;
+ int gadget_id;
+ int *value;
+ char *infotext;
+} colorpicker_info[ED_NUM_COLORPICKERS] =
+{
+ {
+ ED_COLORPICKER_ID_PICK_COLOR,
+ 8, 40,
+ GADGET_ID_COLOR_PICKER,
+ NULL,
+ "Select color"
+ },
+};
+
// ----------------------------------------------------------------------------
// some internally used variables
static void HandleCheckbuttons(struct GadgetInfo *);
static void HandleControlButtons(struct GadgetInfo *);
static void HandleDrawingAreaInfo(struct GadgetInfo *);
+static void HandleColorPickerGadgets(struct GadgetInfo *);
static void PrintEditorGadgetInfoText(struct GadgetInfo *);
static boolean AskToCopyAndModifyLevelTemplate(void);
static boolean getDrawModeHiRes(void);
}
}
+static void CreateColorPickerGadgets(void)
+{
+ int i;
+
+ for (i = 0; i < ED_NUM_COLORPICKERS; i++)
+ {
+ struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_INPUT_COLORPICKER];
+ int gd_x1 = gd->src_x;
+ int gd_y1 = gd->src_y;
+ int gd_x2 = gd->src_x + gd->active_xoffset;
+ int gd_y2 = gd->src_y + gd->active_yoffset;
+ struct GadgetInfo *gi;
+ unsigned int event_mask = GD_EVENT_COLOR_PICKER_LEAVING;
+ int id = colorpicker_info[i].gadget_id;
+ int type_id = colorpicker_info[i].gadget_type_id;
+
+ if (type_id != i)
+ Fail("'colorpicker_info' structure corrupted at index %d -- please fix", i);
+
+ gi = CreateGadget(GDI_CUSTOM_ID, id,
+ GDI_CUSTOM_TYPE_ID, type_id,
+ GDI_INFO_TEXT, colorpicker_info[i].infotext,
+ GDI_X, SX + ED_SETTINGS_X(colorpicker_info[i].x),
+ GDI_Y, SY + ED_SETTINGS_Y(colorpicker_info[i].y),
+ GDI_TYPE, GD_TYPE_COLOR_PICKER,
+ GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1,
+ GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2,
+ GDI_BORDER_SIZE, gd->border_size, gd->border_size,
+ GDI_DESIGN_WIDTH, gd->width,
+ GDI_DESIGN_HEIGHT, gd->height,
+ GDI_EVENT_MASK, event_mask,
+ GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
+ GDI_CALLBACK_ACTION, HandleColorPickerGadgets,
+ GDI_CALLBACK_ACTION_ALWAYS, TRUE,
+ GDI_END);
+
+ if (gi == NULL)
+ Fail("cannot create gadget");
+
+ level_editor_gadget[id] = gi;
+ }
+}
+
void CreateLevelEditorGadgets(void)
{
// force EDITOR font inside level editor
CreateGraphicbuttonGadgets();
CreateTextbuttonGadgets();
CreateDrawingAreas();
+ CreateColorPickerGadgets();
ResetFontStatus();
}
MapGadget(gi);
}
+static void MapColorPickerGadget(int id)
+{
+ struct GadgetInfo *gi = level_editor_gadget[colorpicker_info[id].gadget_id];
+
+ MapGadget(gi);
+}
+
static void MapMainDrawingArea(void)
{
boolean no_horizontal_scrollbar = (lev_fieldx + 2 <= ed_fieldx);
else if (type_id >= ED_GRAPHICBUTTON_ID_PICK_FIRST ||
type_id <= ED_GRAPHICBUTTON_ID_PICK_LAST)
{
- Warn("color picker not implemented yet");
+ MapColorPickerGadget(ED_COLORPICKER_ID_PICK_COLOR);
}
}
level.changed = TRUE;
}
+static void HandleColorPickerGadgets(struct GadgetInfo *gi)
+{
+ int type_id = gi->custom_type_id;
+
+ if (type_id == ED_COLORPICKER_ID_PICK_COLOR)
+ DrawLevelConfigWindow();
+
+ level.changed = TRUE;
+}
+
static void HandleControlButtons(struct GadgetInfo *gi)
{
static int last_level_drawing_function = GADGET_ID_SINGLE_ITEMS;