Example #1
0
static void
function_change_apply_revert( ObjectChange* objchg, DiaObject* obj)
{
  int tmp ;
  char* ttxt ;
  FunctionChange* change = (FunctionChange*) objchg ;
  Function* fcn = (Function*) obj ;

  if ( change->change_type == WISH_FUNC || change->change_type == ALL ) {
     tmp = fcn->is_wish ;
     fcn->is_wish = change->is_wish ;
     change->is_wish = tmp ;
  }
  if ( change->change_type == USER_FUNC || change->change_type == ALL ) {
     tmp = fcn->is_user ;
     fcn->is_user = change->is_user ;
     change->is_user = tmp ;
  }
  if ( change->change_type == TEXT_EDIT || change->change_type == ALL ) {
     ttxt = text_get_string_copy( fcn->text ) ;
     text_set_string( fcn->text, change->text ) ;
     g_free( change->text ) ;
     change->text = ttxt ;
  }
}
Example #2
0
int
text_delete_all(Text *text, ObjectChange **change, DiaObject *obj)
{
  if (!text_is_empty(text)) {
    *change = text_create_change(text, TYPE_DELETE_ALL,
				 0, text->cursor_pos, text->cursor_row,
				 obj);
    
    text_set_string(text, "");
    calc_ascent_descent(text);
    return TRUE;
  }
  return FALSE;
}
Example #3
0
gboolean 
apply_textstr_properties(GPtrArray *props,
                         Text *text, const gchar *textname,
                         const gchar *str)
{
  TextProperty *textprop = 
    (TextProperty *)find_prop_by_name_and_type(props,textname,PROP_TYPE_TEXT);

  if ((!textprop) || 
      ((textprop->common.experience & (PXP_LOADED|PXP_SFO))==0 )) {
    /* most likely we're called after the dialog box has been applied */
    text_set_string(text,str);
    return TRUE; 
  }
  return FALSE;
}
Example #4
0
static ObjectChange *
function_insert_word( Function* func, const char* word, gboolean newline )
{
  ObjectChange* change = function_create_change( func, TEXT_EDIT ) ;
  char* old_chars = text_get_string_copy( func->text ) ;
  char* new_chars = g_malloc( strlen( old_chars) + strlen( word )
		  	+ ( newline ? 2 : 1) ) ;
  sprintf( new_chars, newline ? "%s\n%s" : "%s%s", old_chars, word ) ;
  text_set_string( func->text, new_chars ) ;
  g_free( new_chars ) ;
  g_free( old_chars ) ;
  function_update_data( func ) ;
  text_set_cursor_at_end( func->text ) ;

  return change;
}
void game_screen_input_task(screen_ptr_t screen_ptr, input_state_ptr_t input_state_ptr)
{
    /*** debug ***/ // fprintf(stdout, "[Trace] game_screen_input_task()\n");
    
    // handle input
    actor_ptr_t player_ptr = model_ptr->actor_ptr;
    area_ptr_t area_ptr = player_ptr->area_ptr;
    area_ptr_t left_area_ptr;
    area_ptr_t right_area_ptr;
    area_ptr_t back_area_ptr;
    game_screen_get_area_paths(player_ptr, area_ptr, &left_area_ptr, &right_area_ptr, &back_area_ptr);

    area_ptr_t next_area_ptr = NULL;
    if (input_state_ptr->event == event_button_down && input_state_ptr->button == 1 && input_state_ptr->x < runtime.screen_width / 4)
    {
        next_area_ptr = left_area_ptr;
    }
    else if (input_state_ptr->event == event_button_down && input_state_ptr->button == 1 && input_state_ptr->x > runtime.screen_width / 4 * 3)
    {
        next_area_ptr = right_area_ptr;
    }
    else if (input_state_ptr->event == event_button_down && input_state_ptr->button == 1 && input_state_ptr->y > runtime.screen_height / 4 * 3)
    {
        next_area_ptr = back_area_ptr;
    }
    if (next_area_ptr != NULL)
    {
        player_ptr->prev_area_ptr = player_ptr->area_ptr;
        player_ptr->area_ptr = next_area_ptr;
        area_remove_actor(player_ptr->prev_area_ptr, player_ptr);
        area_add_actor(player_ptr->area_ptr, player_ptr);
        area_ptr = player_ptr->area_ptr;
        game_screen_get_area_paths(player_ptr, area_ptr, &left_area_ptr, &right_area_ptr, &back_area_ptr);
    }

    // update screen objects based on model
    char* area_string = area_ptr->string_ptr;
    text_ptr_t area_text_ptr = screen_ptr->text_ptr_array[AREA_TEXT_INDEX];
    text_set_string(area_text_ptr, "DejaVuSans", 128, &color_white, area_string);
    area_text_ptr->x = runtime.screen_width / 2 - runtime_surface_width(area_text_ptr->surface_ptr) / 2;
    area_text_ptr->y = runtime_surface_height(area_text_ptr->surface_ptr) / 4;

    char* left_area_string = left_area_ptr->string_ptr;
    text_ptr_t left_area_text_ptr = screen_ptr->text_ptr_array[LEFT_AREA_TEXT_INDEX];
    text_set_string(left_area_text_ptr, "DejaVuSans", 128, &color_white, left_area_string);
    left_area_text_ptr->x = runtime_surface_height(left_area_text_ptr->surface_ptr) / 4;
    left_area_text_ptr->y = runtime.screen_height / 2 - runtime_surface_height(left_area_text_ptr->surface_ptr) / 2;
    
    char* right_area_string = right_area_ptr->string_ptr;
    text_ptr_t right_area_text_ptr = screen_ptr->text_ptr_array[RIGHT_AREA_TEXT_INDEX];
    text_set_string(right_area_text_ptr, "DejaVuSans", 128, &color_white, right_area_string);
    right_area_text_ptr->x = runtime.screen_width - runtime_surface_width(right_area_text_ptr->surface_ptr) - runtime_surface_height(right_area_text_ptr->surface_ptr) / 4;
    right_area_text_ptr->y = runtime.screen_height / 2 - runtime_surface_height(right_area_text_ptr->surface_ptr) / 2;
    
    char* back_area_string = back_area_ptr->string_ptr;
    text_ptr_t back_area_text_ptr = screen_ptr->text_ptr_array[BACK_AREA_TEXT_INDEX];
    text_set_string(back_area_text_ptr, "DejaVuSans", 128, &color_white, back_area_string);
    back_area_text_ptr->x = runtime.screen_width / 2 - runtime_surface_width(back_area_text_ptr->surface_ptr) / 2;
    back_area_text_ptr->y = runtime.screen_height - runtime_surface_height(back_area_text_ptr->surface_ptr) - runtime_surface_height(back_area_text_ptr->surface_ptr) / 4;

    text_ptr_t squid_text_ptr = screen_ptr->text_ptr_array[SQUID_TEXT_INDEX];
    if (area_has_actor_type(area_ptr, ACTOR_TYPE_SQUID))
    {
        squid_text_ptr->z = 0;
    }
    else
    {
        squid_text_ptr->z = -1;
    }
    text_ptr_t wisp_text_ptr = screen_ptr->text_ptr_array[WISP_TEXT_INDEX];
    if (area_has_actor_type(area_ptr, ACTOR_TYPE_WISP))
    {
        wisp_text_ptr->z = 0;
    }
    else
    {
        wisp_text_ptr->z = -1;
    }
    text_ptr_t vines_text_ptr = screen_ptr->text_ptr_array[VINES_TEXT_INDEX];
    if (area_has_actor_type(area_ptr, ACTOR_TYPE_VINES))
    {
        vines_text_ptr->z = 0;
    }
    else
    {
        vines_text_ptr->z = -1;
    }
    text_ptr_t squid_near_text_ptr = screen_ptr->text_ptr_array[SQUID_NEAR_TEXT_INDEX];
    if (area_has_actor_type(left_area_ptr, ACTOR_TYPE_SQUID) || area_has_actor_type(right_area_ptr, ACTOR_TYPE_SQUID) || area_has_actor_type(back_area_ptr, ACTOR_TYPE_SQUID))
    {
        squid_near_text_ptr->z = 0;
    }
    else
    {
        squid_near_text_ptr->z = -1;
    }
    text_ptr_t wisp_near_text_ptr = screen_ptr->text_ptr_array[WISP_NEAR_TEXT_INDEX];
    if (area_has_actor_type(left_area_ptr, ACTOR_TYPE_WISP) || area_has_actor_type(right_area_ptr, ACTOR_TYPE_WISP) || area_has_actor_type(back_area_ptr, ACTOR_TYPE_WISP))
    {
        wisp_near_text_ptr->z = 0;
    }
    else
    {
        wisp_near_text_ptr->z = -1;
    }
    text_ptr_t vines_near_text_ptr = screen_ptr->text_ptr_array[VINES_NEAR_TEXT_INDEX];
    if (area_has_actor_type(left_area_ptr, ACTOR_TYPE_VINES) || area_has_actor_type(right_area_ptr, ACTOR_TYPE_VINES) || area_has_actor_type(back_area_ptr, ACTOR_TYPE_VINES))
    {
        vines_near_text_ptr->z = 0;
    }
    else
    {
        vines_near_text_ptr->z = -1;
    }
}