more cleanups, mainly whitespace, indentation and code style... now I can start working on this :)
This commit is contained in:
parent
918e24c97a
commit
88fcb3b9f7
|
@ -38,8 +38,7 @@ e_int_config_penguins_module(E_Comp *comp, const char *params)
|
|||
v->basic.create_widgets = _basic_create_widgets;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/e-module-penguins.edj", e_module_dir_get(pop->module));
|
||||
cfd = e_config_dialog_new(comp,
|
||||
D_("Population Settings"),
|
||||
cfd = e_config_dialog_new(comp, D_("Population Settings"),
|
||||
"Penguins", "appearance/penguins",
|
||||
buf, 0, v, pop);
|
||||
pop->config_dialog = cfd;
|
||||
|
@ -76,8 +75,7 @@ _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
pop = cfd->data;
|
||||
pop->config_dialog = NULL;
|
||||
eina_stringshare_del(cfdata->theme);
|
||||
free(cfdata);
|
||||
cfdata = NULL;
|
||||
E_FREE(cfdata);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
|
@ -85,6 +83,9 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
|||
{
|
||||
Evas_Object *o, *ob, *ol;
|
||||
Penguins_Population *pop;
|
||||
Eina_List *l;
|
||||
int count = 0;
|
||||
char *theme;
|
||||
|
||||
pop = cfd->data;
|
||||
o = e_widget_list_add(evas, 0, 0);
|
||||
|
@ -104,37 +105,25 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
|||
ob = e_widget_slider_add(evas, 1, 0, D_("%1.0f"), 50, 255, 1, 0, NULL, &(cfdata->alpha), 200);
|
||||
e_widget_list_object_append(o, ob, 1, 1, 0.5);
|
||||
|
||||
//Lista
|
||||
ob = e_widget_label_add(evas, D_("Select population:"));
|
||||
e_widget_list_object_append(o, ob, 1, 1, 0.5);
|
||||
ol = e_widget_ilist_add(evas, 24, 24, &(cfdata->theme));
|
||||
|
||||
e_widget_ilist_clear(ol);
|
||||
|
||||
Eina_List *l;
|
||||
int count;
|
||||
l = pop->themes;
|
||||
count = 0;
|
||||
while (l)
|
||||
EINA_LIST_FOREACH(pop->themes, l, theme)
|
||||
{
|
||||
char *theme;
|
||||
char *name;
|
||||
char *name = edje_file_data_get(theme, "PopulationName");
|
||||
Evas_Object *oi;
|
||||
theme = l->data;
|
||||
name = edje_file_data_get(theme, "PopulationName");
|
||||
|
||||
if (name)
|
||||
{
|
||||
oi = edje_object_add(evas);
|
||||
edje_object_file_set(oi, theme, "icon");
|
||||
//printf("TEMA: %s (%s)\n", name, cfdata->theme);
|
||||
e_widget_ilist_append(ol, oi, name, NULL, theme, theme);
|
||||
if (strcmp(theme, cfdata->theme) == 0)
|
||||
{
|
||||
if (!strcmp(theme, cfdata->theme))
|
||||
e_widget_ilist_selected_set(ol, count);
|
||||
}
|
||||
free(name);
|
||||
count++;
|
||||
}
|
||||
l = eina_list_next(l);
|
||||
}
|
||||
e_widget_ilist_go(ol);
|
||||
e_widget_size_min_set(ol, 155, 250);
|
||||
|
|
|
@ -190,31 +190,31 @@ _population_free(Penguins_Population *pop)
|
|||
pop->actions = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Penguins_Action *
|
||||
_load_action(Penguins_Population *pop, const char *filename, char *name, int id)
|
||||
{
|
||||
Penguins_Action *act;
|
||||
int w, h, speed, ret;
|
||||
char *data;
|
||||
|
||||
data = edje_file_data_get(filename, name);
|
||||
if (!data) return NULL;
|
||||
|
||||
ret = sscanf(data, "%d %d %d", &w, &h, &speed);
|
||||
free(data);
|
||||
if (ret != 3) return NULL;
|
||||
|
||||
act = E_NEW(Penguins_Action, 1);
|
||||
if (!act) return NULL;
|
||||
|
||||
act->name = strdup(name);
|
||||
sscanf(data, "%d %d %d", &act->w, &act->h, &act->speed);
|
||||
|
||||
act->w = act->w * pop->conf->zoom;
|
||||
act->h = act->h * pop->conf->zoom;
|
||||
act->speed = act->speed * pop->conf->zoom;
|
||||
act->id = id;
|
||||
act->w = w * pop->conf->zoom;
|
||||
act->h = h * pop->conf->zoom;
|
||||
act->speed = speed * pop->conf->zoom;
|
||||
|
||||
if (!pop->actions)
|
||||
pop->actions = eina_hash_string_small_new(NULL);
|
||||
|
||||
eina_hash_add(pop->actions, name, act);
|
||||
|
||||
return act;
|
||||
|
@ -224,41 +224,40 @@ static Penguins_Custom_Action *
|
|||
_load_custom_action(Penguins_Population *pop, const char *filename, char *name)
|
||||
{
|
||||
Penguins_Custom_Action *c;
|
||||
int w, h, h_speed, v_speed, r_min, r_max, ret;
|
||||
char *data;
|
||||
char buf[25];
|
||||
|
||||
data = edje_file_data_get(filename, name); // TODO free data??
|
||||
data = edje_file_data_get(filename, name);
|
||||
if (!data) return NULL;
|
||||
|
||||
ret = sscanf(data, "%d %d %d %d %d %d",
|
||||
&w, &h, &h_speed, &v_speed, &r_min, &r_max);
|
||||
free(data);
|
||||
if (ret != 6) return NULL;
|
||||
|
||||
c = E_NEW(Penguins_Custom_Action, 1);
|
||||
if (!c) return NULL;
|
||||
|
||||
c->name = strdup(name);
|
||||
sscanf(data, "%d %d %d %d %d %d",
|
||||
&c->w, &c->h, &c->h_speed, &c->v_speed, &c->r_min, &c->r_max);
|
||||
c->w = w * pop->conf->zoom;
|
||||
c->h = h * pop->conf->zoom;
|
||||
c->h_speed = h_speed * pop->conf->zoom;
|
||||
c->v_speed = v_speed * pop->conf->zoom;
|
||||
c->r_min = r_min;
|
||||
c->r_max = r_max;
|
||||
|
||||
c->w = c->w * pop->conf->zoom;
|
||||
c->h = c->h * pop->conf->zoom;
|
||||
|
||||
snprintf(buf, sizeof(buf), "start_custom_%d_left", pop->custom_num+1);
|
||||
pop->custom_num++;
|
||||
snprintf(buf, sizeof(buf), "start_custom_%d_left", pop->custom_num);
|
||||
c->left_program_name = strdup(buf);
|
||||
snprintf(buf, sizeof(buf), "start_custom_%d_right", pop->custom_num+1);
|
||||
snprintf(buf, sizeof(buf), "start_custom_%d_right", pop->custom_num);
|
||||
c->right_program_name = strdup(buf);
|
||||
|
||||
pop->customs = eina_list_append(pop->customs, c);
|
||||
pop->custom_num++;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
hash_fn(const Eina_Hash *hash, const char *key, void *data, void *fdata)
|
||||
{
|
||||
Penguins_Action *a = data;
|
||||
printf("PENGUINS: Load action: '%s' w:%d h:%d speed:%d\n", key, a->w, a->h, a->speed);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_theme_load(Penguins_Population *pop)
|
||||
{
|
||||
|
@ -271,10 +270,10 @@ _theme_load(Penguins_Population *pop)
|
|||
pop->custom_num = 0;
|
||||
|
||||
name = edje_file_data_get(pop->conf->theme, "PopulationName");
|
||||
if (!name)
|
||||
return;
|
||||
if (!name) return;
|
||||
|
||||
//printf("PENGUINS: Load theme: %s (%s)\n", name, pop->conf->theme);
|
||||
free(name);
|
||||
|
||||
// load standard actions
|
||||
_load_action(pop, pop->conf->theme, "Walker", ID_WALKER);
|
||||
|
@ -291,15 +290,6 @@ _theme_load(Penguins_Population *pop)
|
|||
snprintf(buf, sizeof(buf), "Custom_1");
|
||||
while (_load_custom_action(pop, pop->conf->theme, buf))
|
||||
snprintf(buf, sizeof(buf), "Custom_%d", i++);
|
||||
|
||||
// eina_hash_foreach(pop->actions, hash_fn, NULL);
|
||||
// Eina_List *l;
|
||||
// for (l = pop->customs; l; l = l->next )
|
||||
// {
|
||||
// Custom_Action *c = l->data;
|
||||
// printf("PENGUINS: Load custom action: name:'%s' w:%d h:%d h_speed:%d v_speed:%d\n",
|
||||
// c->name, c->w, c->h, c->h_speed, c->v_speed);
|
||||
// }
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -323,10 +313,9 @@ _population_load(Penguins_Population *pop)
|
|||
|
||||
tux->action = eina_hash_find(pop->actions, "Faller");
|
||||
|
||||
evas_object_image_alpha_set(o, 0.5);
|
||||
evas_object_color_set(o, pop->conf->alpha, pop->conf->alpha,
|
||||
pop->conf->alpha, pop->conf->alpha);
|
||||
evas_object_pass_events_set(o, 0);
|
||||
evas_object_pass_events_set(o, EINA_FALSE);
|
||||
|
||||
edje_object_signal_callback_add(o,"click_l","penguins", _cb_click_l, tux);
|
||||
edje_object_signal_callback_add(o,"click_r","penguins", _cb_click_r, tux);
|
||||
|
@ -345,8 +334,6 @@ _delay_born(void *data)
|
|||
{
|
||||
Penguins_Actor *tux = data;
|
||||
|
||||
if (!tux) return ECORE_CALLBACK_CANCEL;
|
||||
|
||||
tux->pop->penguins = eina_list_append(tux->pop->penguins, tux);
|
||||
_reborn(tux);
|
||||
|
||||
|
@ -360,12 +347,14 @@ _cb_click_l (void *data, Evas_Object *o, const char *emi, const char *src)
|
|||
//printf("Left-click on TUX !!!\n");
|
||||
_start_bombing_at(tux, tux->y + tux->action->h);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_click_r (void *data, Evas_Object *o, const char *emi, const char *src)
|
||||
{
|
||||
//printf("Right-click on TUX !!!\n");
|
||||
e_int_config_penguins_module(NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_click_c (void *data, Evas_Object *o, const char *emi, const char *src)
|
||||
{
|
||||
|
@ -379,11 +368,10 @@ _reborn(Penguins_Actor *tux)
|
|||
tux->reverse = random() % (2);
|
||||
tux->x = random() % (tux->pop->width);
|
||||
tux->y = -100;
|
||||
tux->custom = 0;
|
||||
tux->custom = NULL;
|
||||
evas_object_move(tux->obj, (int)tux->x, (int)tux->y);
|
||||
_start_falling_at(tux, tux->x);
|
||||
evas_object_resize(tux->obj, tux->action->w, tux->action->h);
|
||||
evas_object_image_fill_set(tux->obj, 0, 0, tux->action->w, tux->action->h);
|
||||
evas_object_show(tux->obj);
|
||||
}
|
||||
|
||||
|
@ -405,11 +393,11 @@ _cb_animator(void *data)
|
|||
{
|
||||
tux->x += ((double)tux->custom->h_speed * ecore_animator_frametime_get());
|
||||
tux->y += ((double)tux->custom->v_speed * ecore_animator_frametime_get());
|
||||
if (!_is_inside_any_win(pop,
|
||||
if ((!_is_inside_any_win(pop,
|
||||
(int)tux->x + (tux->action->w / 2),
|
||||
(int)tux->y + tux->action->h + 1,
|
||||
RETURN_NONE_VALUE)
|
||||
&& (int)tux->y+tux->action->h+1 < pop->height
|
||||
RETURN_NONE_VALUE))
|
||||
&& ((int)tux->y + tux->action->h + 1 < pop->height)
|
||||
)
|
||||
{
|
||||
edje_object_signal_callback_del(tux->obj,"custom_done","edje", _cb_custom_end);
|
||||
|
@ -481,15 +469,18 @@ _cb_animator(void *data)
|
|||
}
|
||||
}
|
||||
if ((tux->y + tux->action->h) < pop->height)
|
||||
if (!_is_inside_any_win(pop, (int)tux->x+(tux->action->w/2) , (int)tux->y+tux->action->h+1, RETURN_NONE_VALUE))
|
||||
if (!_is_inside_any_win(pop, (int)tux->x + (tux->action->w / 2) ,
|
||||
(int)tux->y + tux->action->h + 1,
|
||||
RETURN_NONE_VALUE))
|
||||
_start_falling_at(tux, (int)tux->x + (tux->action->w / 2));
|
||||
}
|
||||
// right
|
||||
else
|
||||
{
|
||||
tux->x += ((double)tux->action->speed * ecore_animator_frametime_get());
|
||||
if ((touch = _is_inside_any_win(pop, (int)tux->x + tux->action->w, (int)tux->y, RETURN_LEFT_VALUE)) ||
|
||||
(tux->x + tux->action->w) > pop->width)
|
||||
if ((touch = _is_inside_any_win(pop, (int)tux->x + tux->action->w,
|
||||
(int)tux->y, RETURN_LEFT_VALUE))
|
||||
|| (tux->x + tux->action->w) > pop->width)
|
||||
{
|
||||
if (_RAND(CLIMBER_PROB))
|
||||
{
|
||||
|
@ -505,7 +496,9 @@ _cb_animator(void *data)
|
|||
}
|
||||
}
|
||||
if ((tux->y + tux->action->h) < pop->height)
|
||||
if (!_is_inside_any_win(pop, (int)tux->x+(tux->action->w/2), (int)tux->y+tux->action->h+1, RETURN_NONE_VALUE))
|
||||
if (!_is_inside_any_win(pop, (int)tux->x + (tux->action->w / 2),
|
||||
(int)tux->y + tux->action->h + 1,
|
||||
RETURN_NONE_VALUE))
|
||||
_start_falling_at(tux, (int)tux->x + (tux->action->w / 2));
|
||||
}
|
||||
}
|
||||
|
@ -596,19 +589,14 @@ _is_inside_any_win(Penguins_Population *pop, int x, int y, int ret_value)
|
|||
{
|
||||
case RETURN_NONE_VALUE:
|
||||
return 1;
|
||||
break;
|
||||
case RETURN_RIGHT_VALUE:
|
||||
return ec->x + ec->w;
|
||||
break;
|
||||
case RETURN_BOTTOM_VALUE:
|
||||
return ec->y + ec->h;
|
||||
break;
|
||||
case RETURN_TOP_VALUE:
|
||||
return ec->y;
|
||||
break;
|
||||
case RETURN_LEFT_VALUE:
|
||||
return ec->x;
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
@ -662,7 +650,7 @@ _start_walking_at(Penguins_Actor *tux, int at_y)
|
|||
{
|
||||
//printf("PENGUINS: Start walking...at %d\n", at_y);
|
||||
tux->action = eina_hash_find(tux->pop->actions, "Walker");
|
||||
tux->custom = 0;
|
||||
tux->custom = NULL;
|
||||
|
||||
tux->y = at_y - tux->action->h;
|
||||
evas_object_resize(tux->obj, tux->action->w, tux->action->h);
|
||||
|
@ -730,7 +718,7 @@ _start_falling_at(Penguins_Actor *tux, int at_x)
|
|||
}
|
||||
}
|
||||
tux->faller_h = (int)tux->y;
|
||||
tux->custom = 0;
|
||||
tux->custom = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -759,7 +747,7 @@ _start_angel_at(Penguins_Actor *tux, int at_y)
|
|||
tux->x = tux->x - (tux->action->w / 2);
|
||||
tux->y = at_y - 10;
|
||||
|
||||
tux->custom = 0;
|
||||
tux->custom = NULL;
|
||||
edje_object_signal_emit(tux->obj, "start_angel", "epenguins");
|
||||
evas_object_move(tux->obj,(int)tux->x,(int)tux->y);
|
||||
evas_object_resize(tux->obj, tux->action->w, tux->action->h);
|
||||
|
@ -769,6 +757,7 @@ static void
|
|||
_cb_splatter_end(void *data, Evas_Object *o, const char *emi, const char *src)
|
||||
{
|
||||
Penguins_Actor *tux = data;
|
||||
|
||||
edje_object_signal_callback_del(o,"splatting_done","edje", _cb_splatter_end);
|
||||
_start_angel_at(tux, tux->y + tux->action->h + 10);
|
||||
}
|
||||
|
@ -780,7 +769,6 @@ _start_splatting_at(Penguins_Actor *tux, int at_y)
|
|||
evas_object_hide(tux->obj);
|
||||
tux->action = eina_hash_find(tux->pop->actions, "Splatter");
|
||||
evas_object_resize(tux->obj, tux->action->w, tux->action->h);
|
||||
evas_object_image_fill_set(tux->obj, 0, 0, tux->action->w, tux->action->h);
|
||||
tux->y = at_y - tux->action->h;
|
||||
if (tux->reverse)
|
||||
edje_object_signal_emit(tux->obj, "start_splatting_left", "epenguins");
|
||||
|
@ -789,7 +777,6 @@ _start_splatting_at(Penguins_Actor *tux, int at_y)
|
|||
|
||||
edje_object_signal_callback_add(tux->obj,"splatting_done","edje", _cb_splatter_end, tux);
|
||||
evas_object_resize(tux->obj, tux->action->w, tux->action->h);
|
||||
evas_object_image_fill_set(tux->obj, 0, 0, tux->action->w, tux->action->h);
|
||||
evas_object_move(tux->obj, (int)tux->x, (int)tux->y);
|
||||
evas_object_show(tux->obj);
|
||||
}
|
||||
|
@ -798,6 +785,7 @@ static void
|
|||
_cb_bomber_end(void *data, Evas_Object *o, const char *emi, const char *src)
|
||||
{
|
||||
Penguins_Actor *tux = data;
|
||||
|
||||
edje_object_signal_callback_del(o,"bombing_done","edje", _cb_bomber_end);
|
||||
_start_angel_at(tux, tux->y);
|
||||
}
|
||||
|
@ -824,7 +812,6 @@ _start_bombing_at(Penguins_Actor *tux, int at_y)
|
|||
tux->y = at_y - tux->action->h;
|
||||
|
||||
edje_object_signal_callback_add(tux->obj,"bombing_done","edje", _cb_bomber_end, tux);
|
||||
evas_object_image_fill_set(tux->obj, 0, 0, tux->action->w, tux->action->h);
|
||||
evas_object_resize(tux->obj, tux->action->w, tux->action->h);
|
||||
evas_object_move(tux->obj, (int)tux->x, (int)tux->y);
|
||||
}
|
||||
|
@ -833,6 +820,7 @@ static void
|
|||
_cb_custom_end(void *data, Evas_Object *o, const char *emi, const char *src)
|
||||
{
|
||||
Penguins_Actor* tux = data;
|
||||
|
||||
//printf("PENGUINS: Custom action end.\n");
|
||||
if (!tux->custom)
|
||||
return;
|
||||
|
@ -862,13 +850,10 @@ _start_custom_at(Penguins_Actor *tux, int at_y)
|
|||
return;
|
||||
|
||||
ran = random() % (tux->pop->custom_num);
|
||||
//ran=2; //!!!!
|
||||
//printf("START CUSTOM NUM %d RAN %d\n",tux->pop->custom_num, ran);
|
||||
|
||||
tux->custom = eina_list_nth(tux->pop->customs, ran);
|
||||
if (!tux->custom)
|
||||
return;
|
||||
|
||||
if (!tux->custom) return;
|
||||
|
||||
evas_object_resize(tux->obj, tux->custom->w, tux->custom->h);
|
||||
tux->y = at_y - tux->custom->h;
|
||||
|
@ -890,4 +875,3 @@ _start_custom_at(Penguins_Actor *tux, int at_y)
|
|||
edje_object_signal_callback_add(tux->obj,"custom_done","edje", _cb_custom_end, tux);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue