2008-01-17 23:09:49 +00:00
|
|
|
#include <stdio.h>
|
2009-10-27 14:38:53 +00:00
|
|
|
#include <engine/client/graphics.h>
|
2008-01-17 23:09:49 +00:00
|
|
|
#include "ed_editor.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
// popup menu handling
|
|
|
|
static struct
|
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
CUIRect rect;
|
2008-01-17 23:09:49 +00:00
|
|
|
void *id;
|
2009-10-27 14:38:53 +00:00
|
|
|
int (*func)(EDITOR *pEditor, CUIRect rect);
|
2008-01-17 23:09:49 +00:00
|
|
|
int is_menu;
|
|
|
|
void *extra;
|
|
|
|
} ui_popups[8];
|
|
|
|
|
|
|
|
static int ui_num_popups = 0;
|
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
void EDITOR::ui_invoke_popup_menu(void *id, int flags, float x, float y, float w, float h, int (*func)(EDITOR *pEditor, CUIRect rect), void *extra)
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
|
|
|
dbg_msg("", "invoked");
|
|
|
|
ui_popups[ui_num_popups].id = id;
|
|
|
|
ui_popups[ui_num_popups].is_menu = flags;
|
|
|
|
ui_popups[ui_num_popups].rect.x = x;
|
|
|
|
ui_popups[ui_num_popups].rect.y = y;
|
|
|
|
ui_popups[ui_num_popups].rect.w = w;
|
|
|
|
ui_popups[ui_num_popups].rect.h = h;
|
|
|
|
ui_popups[ui_num_popups].func = func;
|
|
|
|
ui_popups[ui_num_popups].extra = extra;
|
|
|
|
ui_num_popups++;
|
|
|
|
}
|
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
void EDITOR::ui_do_popup_menu()
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
|
|
|
for(int i = 0; i < ui_num_popups; i++)
|
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
bool inside = UI()->MouseInside(&ui_popups[i].rect);
|
|
|
|
UI()->SetHotItem(&ui_popups[i].id);
|
2008-01-17 23:09:49 +00:00
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
if(UI()->ActiveItem() == &ui_popups[i].id)
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
if(!UI()->MouseButton(0))
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
|
|
|
if(!inside)
|
|
|
|
ui_num_popups--;
|
2009-10-27 14:38:53 +00:00
|
|
|
UI()->SetActiveItem(0);
|
2008-01-17 23:09:49 +00:00
|
|
|
}
|
|
|
|
}
|
2009-10-27 14:38:53 +00:00
|
|
|
else if(UI()->HotItem() == &ui_popups[i].id)
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
if(UI()->MouseButton(0))
|
|
|
|
UI()->SetActiveItem(&ui_popups[i].id);
|
2008-01-17 23:09:49 +00:00
|
|
|
}
|
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
int corners = CUI::CORNER_ALL;
|
2008-01-17 23:09:49 +00:00
|
|
|
if(ui_popups[i].is_menu)
|
2009-10-27 14:38:53 +00:00
|
|
|
corners = CUI::CORNER_R|CUI::CORNER_B;
|
2008-01-17 23:09:49 +00:00
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
CUIRect r = ui_popups[i].rect;
|
|
|
|
RenderTools()->DrawUIRect(&r, vec4(0.5f,0.5f,0.5f,0.75f), corners, 3.0f);
|
|
|
|
r.Margin(1.0f, &r);
|
|
|
|
RenderTools()->DrawUIRect(&r, vec4(0,0,0,0.75f), corners, 3.0f);
|
|
|
|
r.Margin(4.0f, &r);
|
2008-01-17 23:09:49 +00:00
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
if(ui_popups[i].func(this, r))
|
2008-01-17 23:09:49 +00:00
|
|
|
ui_num_popups--;
|
|
|
|
|
2008-10-23 16:18:33 +00:00
|
|
|
if(inp_key_down(KEY_ESCAPE))
|
2008-01-17 23:09:49 +00:00
|
|
|
ui_num_popups--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
int EDITOR::popup_group(EDITOR *pEditor, CUIRect view)
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
|
|
|
// remove group button
|
2009-10-27 14:38:53 +00:00
|
|
|
CUIRect button;
|
|
|
|
view.HSplitBottom(12.0f, &view, &button);
|
2008-01-17 23:09:49 +00:00
|
|
|
static int delete_button = 0;
|
2008-03-02 15:53:53 +00:00
|
|
|
|
|
|
|
// don't allow deletion of game group
|
2009-10-27 14:38:53 +00:00
|
|
|
if(pEditor->map.game_group != pEditor->get_selected_group() &&
|
|
|
|
pEditor->DoButton_Editor(&delete_button, "Delete Group", 0, &button, 0, "Delete group"))
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
pEditor->map.delete_group(pEditor->selected_group);
|
2008-01-17 23:09:49 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// new tile layer
|
2009-10-27 14:38:53 +00:00
|
|
|
view.HSplitBottom(10.0f, &view, &button);
|
|
|
|
view.HSplitBottom(12.0f, &view, &button);
|
2008-01-17 23:09:49 +00:00
|
|
|
static int new_quad_layer_button = 0;
|
2009-10-27 14:38:53 +00:00
|
|
|
if(pEditor->DoButton_Editor(&new_quad_layer_button, "Add Quads Layer", 0, &button, 0, "Creates a new quad layer"))
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
|
|
|
LAYER *l = new LAYER_QUADS;
|
2009-10-27 14:38:53 +00:00
|
|
|
pEditor->map.groups[pEditor->selected_group]->add_layer(l);
|
|
|
|
pEditor->selected_layer = pEditor->map.groups[pEditor->selected_group]->layers.len()-1;
|
2008-01-17 23:09:49 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// new quad layer
|
2009-10-27 14:38:53 +00:00
|
|
|
view.HSplitBottom(5.0f, &view, &button);
|
|
|
|
view.HSplitBottom(12.0f, &view, &button);
|
2008-01-17 23:09:49 +00:00
|
|
|
static int new_tile_layer_button = 0;
|
2009-10-27 14:38:53 +00:00
|
|
|
if(pEditor->DoButton_Editor(&new_tile_layer_button, "Add Tile Layer", 0, &button, 0, "Creates a new tile layer"))
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
|
|
|
LAYER *l = new LAYER_TILES(50, 50);
|
2009-10-27 14:38:53 +00:00
|
|
|
pEditor->map.groups[pEditor->selected_group]->add_layer(l);
|
|
|
|
pEditor->selected_layer = pEditor->map.groups[pEditor->selected_group]->layers.len()-1;
|
2008-01-17 23:09:49 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_ORDER=0,
|
|
|
|
PROP_POS_X,
|
|
|
|
PROP_POS_Y,
|
|
|
|
PROP_PARA_X,
|
|
|
|
PROP_PARA_Y,
|
2008-03-29 11:44:03 +00:00
|
|
|
PROP_USE_CLIPPING,
|
|
|
|
PROP_CLIP_X,
|
|
|
|
PROP_CLIP_Y,
|
|
|
|
PROP_CLIP_W,
|
|
|
|
PROP_CLIP_H,
|
2008-01-17 23:09:49 +00:00
|
|
|
NUM_PROPS,
|
|
|
|
};
|
|
|
|
|
|
|
|
PROPERTY props[] = {
|
2009-10-27 14:38:53 +00:00
|
|
|
{"Order", pEditor->selected_group, PROPTYPE_INT_STEP, 0, pEditor->map.groups.len()-1},
|
|
|
|
{"Pos X", -pEditor->map.groups[pEditor->selected_group]->offset_x, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
|
|
|
{"Pos Y", -pEditor->map.groups[pEditor->selected_group]->offset_y, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
|
|
|
{"Para X", pEditor->map.groups[pEditor->selected_group]->parallax_x, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
|
|
|
{"Para Y", pEditor->map.groups[pEditor->selected_group]->parallax_y, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
2008-03-29 11:44:03 +00:00
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
{"Use Clipping", pEditor->map.groups[pEditor->selected_group]->use_clipping, PROPTYPE_BOOL, 0, 1},
|
|
|
|
{"Clip X", pEditor->map.groups[pEditor->selected_group]->clip_x, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
|
|
|
{"Clip Y", pEditor->map.groups[pEditor->selected_group]->clip_y, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
|
|
|
{"Clip W", pEditor->map.groups[pEditor->selected_group]->clip_w, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
|
|
|
{"Clip H", pEditor->map.groups[pEditor->selected_group]->clip_h, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
2008-01-17 23:09:49 +00:00
|
|
|
{0},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int ids[NUM_PROPS] = {0};
|
|
|
|
int new_val = 0;
|
|
|
|
|
|
|
|
// cut the properties that isn't needed
|
2009-10-27 14:38:53 +00:00
|
|
|
if(pEditor->get_selected_group()->game_group)
|
2008-01-17 23:09:49 +00:00
|
|
|
props[PROP_POS_X].name = 0;
|
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
int prop = pEditor->do_properties(&view, props, ids, &new_val);
|
2008-01-17 23:09:49 +00:00
|
|
|
if(prop == PROP_ORDER)
|
2009-10-27 14:38:53 +00:00
|
|
|
pEditor->selected_group = pEditor->map.swap_groups(pEditor->selected_group, new_val);
|
2008-01-17 23:09:49 +00:00
|
|
|
|
|
|
|
// these can not be changed on the game group
|
2009-10-27 14:38:53 +00:00
|
|
|
if(!pEditor->get_selected_group()->game_group)
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
if(prop == PROP_PARA_X) pEditor->map.groups[pEditor->selected_group]->parallax_x = new_val;
|
|
|
|
else if(prop == PROP_PARA_Y) pEditor->map.groups[pEditor->selected_group]->parallax_y = new_val;
|
|
|
|
else if(prop == PROP_POS_X) pEditor->map.groups[pEditor->selected_group]->offset_x = -new_val;
|
|
|
|
else if(prop == PROP_POS_Y) pEditor->map.groups[pEditor->selected_group]->offset_y = -new_val;
|
|
|
|
else if(prop == PROP_USE_CLIPPING) pEditor->map.groups[pEditor->selected_group]->use_clipping = new_val;
|
|
|
|
else if(prop == PROP_CLIP_X) pEditor->map.groups[pEditor->selected_group]->clip_x = new_val;
|
|
|
|
else if(prop == PROP_CLIP_Y) pEditor->map.groups[pEditor->selected_group]->clip_y = new_val;
|
|
|
|
else if(prop == PROP_CLIP_W) pEditor->map.groups[pEditor->selected_group]->clip_w = new_val;
|
|
|
|
else if(prop == PROP_CLIP_H) pEditor->map.groups[pEditor->selected_group]->clip_h = new_val;
|
2008-01-17 23:09:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
int EDITOR::popup_layer(EDITOR *pEditor, CUIRect view)
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
|
|
|
// remove layer button
|
2009-10-27 14:38:53 +00:00
|
|
|
CUIRect button;
|
|
|
|
view.HSplitBottom(12.0f, &view, &button);
|
2008-01-17 23:09:49 +00:00
|
|
|
static int delete_button = 0;
|
2008-03-02 15:53:53 +00:00
|
|
|
|
|
|
|
// don't allow deletion of game layer
|
2009-10-27 14:38:53 +00:00
|
|
|
if(pEditor->map.game_layer != pEditor->get_selected_layer(0) &&
|
|
|
|
pEditor->DoButton_Editor(&delete_button, "Delete Layer", 0, &button, 0, "Deletes the layer"))
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
pEditor->map.groups[pEditor->selected_group]->delete_layer(pEditor->selected_layer);
|
2008-01-17 23:09:49 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
view.HSplitBottom(10.0f, &view, 0);
|
2008-01-17 23:09:49 +00:00
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
LAYERGROUP *current_group = pEditor->map.groups[pEditor->selected_group];
|
|
|
|
LAYER *current_layer = pEditor->get_selected_layer(0);
|
2008-01-17 23:09:49 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_GROUP=0,
|
|
|
|
PROP_ORDER,
|
2008-03-21 17:39:09 +00:00
|
|
|
PROP_HQ,
|
2008-01-17 23:09:49 +00:00
|
|
|
NUM_PROPS,
|
|
|
|
};
|
|
|
|
|
|
|
|
PROPERTY props[] = {
|
2009-10-27 14:38:53 +00:00
|
|
|
{"Group", pEditor->selected_group, PROPTYPE_INT_STEP, 0, pEditor->map.groups.len()-1},
|
|
|
|
{"Order", pEditor->selected_layer, PROPTYPE_INT_STEP, 0, current_group->layers.len()},
|
2008-03-21 17:39:09 +00:00
|
|
|
{"Detail", current_layer->flags&LAYERFLAG_DETAIL, PROPTYPE_BOOL, 0, 1},
|
2008-01-17 23:09:49 +00:00
|
|
|
{0},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int ids[NUM_PROPS] = {0};
|
|
|
|
int new_val = 0;
|
2009-10-27 14:38:53 +00:00
|
|
|
int prop = pEditor->do_properties(&view, props, ids, &new_val);
|
2008-01-17 23:09:49 +00:00
|
|
|
|
|
|
|
if(prop == PROP_ORDER)
|
2009-10-27 14:38:53 +00:00
|
|
|
pEditor->selected_layer = current_group->swap_layers(pEditor->selected_layer, new_val);
|
2008-01-17 23:09:49 +00:00
|
|
|
else if(prop == PROP_GROUP && current_layer->type != LAYERTYPE_GAME)
|
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
if(new_val >= 0 && new_val < pEditor->map.groups.len())
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
|
|
|
current_group->layers.remove(current_layer);
|
2009-10-27 14:38:53 +00:00
|
|
|
pEditor->map.groups[new_val]->layers.add(current_layer);
|
|
|
|
pEditor->selected_group = new_val;
|
|
|
|
pEditor->selected_layer = pEditor->map.groups[new_val]->layers.len()-1;
|
2008-01-17 23:09:49 +00:00
|
|
|
}
|
|
|
|
}
|
2008-03-21 17:39:09 +00:00
|
|
|
else if(prop == PROP_HQ)
|
|
|
|
{
|
|
|
|
current_layer->flags &= ~LAYERFLAG_DETAIL;
|
|
|
|
if(new_val)
|
|
|
|
current_layer->flags |= LAYERFLAG_DETAIL;
|
|
|
|
}
|
2008-01-17 23:09:49 +00:00
|
|
|
|
|
|
|
return current_layer->render_properties(&view);
|
|
|
|
}
|
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
int EDITOR::popup_quad(EDITOR *pEditor, CUIRect view)
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
QUAD *quad = pEditor->get_selected_quad();
|
2008-01-17 23:09:49 +00:00
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
CUIRect button;
|
2008-03-02 15:59:52 +00:00
|
|
|
|
|
|
|
// delete button
|
2009-10-27 14:38:53 +00:00
|
|
|
view.HSplitBottom(12.0f, &view, &button);
|
2008-03-02 15:59:52 +00:00
|
|
|
static int delete_button = 0;
|
2009-10-27 14:38:53 +00:00
|
|
|
if(pEditor->DoButton_Editor(&delete_button, "Delete", 0, &button, 0, "Deletes the current quad"))
|
2008-03-02 15:59:52 +00:00
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
LAYER_QUADS *layer = (LAYER_QUADS *)pEditor->get_selected_layer_type(0, LAYERTYPE_QUADS);
|
2008-03-02 15:59:52 +00:00
|
|
|
if(layer)
|
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
layer->quads.removebyindex(pEditor->selected_quad);
|
|
|
|
pEditor->selected_quad--;
|
2008-03-02 15:59:52 +00:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// square button
|
2009-10-27 14:38:53 +00:00
|
|
|
view.HSplitBottom(10.0f, &view, &button);
|
|
|
|
view.HSplitBottom(12.0f, &view, &button);
|
2008-01-17 23:09:49 +00:00
|
|
|
static int sq_button = 0;
|
2009-10-27 14:38:53 +00:00
|
|
|
if(pEditor->DoButton_Editor(&sq_button, "Square", 0, &button, 0, "Squares the current quad"))
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
|
|
|
int top = quad->points[0].y;
|
|
|
|
int left = quad->points[0].x;
|
|
|
|
int bottom = quad->points[0].y;
|
|
|
|
int right = quad->points[0].x;
|
|
|
|
|
|
|
|
for(int k = 1; k < 4; k++)
|
|
|
|
{
|
|
|
|
if(quad->points[k].y < top) top = quad->points[k].y;
|
|
|
|
if(quad->points[k].x < left) left = quad->points[k].x;
|
|
|
|
if(quad->points[k].y > bottom) bottom = quad->points[k].y;
|
|
|
|
if(quad->points[k].x > right) right = quad->points[k].x;
|
|
|
|
}
|
|
|
|
|
|
|
|
quad->points[0].x = left; quad->points[0].y = top;
|
|
|
|
quad->points[1].x = right; quad->points[1].y = top;
|
|
|
|
quad->points[2].x = left; quad->points[2].y = bottom;
|
|
|
|
quad->points[3].x = right; quad->points[3].y = bottom;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_POS_ENV=0,
|
|
|
|
PROP_POS_ENV_OFFSET,
|
|
|
|
PROP_COLOR_ENV,
|
|
|
|
PROP_COLOR_ENV_OFFSET,
|
|
|
|
NUM_PROPS,
|
|
|
|
};
|
|
|
|
|
|
|
|
PROPERTY props[] = {
|
2009-10-27 14:38:53 +00:00
|
|
|
{"Pos. Env", quad->pos_env, PROPTYPE_INT_STEP, -1, pEditor->map.envelopes.len()},
|
2008-01-17 23:09:49 +00:00
|
|
|
{"Pos. TO", quad->pos_env_offset, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
2009-10-27 14:38:53 +00:00
|
|
|
{"Color Env", quad->color_env, PROPTYPE_INT_STEP, -1, pEditor->map.envelopes.len()},
|
2008-01-17 23:09:49 +00:00
|
|
|
{"Color TO", quad->color_env_offset, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
|
|
|
|
|
|
|
{0},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int ids[NUM_PROPS] = {0};
|
|
|
|
int new_val = 0;
|
2009-10-27 14:38:53 +00:00
|
|
|
int prop = pEditor->do_properties(&view, props, ids, &new_val);
|
2008-01-17 23:09:49 +00:00
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
if(prop == PROP_POS_ENV) quad->pos_env = clamp(new_val, -1, pEditor->map.envelopes.len()-1);
|
2008-01-17 23:09:49 +00:00
|
|
|
if(prop == PROP_POS_ENV_OFFSET) quad->pos_env_offset = new_val;
|
2009-10-27 14:38:53 +00:00
|
|
|
if(prop == PROP_COLOR_ENV) quad->color_env = clamp(new_val, -1, pEditor->map.envelopes.len()-1);
|
2008-01-17 23:09:49 +00:00
|
|
|
if(prop == PROP_COLOR_ENV_OFFSET) quad->color_env_offset = new_val;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
int EDITOR::popup_point(EDITOR *pEditor, CUIRect view)
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
QUAD *quad = pEditor->get_selected_quad();
|
2008-01-17 23:09:49 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_COLOR=0,
|
|
|
|
NUM_PROPS,
|
|
|
|
};
|
|
|
|
|
|
|
|
int color = 0;
|
|
|
|
|
|
|
|
for(int v = 0; v < 4; v++)
|
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
if(pEditor->selected_points&(1<<v))
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
|
|
|
color = 0;
|
|
|
|
color |= quad->colors[v].r<<24;
|
|
|
|
color |= quad->colors[v].g<<16;
|
|
|
|
color |= quad->colors[v].b<<8;
|
|
|
|
color |= quad->colors[v].a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PROPERTY props[] = {
|
2009-10-27 14:38:53 +00:00
|
|
|
{"Color", color, PROPTYPE_COLOR, -1, pEditor->map.envelopes.len()},
|
2008-01-17 23:09:49 +00:00
|
|
|
{0},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int ids[NUM_PROPS] = {0};
|
|
|
|
int new_val = 0;
|
2009-10-27 14:38:53 +00:00
|
|
|
int prop = pEditor->do_properties(&view, props, ids, &new_val);
|
2008-01-17 23:09:49 +00:00
|
|
|
if(prop == PROP_COLOR)
|
|
|
|
{
|
|
|
|
for(int v = 0; v < 4; v++)
|
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
if(pEditor->selected_points&(1<<v))
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
|
|
|
color = 0;
|
|
|
|
quad->colors[v].r = (new_val>>24)&0xff;
|
|
|
|
quad->colors[v].g = (new_val>>16)&0xff;
|
|
|
|
quad->colors[v].b = (new_val>>8)&0xff;
|
|
|
|
quad->colors[v].a = new_val&0xff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int select_image_selected = -100;
|
|
|
|
static int select_image_current = -100;
|
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
int EDITOR::popup_select_image(EDITOR *pEditor, CUIRect view)
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
CUIRect buttonbar, imageview;
|
|
|
|
view.VSplitLeft(80.0f, &buttonbar, &view);
|
|
|
|
view.Margin(10.0f, &imageview);
|
2008-01-17 23:09:49 +00:00
|
|
|
|
|
|
|
int show_image = select_image_current;
|
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
for(int i = -1; i < pEditor->map.images.len(); i++)
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
CUIRect button;
|
|
|
|
buttonbar.HSplitTop(12.0f, &button, &buttonbar);
|
|
|
|
buttonbar.HSplitTop(2.0f, 0, &buttonbar);
|
2008-01-17 23:09:49 +00:00
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
if(pEditor->UI()->MouseInside(&button))
|
2008-01-17 23:09:49 +00:00
|
|
|
show_image = i;
|
|
|
|
|
|
|
|
if(i == -1)
|
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
if(pEditor->DoButton_MenuItem(&pEditor->map.images[i], "None", i==select_image_current, &button))
|
2008-01-17 23:09:49 +00:00
|
|
|
select_image_selected = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
if(pEditor->DoButton_MenuItem(&pEditor->map.images[i], pEditor->map.images[i]->name, i==select_image_current, &button))
|
2008-01-17 23:09:49 +00:00
|
|
|
select_image_selected = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
if(show_image >= 0 && show_image < pEditor->map.images.len())
|
|
|
|
pEditor->Graphics()->TextureSet(pEditor->map.images[show_image]->tex_id);
|
2008-01-17 23:09:49 +00:00
|
|
|
else
|
2009-10-27 14:38:53 +00:00
|
|
|
pEditor->Graphics()->TextureSet(-1);
|
|
|
|
pEditor->Graphics()->QuadsBegin();
|
|
|
|
pEditor->Graphics()->QuadsDrawTL(imageview.x, imageview.y, imageview.w, imageview.h);
|
|
|
|
pEditor->Graphics()->QuadsEnd();
|
2008-01-17 23:09:49 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
void EDITOR::popup_select_image_invoke(int current, float x, float y)
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
|
|
|
static int select_image_popup_id = 0;
|
|
|
|
select_image_selected = -100;
|
|
|
|
select_image_current = current;
|
|
|
|
ui_invoke_popup_menu(&select_image_popup_id, 0, x, y, 400, 300, popup_select_image);
|
|
|
|
}
|
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
int EDITOR::popup_select_image_result()
|
2008-01-17 23:09:49 +00:00
|
|
|
{
|
|
|
|
if(select_image_selected == -100)
|
|
|
|
return -100;
|
|
|
|
|
|
|
|
select_image_current = select_image_selected;
|
|
|
|
select_image_selected = -100;
|
|
|
|
return select_image_current;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|